/*! \brief * Initializes position calculation using the maximum possible input index. * * \param[in,out] pc Position calculation data structure. * \param[in] g Maximum index group for the calculation. * \param[in] bBase Whether \p pc will be used as a base or not. * * \p bBase affects on how the \p pc->gmax field is initialized. */ static void set_poscalc_maxindex(gmx_ana_poscalc_t *pc, gmx_ana_index_t *g, bool bBase) { e_index_t ptype; ptype = index_type_for_poscalc(pc->type); gmx_ana_index_make_block(&pc->b, pc->coll->top, g, ptype, pc->flags & POS_COMPLWHOLE); /* Set the type to POS_ATOM if the calculation in fact is such. */ if (pc->b.nr == pc->b.nra) { pc->type = POS_ATOM; pc->flags &= ~(POS_MASS | POS_COMPLMAX | POS_COMPLWHOLE); } /* Set the POS_COMPLWHOLE flag if the calculation in fact always uses * complete residues and molecules. */ if (!(pc->flags & POS_COMPLWHOLE) && (!(pc->flags & POS_DYNAMIC) || (pc->flags & POS_COMPLMAX)) && (pc->type == POS_RES || pc->type == POS_MOL) && gmx_ana_index_has_complete_elems(g, ptype, pc->coll->top)) { pc->flags &= ~POS_COMPLMAX; pc->flags |= POS_COMPLWHOLE; } /* Setup the gmax field */ if ((pc->flags & POS_COMPLWHOLE) && !bBase && pc->b.nra > g->isize) { gmx_ana_index_copy(&pc->gmax, g, TRUE); sfree(pc->gmax.name); pc->gmax.name = NULL; } else { gmx_ana_index_set(&pc->gmax, pc->b.nra, pc->b.a, NULL, 0); } }
/*! * \param[in,out] m Mapping structure to initialize. * \param[in] g Index group to map * (can be NULL if \p type is \ref INDEX_UNKNOWN). * \param[in] top Topology structure * (can be NULL if \p type is not \ref INDEX_RES or \ref INDEX_MOL). * \param[in] type Type of mapping to construct. * * Initializes a new index group mapping. * The index group provided to gmx_ana_indexmap_update() should always be a * subset of the \p g given here. * * \p m should have been initialized somehow (calloc() is enough). */ void gmx_ana_indexmap_init(gmx_ana_indexmap_t *m, gmx_ana_index_t *g, t_topology *top, e_index_t type) { int i, ii, mi; 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); for (i = mi = 0; i < m->b.nr; ++i) { ii = (type == INDEX_UNKNOWN ? 0 : m->b.a[m->b.index[i]]); switch (type) { case INDEX_ATOM: m->orgid[i] = ii; break; case INDEX_RES: m->orgid[i] = top->atoms.atom[ii].resind; break; case INDEX_MOL: while (top->mols.index[mi+1] <= ii) { ++mi; } m->orgid[i] = mi; break; case INDEX_ALL: case INDEX_UNKNOWN: m->orgid[i] = 0; break; } } for (i = 0; i < m->b.nr; ++i) { m->refid[i] = i; m->mapid[i] = m->orgid[i]; } 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->b.nr+1)*sizeof(*(m->mapb.index))); m->bStatic = true; }
/*! * \param[in,out] m Mapping structure to initialize. * \param[in] g Index group to map * (can be NULL if \p type is \ref INDEX_UNKNOWN). * \param[in] top Topology structure * (can be NULL if \p type is not \ref INDEX_RES or \ref INDEX_MOL). * \param[in] type Type of mapping to construct. * * Initializes a new index group mapping. * The index group provided to gmx_ana_indexmap_update() should always be a * subset of the \p g given here. * * \p m should have been initialized somehow (calloc() is enough). */ void gmx_ana_indexmap_init(gmx_ana_indexmap_t *m, gmx_ana_index_t *g, t_topology *top, e_index_t type) { 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); int id = -1; for (int i = 0; i < m->b.nr; ++i) { const int ii = (type == INDEX_UNKNOWN ? 0 : m->b.a[m->b.index[i]]); next_group_index(ii, top, type, &id); m->refid[i] = i; m->mapid[i] = id; m->orgid[i] = id; } 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->b.nr+1)*sizeof(*(m->mapb.index))); m->bStatic = true; }