/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
sel->u.expr.method->init_frame(data->top, data->fr, data->pbc,
sel->u.expr.mdata);
}
- GMX_RELEASE_ASSERT(sel->child != NULL,
- "Modifier element with a value must have a child");
- if (sel->child->v.type != POS_VALUE)
+ if (sel->child && sel->child->v.type != POS_VALUE)
{
GMX_THROW(gmx::NotImplementedError("Non-position valued modifiers not implemented"));
}
sel->u.expr.method->pupdate(data->top, data->fr, data->pbc,
- sel->child->v.u.p,
- &sel->v, sel->u.expr.mdata);
+ NULL, &sel->v, sel->u.expr.mdata);
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* (depending on \p type) that is partially contained in the group.
* If \p type is not INDEX_RES or INDEX_MOL, this has no effect.
*
- * \p m should have been initialized somehow (calloc() is enough) unless
- * \p type is INDEX_UNKNOWN.
+ * \p m should have been initialized somehow (calloc() is enough).
* \p g should be sorted.
*/
void
{
if (type == INDEX_UNKNOWN)
{
+ sfree(t->a);
+ srenew(t->index, 2);
t->nr = 1;
- snew(t->index, 2);
t->nalloc_index = 2;
t->index[0] = 0;
t->index[1] = 0;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
{
gmx_ana_indexmap_set_static(&p->m, &pc->b);
}
- gmx_ana_pos_reserve(p, p->m.mapb.nr, 0);
+ gmx_ana_pos_reserve(p, p->m.mapb.nr, -1);
if (pc->flags & POS_VELOCITIES)
{
gmx_ana_pos_reserve_velocities(p);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
srenew(pos->f, n);
}
}
- if (isize > 0)
+ if (isize >= 0)
{
gmx_ana_indexmap_reserve(&pos->m, n, isize);
}
{
if (bFirst)
{
- gmx_ana_pos_reserve(dest, src->count(), 0);
+ gmx_ana_pos_reserve(dest, src->count(), -1);
if (src->v)
{
gmx_ana_pos_reserve_velocities(dest);
pos->m.mapb.nra = 0;
pos->m.b.nr = 0;
pos->m.b.nra = 0;
- /* This should not really be necessary, but do it for safety... */
+ /* Initializing these should not really be necessary, but do it for
+ * safety... */
pos->m.mapb.index[0] = 0;
pos->m.b.index[0] = 0;
/* This function should only be used to construct all the possible
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
while (child->type == SEL_MODIFIER)
{
child = child->child;
+ if (!child)
+ {
+ break;
+ }
if (child->type == SEL_SUBEXPRREF)
{
child = child->child;
}
}
}
- /* For variable references, we should skip the
- * SEL_SUBEXPRREF and SEL_SUBEXPR elements. */
- if (child->type == SEL_SUBEXPRREF)
+ if (child)
{
- child = child->child->child;
+ /* For variable references, we should skip the
+ * SEL_SUBEXPRREF and SEL_SUBEXPR elements. */
+ if (child->type == SEL_SUBEXPRREF)
+ {
+ child = child->child->child;
+ }
+ bDynamic_ = (child->child->flags & SEL_DYNAMIC);
}
- bDynamic_ = (child->child->flags & SEL_DYNAMIC);
}
initCoveredFraction(CFRAC_NONE);
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
static void
evaluate_permute(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
- gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data)
+ gmx_ana_pos_t * /*p*/, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_permute *d = (t_methoddata_permute *)data;
int i, j, b;
/* De-permute the reference ID */
refid = refid - (refid % d->n) + d->perm[refid % d->n];
}
- gmx_ana_pos_append(out->u.p, p, b, refid);
+ gmx_ana_pos_append(out->u.p, &d->p, b, refid);
}
}
gmx_ana_pos_append_finish(out->u.p);
<Sequence Name="Atoms">
<Int Name="Length">0</Int>
</Sequence>
+ <Sequence Name="Positions">
+ <Int Name="Length">1</Int>
+ <Position>
+ <Int Name="RefId">0</Int>
+ <Int Name="MappedId">0</Int>
+ </Position>
+ </Sequence>
</Selection>
</CompiledSelections>
<EvaluatedSelections Name="Frame1">
<Real Name="Y">-2</Real>
<Real Name="Z">3.5</Real>
</Vector>
+ <Int Name="RefId">0</Int>
+ <Int Name="MappedId">0</Int>
</Position>
</Sequence>
</Selection>
--- /dev/null
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+ <ParsedSelections Name="Parsed">
+ <ParsedSelection Name="Selection1">
+ <String Name="Input">[0, 0, 0] plus [0, 1, 0]</String>
+ <String Name="Text">[0, 0, 0] plus [0, 1, 0]</String>
+ <Bool Name="Dynamic">false</Bool>
+ </ParsedSelection>
+ </ParsedSelections>
+ <CompiledSelections Name="Compiled">
+ <Selection Name="Selection1">
+ <Sequence Name="Atoms">
+ <Int Name="Length">0</Int>
+ </Sequence>
+ <Sequence Name="Positions">
+ <Int Name="Length">2</Int>
+ <Position>
+ <Int Name="RefId">0</Int>
+ <Int Name="MappedId">0</Int>
+ </Position>
+ <Position>
+ <Int Name="RefId">1</Int>
+ <Int Name="MappedId">0</Int>
+ </Position>
+ </Sequence>
+ </Selection>
+ </CompiledSelections>
+ <EvaluatedSelections Name="Frame1">
+ <Selection Name="Selection1">
+ <Sequence Name="Atoms">
+ <Int Name="Length">0</Int>
+ </Sequence>
+ <Sequence Name="Positions">
+ <Int Name="Length">2</Int>
+ <Position>
+ <Vector Name="Coordinates">
+ <Real Name="X">0</Real>
+ <Real Name="Y">0</Real>
+ <Real Name="Z">0</Real>
+ </Vector>
+ <Int Name="RefId">0</Int>
+ <Int Name="MappedId">0</Int>
+ </Position>
+ <Position>
+ <Vector Name="Coordinates">
+ <Real Name="X">0</Real>
+ <Real Name="Y">1</Real>
+ <Real Name="Z">0</Real>
+ </Vector>
+ <Int Name="RefId">1</Int>
+ <Int Name="MappedId">0</Int>
+ </Position>
+ </Sequence>
+ </Selection>
+ </EvaluatedSelections>
+</ReferenceData>
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
+
TEST_F(SelectionCollectionDataTest, HandlesConstantPositions)
{
static const char * const selections[] = {
"[1, -2, 3.5]"
};
- setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
+ setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
+ | efTestPositionMapping);
+ runTest("simple.gro", selections);
+}
+
+
+TEST_F(SelectionCollectionDataTest, HandlesConstantPositionsWithModifiers)
+{
+ static const char * const selections[] = {
+ "[0, 0, 0] plus [0, 1, 0]"
+ };
+ setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
+ | efTestPositionMapping);
runTest("simple.gro", selections);
}