GMX_RELEASE_ASSERT(child,
"Subexpression elements should always have a child element");
}
- nalloc = child->v.u.p->nr;
+ nalloc = child->v.u.p->count();
isize = child->v.u.p->m.b.nra;
/* For positions, we want to allocate just a single structure
gmx_ana_indexmap_clear(gmx_ana_indexmap_t *m)
{
m->type = INDEX_UNKNOWN;
- m->nr = 0;
m->refid = NULL;
m->mapid = NULL;
m->mapb.nr = 0;
m->type = type;
gmx_ana_index_make_block(&m->b, top, g, type, false);
gmx_ana_indexmap_reserve(m, m->b.nr, m->b.nra);
- m->nr = m->b.nr;
- for (i = mi = 0; i < m->nr; ++i)
+ for (i = mi = 0; i < m->b.nr; ++i)
{
ii = (type == INDEX_UNKNOWN ? 0 : m->b.a[m->b.index[i]]);
switch (type)
break;
}
}
- for (i = 0; i < m->nr; ++i)
+ for (i = 0; i < m->b.nr; ++i)
{
m->refid[i] = i;
m->mapid[i] = m->orgid[i];
}
- m->mapb.nr = m->nr;
+ m->mapb.nr = m->b.nr;
m->mapb.nra = m->b.nra;
m->mapb.a = m->b.a;
- std::memcpy(m->mapb.index, m->b.index, (m->nr+1)*sizeof(*(m->mapb.index)));
+ std::memcpy(m->mapb.index, m->b.index, (m->b.nr+1)*sizeof(*(m->mapb.index)));
m->bStatic = true;
}
std::memcpy(dest->b.index, src->b.index, (dest->b.nr+1)*sizeof(*dest->b.index));
std::memcpy(dest->b.a, src->b.a, dest->b.nra*sizeof(*dest->b.a));
}
- dest->nr = src->nr;
dest->mapb.nr = src->mapb.nr;
dest->mapb.nra = src->mapb.nra;
if (src->mapb.nalloc_a > 0)
{
dest->mapb.a = src->mapb.a;
}
- std::memcpy(dest->refid, src->refid, dest->nr*sizeof(*dest->refid));
- std::memcpy(dest->mapid, src->mapid, dest->nr*sizeof(*dest->mapid));
+ std::memcpy(dest->refid, src->refid, dest->mapb.nr*sizeof(*dest->refid));
+ std::memcpy(dest->mapid, src->mapid, dest->mapb.nr*sizeof(*dest->mapid));
std::memcpy(dest->mapb.index, src->mapb.index, (dest->mapb.nr+1)*sizeof(*dest->mapb.index));
dest->bStatic = src->bStatic;
}
}
}
set_atoms(m, m->b.nra, m->b.a);
- m->nr = m->mapb.nr = m->b.nr;
+ m->mapb.nr = m->b.nr;
}
/* Exit immediately if the group is static */
if (bToFull)
if (bMaskOnly)
{
- m->nr = m->b.nr;
for (i = j = bj = 0; i < g->isize; ++i, ++j)
{
/* Find the next atom in the block */
}
/* Update the number of blocks */
m->mapb.index[bi] = g->isize;
- m->nr = bi;
+ m->mapb.nr = bi;
}
- m->mapb.nr = m->nr;
m->bStatic = false;
}
{
/** Type of the mapping. */
e_index_t type;
- /*! \brief
- * Current number of mapped values.
- *
- * This is the current number of values in the \p refid and \p mapid
- * arrays.
- * If \p bMaskOnly is provided to gmx_ana_indexmap_update(), this
- * is always equal to \p b.nr, i.e., the number of blocks in the
- * original index group.
- */
- int nr;
/*! \brief
* Current reference IDs.
*
if (param->val.type == POS_VALUE)
{
gmx_ana_pos_reserve(param->val.u.p, valueCount, 0);
- gmx_ana_pos_set_nr(param->val.u.p, valueCount);
gmx_ana_indexmap_init(¶m->val.u.p->m, NULL, NULL, INDEX_UNKNOWN);
+ gmx_ana_pos_set_nr(param->val.u.p, valueCount);
}
else
{
{
gmx_ana_indexmap_set_static(&p->m, &pc->b);
}
- gmx_ana_pos_reserve(p, p->m.nr, 0);
+ gmx_ana_pos_reserve(p, p->m.mapb.nr, 0);
if (pc->flags & POS_VELOCITIES)
{
gmx_ana_pos_reserve_velocities(p);
{
gmx_ana_pos_reserve_forces(p);
}
- gmx_ana_pos_set_nr(p, p->m.nr);
}
/*!
if (pc->flags & POS_DYNAMIC)
{
gmx_ana_indexmap_update(&p->m, g, false);
- p->nr = p->m.nr;
}
else if (pc->flags & POS_MASKONLY)
{
* loop instead of in the beginning. */
if (pc->flags & POS_DYNAMIC)
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[p->m.refid[bi]];
copy_rvec(pc->sbase->p->x[bj], p->x[bi]);
}
if (p->v)
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[p->m.refid[bi]];
copy_rvec(pc->sbase->p->v[bj], p->v[bi]);
}
if (p->f)
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[p->m.refid[bi]];
copy_rvec(pc->sbase->p->f[bj], p->f[bi]);
}
else
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[bi];
copy_rvec(pc->sbase->p->x[bj], p->x[bi]);
}
if (p->v)
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[bi];
copy_rvec(pc->sbase->p->v[bj], p->v[bi]);
}
if (p->f)
{
- for (bi = 0; bi < p->nr; ++bi)
+ for (bi = 0; bi < p->count(); ++bi)
{
bj = pc->baseid[bi];
copy_rvec(pc->sbase->p->f[bj], p->f[bi]);
void
gmx_ana_pos_clear(gmx_ana_pos_t *pos)
{
- pos->nr = 0;
pos->x = NULL;
pos->v = NULL;
pos->f = NULL;
gmx_ana_pos_init_const(gmx_ana_pos_t *pos, const rvec x)
{
gmx_ana_pos_clear(pos);
- pos->nr = 1;
snew(pos->x, 1);
snew(pos->v, 1);
snew(pos->f, 1);
void
gmx_ana_pos_deinit(gmx_ana_pos_t *pos)
{
- pos->nr = 0;
sfree(pos->x); pos->x = NULL;
sfree(pos->v); pos->v = NULL;
sfree(pos->f); pos->f = NULL;
{
if (bFirst)
{
- gmx_ana_pos_reserve(dest, src->nr, 0);
+ gmx_ana_pos_reserve(dest, src->count(), 0);
if (src->v)
{
gmx_ana_pos_reserve_velocities(dest);
gmx_ana_pos_reserve_forces(dest);
}
}
- dest->nr = src->nr;
- memcpy(dest->x, src->x, dest->nr*sizeof(*dest->x));
+ memcpy(dest->x, src->x, src->count()*sizeof(*dest->x));
if (dest->v)
{
GMX_ASSERT(src->v, "src velocities should be non-null if dest velocities are allocated");
- memcpy(dest->v, src->v, dest->nr*sizeof(*dest->v));
+ memcpy(dest->v, src->v, src->count()*sizeof(*dest->v));
}
if (dest->f)
{
GMX_ASSERT(src->f, "src forces should be non-null if dest forces are allocated");
- memcpy(dest->f, src->f, dest->nr*sizeof(*dest->f));
+ memcpy(dest->f, src->f, src->count()*sizeof(*dest->f));
}
gmx_ana_indexmap_copy(&dest->m, &src->m, bFirst);
}
void
gmx_ana_pos_set_nr(gmx_ana_pos_t *pos, int nr)
{
- pos->nr = nr;
+ // TODO: This puts the mapping in a somewhat inconsistent state.
+ pos->m.mapb.nr = nr;
}
/*!
void
gmx_ana_pos_empty_init(gmx_ana_pos_t *pos)
{
- pos->nr = 0;
- pos->m.nr = 0;
pos->m.mapb.nr = 0;
pos->m.mapb.nra = 0;
pos->m.b.nr = 0;
void
gmx_ana_pos_empty(gmx_ana_pos_t *pos)
{
- pos->nr = 0;
- pos->m.nr = 0;
pos->m.mapb.nr = 0;
pos->m.mapb.nra = 0;
/* This should not really be necessary, but do it for safety... */
{
int j, k;
- j = dest->nr;
+ j = dest->count();
copy_rvec(src->x[i], dest->x[j]);
if (dest->v)
{
}
dest->m.mapb.index[j+1] = dest->m.mapb.nra;
dest->m.b.index[j+1] = dest->m.mapb.nra;
- dest->nr++;
- dest->m.nr = dest->nr;
- dest->m.mapb.nr = dest->nr;
- dest->m.b.nr = dest->nr;
+ dest->m.mapb.nr++;
+ dest->m.b.nr++;
}
/*!
{
dest->m.mapb.a[dest->m.mapb.nra++] = src->m.mapb.a[k];
}
- const int j = dest->nr;
+ const int j = dest->count();
if (dest->v)
{
if (src->v)
dest->m.mapid[j] = dest->m.orgid[refid];
}
dest->m.mapb.index[j+1] = dest->m.mapb.nra;
- dest->nr++;
- dest->m.nr = dest->nr;
- dest->m.mapb.nr = dest->nr;
+ dest->m.mapb.nr++;
}
/*!
void
gmx_ana_pos_append_finish(gmx_ana_pos_t *pos)
{
- if (pos->m.nr != pos->m.b.nr)
+ if (pos->m.mapb.nr != pos->m.b.nr)
{
pos->m.bStatic = false;
}
*/
typedef struct gmx_ana_pos_t
{
- /*! \brief
- * Number of positions.
- */
- int nr;
+ //! Returns the number of positions.
+ int count() const { return m.mapb.nr; }
+
/*! \brief
* Array of positions.
*/
GMX_ASSERT(top != NULL, "Should not have been called with NULL topology");
masses->clear();
charges->clear();
- for (int b = 0; b < pos.nr; ++b)
+ for (int b = 0; b < pos.count(); ++b)
{
real mass = 0.0;
real charge = 0.0;
gmx_ana_pos_t &p = rawPositions_;
gmx_ana_indexmap_update(&p.m, rootElement().v.u.g,
hasFlag(gmx::efSelection_DynamicMask));
- p.nr = p.m.nr;
refreshMassesAndCharges(top);
}
}
Selection::operator AnalysisNeighborhoodPositions() const
{
return AnalysisNeighborhoodPositions(data().rawPositions_.x,
- data().rawPositions_.nr);
+ data().rawPositions_.count());
}
SelectionPosition::operator AnalysisNeighborhoodPositions() const
{
return AnalysisNeighborhoodPositions(sel_->rawPositions_.x,
- sel_->rawPositions_.nr)
+ sel_->rawPositions_.count())
.selectSingleFromArray(i_);
}
e_index_t type() const { return rawPositions_.m.type; }
//! Number of positions in the selection.
- int posCount() const { return rawPositions_.nr; }
+ int posCount() const { return rawPositions_.count(); }
//! Returns the root of the evaluation tree for this selection.
SelectionTreeElement &rootElement() { return rootElement_; }
t_methoddata_distance *d = (t_methoddata_distance *)data;
d->nbsearch.reset();
- gmx::AnalysisNeighborhoodPositions pos(d->p.x, d->p.nr);
+ gmx::AnalysisNeighborhoodPositions pos(d->p.x, d->p.count());
d->nbsearch = d->nb.initSearch(pbc, pos);
}
t_methoddata_distance *d = (t_methoddata_distance *)data;
out->nr = pos->m.mapb.nra;
- for (int b = 0; b < pos->nr; ++b)
+ for (int b = 0; b < pos->count(); ++b)
{
real dist = d->nbsearch.minimumDistance(pos->x[b]);
for (int i = pos->m.mapb.index[b]; i < pos->m.mapb.index[b+1]; ++i)
t_methoddata_distance *d = (t_methoddata_distance *)data;
out->u.g->isize = 0;
- for (int b = 0; b < pos->nr; ++b)
+ for (int b = 0; b < pos->count(); ++b)
{
if (d->nbsearch.isWithin(pos->x[b]))
{
free_surface_points(d);
clear_surface_points(d);
- for (i = 0; i < d->span.nr; ++i)
+ for (i = 0; i < d->span.count(); ++i)
{
if (pbc)
{
evaluate_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
{
- int b;
-
out->u.g->isize = 0;
- for (b = 0; b < pos->nr; ++b)
+ for (int b = 0; b < pos->count(); ++b)
{
if (accept_insolidangle(pos->x[b], pbc, data))
{
/* If no stride given, deduce it from the input sizes */
if (d->stride == 0)
{
- d->stride = d->p1.nr / d->p2.nr;
+ d->stride = d->p1.count() / d->p2.count();
}
- if (d->p1.nr != d->stride*d->p2.nr)
+ if (d->p1.count() != d->stride*d->p2.count())
{
GMX_THROW(gmx::InconsistentInputError("The number of positions to be merged are not compatible"));
}
{
out->u.p->m.type = d->p1.m.type;
}
- gmx_ana_pos_reserve_for_append(out->u.p, d->p1.nr + d->p2.nr,
+ gmx_ana_pos_reserve_for_append(out->u.p, d->p1.count() + d->p2.count(),
d->p1.m.b.nra + d->p2.m.b.nra,
d->p1.v != NULL, d->p1.f != NULL);
gmx_ana_pos_empty_init(out->u.p);
int i, j;
init_output_common(top, out, data);
- for (i = 0; i < d->p2.nr; ++i)
+ for (i = 0; i < d->p2.count(); ++i)
{
for (j = 0; j < d->stride; ++j)
{
int i;
init_output_common(top, out, data);
- for (i = 0; i < d->p1.nr; ++i)
+ for (i = 0; i < d->p1.count(); ++i)
{
gmx_ana_pos_append_init(out->u.p, &d->p1, i);
}
- for (i = 0; i < d->p2.nr; ++i)
+ for (i = 0; i < d->p2.count(); ++i)
{
gmx_ana_pos_append_init(out->u.p, &d->p2, i);
}
int i, j;
int refid;
- if (d->p1.nr != d->stride*d->p2.nr)
+ if (d->p1.count() != d->stride*d->p2.count())
{
GMX_THROW(gmx::InconsistentInputError("The number of positions to be merged are not compatible"));
}
gmx_ana_pos_empty(out->u.p);
- for (i = 0; i < d->p2.nr; ++i)
+ for (i = 0; i < d->p2.count(); ++i)
{
for (j = 0; j < d->stride; ++j)
{
int refid;
gmx_ana_pos_empty(out->u.p);
- for (i = 0; i < d->p1.nr; ++i)
+ for (i = 0; i < d->p1.count(); ++i)
{
refid = d->p1.m.refid[i];
gmx_ana_pos_append(out->u.p, &d->p1, i, refid);
}
- for (i = 0; i < d->p2.nr; ++i)
+ for (i = 0; i < d->p2.count(); ++i)
{
refid = d->p2.m.refid[i];
if (refid != -1)
d->n = param[1].val.nr;
d->perm = param[1].val.u.i;
- if (d->p.nr % d->n != 0)
+ if (d->p.count() % d->n != 0)
{
GMX_THROW(gmx::InconsistentInputError(
gmx::formatString("The number of positions to be permuted is not divisible by %d", d->n)));
int i, j, b;
out->u.p->m.type = d->p.m.type;
- gmx_ana_pos_reserve_for_append(out->u.p, d->p.nr, d->p.m.b.nra,
+ gmx_ana_pos_reserve_for_append(out->u.p, d->p.count(), d->p.m.b.nra,
d->p.v != NULL, d->p.f != NULL);
gmx_ana_pos_empty_init(out->u.p);
- for (i = 0; i < d->p.nr; i += d->n)
+ for (i = 0; i < d->p.count(); i += d->n)
{
for (j = 0; j < d->n; ++j)
{
int i, j, b;
int refid;
- if (d->p.nr % d->n != 0)
+ if (d->p.count() % d->n != 0)
{
GMX_THROW(gmx::InconsistentInputError(
gmx::formatString("The number of positions to be permuted is not divisible by %d", d->n)));
}
gmx_ana_pos_empty(out->u.p);
- for (i = 0; i < d->p.nr; i += d->n)
+ for (i = 0; i < d->p.count(); i += d->n)
{
for (j = 0; j < d->n; ++j)
{
static void
evaluate_coord(real out[], gmx_ana_pos_t *pos, int d)
{
- for (int b = 0; b < pos->nr; ++b)
+ for (int b = 0; b < pos->count(); ++b)
{
const real v = pos->x[b][d];
for (int i = pos->m.mapb.index[b]; i < pos->m.mapb.index[b+1]; ++i)
void IndexMapTest::checkMapping(int atomCount, const int atoms[],
const char *name)
{
- ASSERT_EQ(map_.nr, map_.mapb.nr);
gmx::test::TestReferenceChecker compound(
checker_.checkCompound("IndexMapping", name));
compound.checkSequenceArray(atomCount, atoms, "Input");
- compound.checkInteger(map_.nr, "Count");
- for (int i = 0; i < map_.nr; ++i)
+ compound.checkInteger(map_.mapb.nr, "Count");
+ for (int i = 0; i < map_.mapb.nr; ++i)
{
gmx::test::TestReferenceChecker blockCompound(
compound.checkCompound("Block", NULL));
gmx::test::TestReferenceChecker *checker,
const char *name, gmx_ana_pos_t *p, bool bCoordinates)
{
- EXPECT_EQ(p->nr, p->m.nr);
- EXPECT_EQ(p->nr, p->m.mapb.nr);
gmx::test::TestReferenceChecker compound(
checker->checkCompound("Positions", name));
- compound.checkInteger(p->nr, "Count");
+ compound.checkInteger(p->count(), "Count");
const char *type = "???";
switch (p->m.type)
{
case INDEX_ALL: type = "single"; break;
}
compound.checkString(type, "Type");
- compound.checkSequenceArray(p->nr + 1, p->m.mapb.index, "Block");
- for (int i = 0; i < p->nr; ++i)
+ compound.checkSequenceArray(p->count() + 1, p->m.mapb.index, "Block");
+ for (int i = 0; i < p->count(); ++i)
{
gmx::test::TestReferenceChecker posCompound(
compound.checkCompound("Position", NULL));