static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir, gmx_bool bMergeConstr, gmx_localtop_t *top) { int mb,srcnr,destnr,ftype,ftype_dest,mt,natoms,mol,nposre_old; gmx_molblock_t *molb; gmx_moltype_t *molt; const gmx_ffparams_t *ffp; t_idef *idef; real *qA,*qB; gmx_mtop_atomloop_all_t aloop; int ag; t_atom *atom; top->atomtypes = mtop->atomtypes; ffp = &mtop->ffparams; idef = &top->idef; idef->ntypes = ffp->ntypes; idef->atnr = ffp->atnr; idef->functype = ffp->functype; idef->iparams = ffp->iparams; idef->iparams_posres = NULL; idef->iparams_posres_nalloc = 0; idef->fudgeQQ = ffp->fudgeQQ; idef->cmap_grid = ffp->cmap_grid; idef->ilsort = ilsortUNKNOWN; init_block(&top->cgs); init_blocka(&top->excls); for(ftype=0; ftype<F_NRE; ftype++) { idef->il[ftype].nr = 0; idef->il[ftype].nalloc = 0; idef->il[ftype].iatoms = NULL; } natoms = 0; for(mb=0; mb<mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; molt = &mtop->moltype[molb->type]; srcnr = molt->atoms.nr; destnr = natoms; blockcat(&top->cgs,&molt->cgs,molb->nmol,destnr,srcnr); blockacat(&top->excls,&molt->excls,molb->nmol,destnr,srcnr); nposre_old = idef->il[F_POSRES].nr; for(ftype=0; ftype<F_NRE; ftype++) { if (bMergeConstr && ftype == F_CONSTR && molt->ilist[F_CONSTRNC].nr > 0) { /* Merge all constrains into one ilist. * This simplifies the constraint code. */ for(mol=0; mol<molb->nmol; mol++) { ilistcat(ftype,&idef->il[F_CONSTR],&molt->ilist[F_CONSTR], 1,destnr+mol*srcnr,srcnr); ilistcat(ftype,&idef->il[F_CONSTR],&molt->ilist[F_CONSTRNC], 1,destnr+mol*srcnr,srcnr); } } else if (!(bMergeConstr && ftype == F_CONSTRNC)) { ilistcat(ftype,&idef->il[ftype],&molt->ilist[ftype], molb->nmol,destnr,srcnr); } } if (idef->il[F_POSRES].nr > nposre_old) { set_posres_params(idef,molb,nposre_old/2,natoms); } natoms += molb->nmol*srcnr; } if (ir == NULL) { top->idef.ilsort = ilsortUNKNOWN; } else { if (ir->efep != efepNO && gmx_mtop_bondeds_free_energy(mtop)) { snew(qA,mtop->natoms); snew(qB,mtop->natoms); aloop = gmx_mtop_atomloop_all_init(mtop); while (gmx_mtop_atomloop_all_next(aloop,&ag,&atom)) { qA[ag] = atom->q; qB[ag] = atom->qB; } gmx_sort_ilist_fe(&top->idef,qA,qB); sfree(qA); sfree(qB); } else { top->idef.ilsort = ilsortNO_FE; } } }
static void gen_local_top(gmx_mtop_t *mtop,t_inputrec *ir, gmx_localtop_t *top) { int mb,srcnr,destnr,ftype,mt,natoms,nposre_old; gmx_molblock_t *molb; gmx_moltype_t *molt; gmx_ffparams_t *ffp; t_idef *idef; top->atomtypes = mtop->atomtypes; ffp = &mtop->ffparams; idef = &top->idef; idef->ntypes = ffp->ntypes; idef->atnr = ffp->atnr; idef->functype = ffp->functype; idef->iparams = ffp->iparams; idef->iparams_posres = NULL; idef->iparams_posres_nalloc = 0; idef->fudgeQQ = ffp->fudgeQQ; idef->ilsort = ilsortUNKNOWN; init_block(&top->cgs); init_blocka(&top->excls); for(ftype=0; ftype<F_NRE; ftype++) { idef->il[ftype].nr = 0; idef->il[ftype].nalloc = 0; idef->il[ftype].iatoms = NULL; } natoms = 0; for(mb=0; mb<mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; molt = &mtop->moltype[molb->type]; srcnr = molt->atoms.nr; destnr = natoms; blockcat(&top->cgs,&molt->cgs,molb->nmol,destnr,srcnr); blockacat(&top->excls,&molt->excls,molb->nmol,destnr,srcnr); nposre_old = idef->il[F_POSRES].nr; for(ftype=0; ftype<F_NRE; ftype++) { ilistcat(ftype,&idef->il[ftype],&molt->ilist[ftype],molb->nmol, destnr,srcnr); } if (idef->il[F_POSRES].nr > nposre_old) { set_posres_params(idef,molb,nposre_old/2,natoms); } natoms += molb->nmol*srcnr; } if (ir == NULL) { top->idef.ilsort = ilsortUNKNOWN; } else { if (ir->efep != efepNO && gmx_mtop_bondeds_free_energy(mtop)) { gmx_sort_ilist_fe(&top->idef); } else { top->idef.ilsort = ilsortNO_FE; } } }