/*! * \param[in,out] dest Destination positions. * \param[in] src Source positions. * \param[in] bFirst If true, memory is allocated for \p dest and a full * copy is made; otherwise, only variable parts are copied, and no memory * is allocated. * * \p dest should have been initialized somehow (calloc() is enough). */ void gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst) { if (bFirst) { gmx_ana_pos_reserve(dest, src->count(), 0); if (src->v) { gmx_ana_pos_reserve_velocities(dest); } if (src->f) { gmx_ana_pos_reserve_forces(dest); } } 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, 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, src->count()*sizeof(*dest->f)); } gmx_ana_indexmap_copy(&dest->m, &src->m, bFirst); }
/*! * \param[in,out] dest Destination positions. * \param[in] src Source positions. * \param[in] bFirst If true, memory is allocated for \p dest and a full * copy is made; otherwise, only variable parts are copied, and no memory * is allocated. * * \p dest should have been initialized somehow (calloc() is enough). */ void gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst) { if (bFirst) { gmx_ana_pos_reserve(dest, src->nr, 0); if (src->v) { gmx_ana_pos_reserve_velocities(dest); } if (src->f) { gmx_ana_pos_reserve_forces(dest); } } dest->nr = src->nr; memcpy(dest->x, src->x, dest->nr*sizeof(*dest->x)); if (dest->v) { memcpy(dest->v, src->v, dest->nr*sizeof(*dest->v)); } if (dest->f) { memcpy(dest->f, src->f, dest->nr*sizeof(*dest->f)); } gmx_ana_indexmap_copy(&dest->m, &src->m, bFirst); dest->g = src->g; }
/*! * \param[in,out] pos Position data structure. * \param[in] n Maximum number of positions. * \param[in] isize Maximum number of atoms. * \param[in] bVelocities Whether to reserve space for velocities. * \param[in] bForces Whether to reserve space for forces. * * Ensures that enough memory is allocated in \p pos to calculate \p n * positions from \p isize atoms. * * This method needs to be called instead of gmx_ana_pos_reserve() if the * intent is to use gmx_ana_pos_append_init()/gmx_ana_pos_append(). */ void gmx_ana_pos_reserve_for_append(gmx_ana_pos_t *pos, int n, int isize, bool bVelocities, bool bForces) { gmx_ana_pos_reserve(pos, n, isize); snew(pos->m.mapb.a, isize); pos->m.mapb.nalloc_a = isize; if (bVelocities) { gmx_ana_pos_reserve_velocities(pos); } if (bForces) { gmx_ana_pos_reserve_forces(pos); } }
/*! * \param[in] pc Position calculation data structure. * \param[out] p Output positions. * * Calls to gmx_ana_poscalc_update() using \p pc should use only positions * initialized with this function. * The \c p->g pointer is initialized to point to an internal group that * contains the maximum index group set with gmx_ana_poscalc_set_maxindex(). */ void gmx_ana_poscalc_init_pos(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p) { gmx_ana_indexmap_init(&p->m, &pc->gmax, pc->coll->top_, pc->itype); /* Only do the static optimization when there is no completion */ if (!(pc->flags & POS_DYNAMIC) && pc->b.nra == pc->gmax.isize) { gmx_ana_indexmap_set_static(&p->m, &pc->b); } gmx_ana_pos_reserve(p, p->m.mapb.nr, 0); if (pc->flags & POS_VELOCITIES) { gmx_ana_pos_reserve_velocities(p); } if (pc->flags & POS_FORCES) { gmx_ana_pos_reserve_forces(p); } }