void gmx_rmpbc_done(gmx_rmpbc_t gpbc) { int i; for(i=0; i<gpbc->ngraph; i++) { done_graph(gpbc->graph[i].gr); } if (gpbc->graph != NULL) { sfree(gpbc->graph); } }
static void low_do_pbc_mtop(FILE *fplog,int ePBC,matrix box, gmx_mtop_t *mtop,rvec x[], bool bFirst) { t_graph *graph; int mb,as,mol; gmx_molblock_t *molb; if (bFirst && fplog) fprintf(fplog,"Removing pbc first time\n"); snew(graph,1); as = 0; for(mb=0; mb<mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; if (molb->natoms_mol == 1 || (!bFirst && mtop->moltype[molb->type].cgs.nr == 1)) { /* Just one atom or charge group in the molecule, no PBC required */ as += molb->nmol*molb->natoms_mol; } else { /* Pass NULL iso fplog to avoid graph prints for each molecule type */ mk_graph_ilist(NULL,mtop->moltype[molb->type].ilist, 0,molb->natoms_mol,FALSE,FALSE,graph); for(mol=0; mol<molb->nmol; mol++) { mk_mshift(fplog,graph,ePBC,box,x+as); shift_self(graph,box,x+as); /* The molecule is whole now. * We don't need the second mk_mshift call as in do_pbc_first, * since we no longer need this graph. */ as += molb->natoms_mol; } done_graph(graph); } } sfree(graph); }
void gen_sblocks(FILE *fp, int at_start, int at_end, t_idef *idef, t_blocka *sblock, gmx_bool bSettle) { t_graph *g; int i, i0, j, k, istart, n; t_sid *sid; int isid, nsid; g = mk_graph(NULL, idef, at_start, at_end, TRUE, bSettle); if (debug) { p_graph(debug, "Graaf Dracula", g); } snew(sid, at_end); for (i = at_start; (i < at_end); i++) { sid[i].atom = i; sid[i].sid = -1; } nsid = mk_sblocks(fp, g, at_end, sid); if (!nsid) { return; } /* Now sort the shake blocks... */ qsort(sid+at_start, at_end-at_start, (size_t)sizeof(sid[0]), sid_comp); if (debug) { fprintf(debug, "Sorted shake block\n"); for (i = at_start; (i < at_end); i++) { fprintf(debug, "sid[%5d] = atom:%5d sid:%5d\n", i, sid[i].atom, sid[i].sid); } } /* Now check how many are NOT -1, i.e. how many have to be shaken */ for (i0 = at_start; (i0 < at_end); i0++) { if (sid[i0].sid > -1) { break; } } /* Now we have the sids that have to be shaken. We'll check the min and * max atom numbers and this determines the shake block. DvdS 2007-07-19. * For the purpose of making boundaries all atoms in between need to be * part of the shake block too. There may be cases where blocks overlap * and they will have to be merged. */ nsid = merge_sid(at_start, at_end, nsid, sid, sblock); /* Now sort the shake blocks again... */ /*qsort(sid,natoms,(size_t)sizeof(sid[0]),sid_comp);*/ /* Fill the sblock struct */ /* sblock->nr = nsid; sblock->nra = natoms; srenew(sblock->a,sblock->nra); srenew(sblock->index,sblock->nr+1); i = i0; isid = sid[i].sid; n = k = 0; sblock->index[n++]=k; while (i < natoms) { istart = sid[i].atom; while ((i<natoms-1) && (sid[i+1].sid == isid)) i++;*/ /* After while: we found a new block, or are thru with the atoms */ /* for(j=istart; (j<=sid[i].atom); j++,k++) sblock->a[k]=j; sblock->index[n] = k; if (i < natoms-1) n++; if (n > nsid) gmx_fatal(FARGS,"Death Horror: nsid = %d, n= %d",nsid,n); i++; isid = sid[i].sid; } */ sfree(sid); /* Due to unknown reason this free generates a problem sometimes */ done_graph(g); sfree(g); if (debug) { fprintf(debug, "Done gen_sblocks\n"); } }