Changes the localtop topology structure to C++.
Cases where the object could be allocated on the stack have
been changed in that way. In other places, unique_ptr is now
used for the allocation.
Changed callers that returned a pointer to a new gmx_localtop_t
to instead take a pointer to the datastructure that will be
populated.
gmx_localtop_t is by default managing its own memory, but can be changed
to not do this. This is needed for the domain decomposition as it is not
expected to free memory owned by mtop there.
This is part of the larger aim of modernizing the topology
datastructures to C++.
Changed const pointers to const references where encountered during the
change.
Change-Id: I619533f5dc332332f1652afb24266bc2dae67d4c
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2005 - 2014, The GROMACS development team.
+ * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void dd_make_local_cgs(struct gmx_domdec_t *dd, t_block *lcgs);
/*! \brief Generate the local topology and virtual site data */
-void dd_make_local_top(struct gmx_domdec_t *dd, struct gmx_domdec_zones_t *zones,
- int npbcdim, matrix box,
- rvec cellsize_min, const ivec npulse,
- t_forcerec *fr,
- rvec *cgcm_or_x,
- gmx_vsite_t *vsite,
- const gmx_mtop_t *top, gmx_localtop_t *ltop);
+void dd_make_local_top(struct gmx_domdec_t *dd,
+ struct gmx_domdec_zones_t *zones,
+ int npbcdim,
+ matrix box,
+ rvec cellsize_min,
+ const ivec npulse,
+ t_forcerec *fr,
+ rvec *cgcm_or_x,
+ gmx_vsite_t *vsite,
+ const gmx_mtop_t &top,
+ gmx_localtop_t *ltop);
/*! \brief Sort ltop->ilist when we are doing free energy. */
void dd_sort_local_top(gmx_domdec_t *dd, const t_mdatoms *mdatoms,
gmx_localtop_t *ltop);
-/*! \brief Construct local topology */
-gmx_localtop_t *dd_init_local_top(const gmx_mtop_t *top_global);
+/*! \brief Initialize local topology
+ *
+ * \param[in] top_global Reference to global topology.
+ * \param[in,out] top Pointer to new local topology
+ */
+void dd_init_local_top(const gmx_mtop_t &top_global,
+ gmx_localtop_t *top);
/*! \brief Construct local state */
void dd_init_local_state(struct gmx_domdec_t *dd,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2006 - 2014, The GROMACS development team.
+ * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
t_forcerec *fr,
rvec *cgcm_or_x,
gmx_vsite_t *vsite,
- const gmx_mtop_t *mtop, gmx_localtop_t *ltop)
+ const gmx_mtop_t &mtop, gmx_localtop_t *ltop)
{
gmx_bool bRCheckMB, bRCheck2B;
real rc = -1;
}
dd->nbonded_local =
- make_local_bondeds_excls(dd, zones, mtop, fr->cginfo,
+ make_local_bondeds_excls(dd, zones, &mtop, fr->cginfo,
bRCheckMB, rcheck, bRCheck2B, rc,
dd->localAtomGroupFromAtom.data(),
pbc_null, cgcm_or_x,
dd->nbonded_local += nexcl;
}
- ltop->atomtypes = mtop->atomtypes;
+ ltop->atomtypes = mtop.atomtypes;
}
void dd_sort_local_top(gmx_domdec_t *dd, const t_mdatoms *mdatoms,
}
}
-gmx_localtop_t *dd_init_local_top(const gmx_mtop_t *top_global)
+void dd_init_local_top(const gmx_mtop_t &top_global,
+ gmx_localtop_t *top)
{
- gmx_localtop_t *top;
-
- snew(top, 1);
-
/* TODO: Get rid of the const casts below, e.g. by using a reference */
- top->idef.ntypes = top_global->ffparams.numTypes();
- top->idef.atnr = top_global->ffparams.atnr;
- top->idef.functype = const_cast<t_functype *>(top_global->ffparams.functype.data());
- top->idef.iparams = const_cast<t_iparams *>(top_global->ffparams.iparams.data());
- top->idef.fudgeQQ = top_global->ffparams.fudgeQQ;
+ top->idef.ntypes = top_global.ffparams.numTypes();
+ top->idef.atnr = top_global.ffparams.atnr;
+ top->idef.functype = const_cast<t_functype *>(top_global.ffparams.functype.data());
+ top->idef.iparams = const_cast<t_iparams *>(top_global.ffparams.iparams.data());
+ top->idef.fudgeQQ = top_global.ffparams.fudgeQQ;
top->idef.cmap_grid = new gmx_cmap_t;
- *top->idef.cmap_grid = top_global->ffparams.cmap_grid;
-
- top->idef.ilsort = ilsortUNKNOWN;
+ *top->idef.cmap_grid = top_global.ffparams.cmap_grid;
- return top;
+ top->idef.ilsort = ilsortUNKNOWN;
+ top->useInDomainDecomp_ = true;
}
void dd_init_local_state(gmx_domdec_t *dd,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
gmx_bool bMasterState,
int nstglobalcomm,
t_state *state_global,
- const gmx_mtop_t *top_global,
+ const gmx_mtop_t &top_global,
const t_inputrec *ir,
t_state *state_local,
PaddedVector<gmx::RVec> *f,
true, xGlobal,
&ddbox);
- distributeState(mdlog, dd, *top_global, state_global, ddbox, state_local, f);
+ distributeState(mdlog, dd, top_global, state_global, ddbox, state_local, f);
dd_make_local_cgs(dd, &top_local->cgs);
if (dd->splitConstraints || dd->splitSettles)
{
/* Only for inter-cg constraints we need special code */
- n = dd_make_local_constraints(dd, n, top_global, fr->cginfo,
+ n = dd_make_local_constraints(dd, n, &top_global, fr->cginfo,
constr, ir->nProjOrder,
top_local->idef.il);
}
if (comm->nstDDDump > 0 && step % comm->nstDDDump == 0)
{
dd_move_x(dd, state_local->box, state_local->x, nullWallcycle);
- write_dd_pdb("dd_dump", step, "dump", top_global, cr,
+ write_dd_pdb("dd_dump", step, "dump", &top_global, cr,
-1, state_local->x.rvec_array(), state_local->box);
}
if (comm->DD_debug > 0)
{
/* Set the env var GMX_DD_DEBUG if you suspect corrupted indices */
- check_index_consistency(dd, top_global->natoms, ncg_mtop(top_global),
+ check_index_consistency(dd, top_global.natoms, ncg_mtop(&top_global),
"after partitioning");
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
gmx_bool bMasterState,
int nstglobalcomm,
t_state *state_global,
- const gmx_mtop_t *top_global,
+ const gmx_mtop_t &top_global,
const t_inputrec *ir,
t_state *state_local,
PaddedVector<gmx::RVec> *f,
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/topology/index.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
+#include "gromacs/trajectoryanalysis/topologyinformation.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
};
FILE *out = nullptr, *aver = nullptr, *numv = nullptr, *maxxv = nullptr, *xvg = nullptr;
- t_tpxheader header;
- gmx_mtop_t mtop;
- rvec *xtop;
- gmx_localtop_t *top;
- t_atoms *atoms = nullptr;
+ gmx_localtop_t top;
t_fcdata fcd;
t_nrnb nrnb;
t_graph *g;
- int ntopatoms, natoms, i, j, kkk;
+ int i, j, kkk;
t_trxstatus *status;
real t;
rvec *x, *xav = nullptr;
t_inputrec irInstance;
t_inputrec *ir = &irInstance;
- read_tpxheader(ftp2fn(efTPR, NFILE, fnm), &header, FALSE);
- snew(xtop, header.natoms);
- read_tpx(ftp2fn(efTPR, NFILE, fnm), ir, box, &ntopatoms, xtop, nullptr, &mtop);
+ gmx::TopologyInformation topInfo;
+ topInfo.fillFromInputFile(ftp2fn(efTPR, NFILE, fnm));
+ int ntopatoms = topInfo.mtop()->natoms;
+ AtomsDataPtr atoms;
bPDB = opt2bSet("-q", NFILE, fnm);
if (bPDB)
{
ind_fit[kkk] = kkk;
}
- snew(atoms, 1);
- *atoms = gmx_mtop_global_atoms(&mtop);
+ atoms = topInfo.copyAtoms();
if (atoms->pdbinfo == nullptr)
{
atoms->havePdbInfo = TRUE;
}
- top = gmx_mtop_generate_local_top(&mtop, ir->efep != efepNO);
+ gmx_mtop_generate_local_top(*topInfo.mtop(), &top, ir->efep != efepNO);
g = nullptr;
pbc_null = nullptr;
}
else
{
- g = mk_graph(fplog, &top->idef, 0, mtop.natoms, FALSE, FALSE);
+ g = mk_graph(fplog, &top.idef, 0, ntopatoms, FALSE, FALSE);
}
}
}
ir->dr_tau = 0.0;
- init_disres(fplog, &mtop, ir, nullptr, nullptr, &fcd, nullptr, FALSE);
+ init_disres(fplog, topInfo.mtop(), ir, nullptr, nullptr, &fcd, nullptr, FALSE);
- natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
+ int natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
snew(f, 5*natoms);
init_dr_res(&dr, fcd.disres.nres);
"Largest Violation", "Time (ps)", "nm", oenv);
}
- auto mdAtoms = gmx::makeMDAtoms(fplog, mtop, *ir, false);
- atoms2md(&mtop, ir, -1, nullptr, mtop.natoms, mdAtoms.get());
+ auto mdAtoms = gmx::makeMDAtoms(fplog, *topInfo.mtop(), *ir, false);
+ atoms2md(topInfo.mtop(), ir, -1, nullptr, ntopatoms, mdAtoms.get());
update_mdatoms(mdAtoms->mdatoms(), ir->fepvals->init_lambda);
init_nrnb(&nrnb);
if (ir->ePBC != epbcNONE)
{
- gpbc = gmx_rmpbc_init(&top->idef, ir->ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top.idef, ir->ePBC, natoms);
}
j = 0;
}
my_clust = clust->inv_clust[j];
range_check(my_clust, 0, clust->clust->nr);
- check_viol(fplog, &(top->idef.il[F_DISRES]),
- top->idef.iparams,
+ check_viol(fplog, &(top.idef.il[F_DISRES]),
+ top.idef.iparams,
x, f, pbc_null, g, dr_clust, my_clust, isize, index, vvindex, &fcd);
}
else
{
- check_viol(fplog, &(top->idef.il[F_DISRES]),
- top->idef.iparams,
+ check_viol(fplog, &(top.idef.il[F_DISRES]),
+ top.idef.iparams,
x, f, pbc_null, g, &dr, 0, isize, index, vvindex, &fcd);
}
if (bPDB)
if (clust)
{
- dump_clust_stats(fplog, fcd.disres.nres, &(top->idef.il[F_DISRES]),
- top->idef.iparams, clust->clust, dr_clust,
+ dump_clust_stats(fplog, fcd.disres.nres, &(top.idef.il[F_DISRES]),
+ top.idef.iparams, clust->clust, dr_clust,
clust->grpname, isize, index);
}
else
{
- dump_stats(fplog, j, fcd.disres.nres, &(top->idef.il[F_DISRES]),
- top->idef.iparams, &dr, isize, index,
- bPDB ? atoms : nullptr);
+ dump_stats(fplog, j, fcd.disres.nres, &(top.idef.il[F_DISRES]),
+ top.idef.iparams, &dr, isize, index,
+ bPDB ? atoms.get() : nullptr);
if (bPDB)
{
write_sto_conf(opt2fn("-q", NFILE, fnm),
"Coloured by average violation in Angstrom",
- atoms, xav, nullptr, ir->ePBC, box);
+ atoms.get(), xav, nullptr, ir->ePBC, box);
}
dump_disre_matrix(opt2fn_null("-x", NFILE, fnm), &dr, fcd.disres.nres,
- j, &top->idef, &mtop, max_dr, nlevels, bThird);
+ j, &top.idef, topInfo.mtop(), max_dr, nlevels, bThird);
xvgrclose(out);
xvgrclose(aver);
xvgrclose(numv);
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/topology/mtop_lookup.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
+#include "gromacs/trajectoryanalysis/topologyinformation.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
done_top_mtop(&top, &mtop);
}
-static int get_bounds(const char *topnm,
- real **bounds, int **index, int **dr_pair, int *npairs,
- gmx_mtop_t *mtop, gmx_localtop_t **ltop, t_inputrec *ir)
+static int get_bounds(real **bounds, int **index, int **dr_pair, int *npairs,
+ gmx_localtop_t *top)
{
- gmx_localtop_t *top;
t_functype *functype;
t_iparams *ip;
- int natoms, i, j, k, type, ftype, natom;
+ int i, j, k, type, ftype, natom;
t_ilist *disres;
t_iatom *iatom;
real *b;
int *ind, *pair;
int nb, label1;
- matrix box;
-
- read_tpx(topnm, ir, box, &natoms, nullptr, nullptr, mtop);
- snew(*ltop, 1);
- top = gmx_mtop_generate_local_top(mtop, ir->efep != efepNO);
- *ltop = top;
functype = top->idef.functype;
ip = top->idef.iparams;
};
FILE /* *out = NULL,*/ *out_disre = nullptr, *fp_pairs = nullptr, *fort = nullptr, *fodt = nullptr, *foten = nullptr;
- ener_file_t fp;
- int timecheck = 0;
- gmx_mtop_t mtop;
- gmx_localtop_t *top = nullptr;
- gmx_enxnm_t *enm = nullptr;
- t_enxframe fr;
- int nre, teller, teller_disre;
- int nor = 0, nex = 0, norfr = 0, enx_i = 0;
- real *bounds = nullptr, *violaver = nullptr, *oobs = nullptr, *orient = nullptr, *odrms = nullptr;
- int *index = nullptr, *pair = nullptr, norsel = 0, *orsel = nullptr, *or_label = nullptr;
- int nbounds = 0, npairs;
- gmx_bool bDisRe, bDRAll, bORA, bORT, bODA, bODR, bODT, bORIRE, bOTEN;
- gmx_bool bCont;
- double sumaver, sumt;
- int *set = nullptr, i, j, k, nset, sss;
- char **pairleg, **odtleg, **otenleg;
- char **leg = nullptr;
- const char *anm_j, *anm_k, *resnm_j, *resnm_k;
- int resnr_j, resnr_k;
- const char *orinst_sub = "@ subtitle \"instantaneous\"\n";
- char buf[256];
- gmx_output_env_t *oenv;
- t_enxblock *blk_disre = nullptr;
- int ndisre = 0;
-
- t_filenm fnm[] = {
+ ener_file_t fp;
+ int timecheck = 0;
+ gmx_localtop_t top;
+ gmx_enxnm_t *enm = nullptr;
+ t_enxframe fr;
+ int nre, teller, teller_disre;
+ int nor = 0, nex = 0, norfr = 0, enx_i = 0;
+ real *bounds = nullptr, *violaver = nullptr, *oobs = nullptr, *orient = nullptr, *odrms = nullptr;
+ int *index = nullptr, *pair = nullptr, norsel = 0, *orsel = nullptr, *or_label = nullptr;
+ int nbounds = 0, npairs;
+ gmx_bool bDisRe, bDRAll, bORA, bORT, bODA, bODR, bODT, bORIRE, bOTEN;
+ gmx_bool bCont;
+ double sumaver, sumt;
+ int *set = nullptr, i, j, k, nset, sss;
+ char **pairleg, **odtleg, **otenleg;
+ char **leg = nullptr;
+ const char *anm_j, *anm_k, *resnm_j, *resnm_k;
+ int resnr_j, resnr_k;
+ const char *orinst_sub = "@ subtitle \"instantaneous\"\n";
+ char buf[256];
+ gmx_output_env_t *oenv;
+ t_enxblock *blk_disre = nullptr;
+ int ndisre = 0;
+
+ t_filenm fnm[] = {
{ efEDR, "-f", nullptr, ffREAD },
{ efEDR, "-f2", nullptr, ffOPTRD },
{ efTPR, "-s", nullptr, ffOPTRD },
{ efXVG, "-oten", "oriten", ffOPTWR }
};
#define NFILE asize(fnm)
- int npargs;
+ int npargs;
npargs = asize(pa);
if (!parse_common_args(&argc, argv,
t_inputrec irInstance;
t_inputrec *ir = &irInstance;
init_enxframe(&fr);
-
+ gmx::TopologyInformation topInfo;
if (!bDisRe)
{
if (bORIRE || bOTEN)
}
else
{
- nbounds = get_bounds(ftp2fn(efTPR, NFILE, fnm), &bounds, &index, &pair, &npairs,
- &mtop, &top, ir);
+ {
+ topInfo.fillFromInputFile(ftp2fn(efTPR, NFILE, fnm));
+ gmx_mtop_generate_local_top(*topInfo.mtop(), &top, ir->efep != efepNO);
+ }
+ nbounds = get_bounds(&bounds, &index, &pair, &npairs,
+ &top);
snew(violaver, npairs);
out_disre = xvgropen(opt2fn("-o", NFILE, fnm), "Sum of Violations",
"Time (ps)", "nm", oenv);
t_iatom *fa;
t_iparams *ip;
- fa = top->idef.il[F_DISRES].iatoms;
- ip = top->idef.iparams;
+ fa = top.idef.il[F_DISRES].iatoms;
+ ip = top.idef.iparams;
if (blk_disre->nsub != 2 ||
(blk_disre->sub[0].nr != blk_disre->sub[1].nr) )
{
}
ndisre = blk_disre->sub[0].nr;
- if (ndisre != top->idef.il[F_DISRES].nr/3)
+ if (ndisre != top.idef.il[F_DISRES].nr/3)
{
gmx_fatal(FARGS, "Number of disre pairs in the energy file (%d) does not match the number in the run input file (%d)\n",
- ndisre, top->idef.il[F_DISRES].nr/3);
+ ndisre, top.idef.il[F_DISRES].nr/3);
}
snew(pairleg, ndisre);
int molb = 0;
snew(pairleg[i], 30);
j = fa[3*i+1];
k = fa[3*i+2];
- mtopGetAtomAndResidueName(&mtop, j, &molb, &anm_j, &resnr_j, &resnm_j, nullptr);
- mtopGetAtomAndResidueName(&mtop, k, &molb, &anm_k, &resnr_k, &resnm_k, nullptr);
+ mtopGetAtomAndResidueName(topInfo.mtop(), j, &molb, &anm_j, &resnr_j, &resnm_j, nullptr);
+ mtopGetAtomAndResidueName(topInfo.mtop(), k, &molb, &anm_k, &resnr_k, &resnm_k, nullptr);
sprintf(pairleg[i], "%d %s %d %s (%d)",
resnr_j, anm_j, resnr_k, anm_k,
ip[fa[3*i]].disres.label);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* The final solution should be an MD algorithm base class with methods
* for initialization and atom-data setup.
*/
-
-void mdAlgorithmsSetupAtomData(const t_commrec *cr,
- const t_inputrec *ir,
- const gmx_mtop_t *top_global,
- gmx_localtop_t *top,
- t_forcerec *fr,
- t_graph **graph,
- gmx::MDAtoms *mdAtoms,
- gmx::Constraints *constr,
- gmx_vsite_t *vsite,
- gmx_shellfc_t *shellfc)
+void mdAlgorithmsSetupAtomData(const t_commrec *cr,
+ const t_inputrec *ir,
+ const gmx_mtop_t &top_global,
+ gmx_localtop_t *top,
+ t_forcerec *fr,
+ t_graph **graph,
+ gmx::MDAtoms *mdAtoms,
+ gmx::Constraints *constr,
+ gmx_vsite_t *vsite,
+ gmx_shellfc_t *shellfc)
{
bool usingDomDec = DOMAINDECOMP(cr);
{
numAtomIndex = -1;
atomIndex = nullptr;
- numHomeAtoms = top_global->natoms;
+ numHomeAtoms = top_global.natoms;
}
- atoms2md(top_global, ir, numAtomIndex, atomIndex, numHomeAtoms, mdAtoms);
+ atoms2md(&top_global, ir, numAtomIndex, atomIndex, numHomeAtoms, mdAtoms);
auto mdatoms = mdAtoms->mdatoms();
if (usingDomDec)
}
else
{
- /* Currently gmx_generate_local_top allocates and returns a pointer.
- * We should implement a more elegant solution.
- */
- gmx_localtop_t *tmpTop;
-
- tmpTop = gmx_mtop_generate_local_top(top_global, ir->efep != efepNO);
- *top = *tmpTop;
- sfree(tmpTop);
+ gmx_mtop_generate_local_top(top_global, top, ir->efep != efepNO);
}
if (vsite)
{
GMX_ASSERT(graph != nullptr, "We use a graph with PBC (no periodic mols) and without DD");
- *graph = mk_graph(nullptr, &(top->idef), 0, top_global->natoms, FALSE, FALSE);
+ *graph = mk_graph(nullptr, &(top->idef), 0, top_global.natoms, FALSE, FALSE);
}
else if (graph != nullptr)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[in,out] vsite The virtual site data, can be NULL
* \param[in,out] shellfc The shell/flexible-constraint data, can be NULL
*/
-void mdAlgorithmsSetupAtomData(const t_commrec *cr,
- const t_inputrec *ir,
- const gmx_mtop_t *top_global,
- gmx_localtop_t *top,
- t_forcerec *fr,
- t_graph **graph,
- gmx::MDAtoms *mdAtoms,
- gmx::Constraints *constr,
- gmx_vsite_t *vsite,
- gmx_shellfc_t *shellfc);
+void mdAlgorithmsSetupAtomData(const t_commrec *cr,
+ const t_inputrec *ir,
+ const gmx_mtop_t &top_global,
+ gmx_localtop_t *top,
+ t_forcerec *fr,
+ t_graph **graph,
+ gmx::MDAtoms *mdAtoms,
+ gmx::Constraints *constr,
+ gmx_vsite_t *vsite,
+ gmx_shellfc_t *shellfc);
#endif
t_vcm *vcm;
matrix parrinellorahmanMu, M;
gmx_repl_ex_t repl_ex = nullptr;
- gmx_localtop_t *top;
+ gmx_localtop_t top;
t_mdebin *mdebin = nullptr;
gmx_enerdata_t *enerd;
PaddedVector<gmx::RVec> f {};
if (DOMAINDECOMP(cr))
{
- top = dd_init_local_top(top_global);
+ dd_init_local_top(*top_global, &top);
stateInstance = compat::make_unique<t_state>();
state = stateInstance.get();
/* Distribute the charge groups over the nodes from the master node */
dd_partition_system(fplog, mdlog, ir->init_step, cr, TRUE, 1,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, nullptr, FALSE);
shouldCheckNumberOfBondedInteractions = true;
/* Copy the pointer to the global state */
state = state_global;
- snew(top, 1);
- mdAlgorithmsSetupAtomData(cr, ir, top_global, top, fr,
+ /* Generate and initialize new topology */
+ mdAlgorithmsSetupAtomData(cr, ir, *top_global, &top, fr,
&graph, mdAtoms, constr, vsite, shellfc);
update_realloc(upd, state->natoms);
{
/* Construct the virtual sites for the initial configuration */
construct_vsites(vsite, state->x.rvec_array(), ir->delta_t, nullptr,
- top->idef.iparams, top->idef.il,
+ top.idef.iparams, top.idef.il,
fr->ePBC, fr->bMolPBC, cr, state->box);
}
}
| (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0));
}
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
if (ir->eI == eiVVAK)
{
/* Repartition the domain decomposition */
dd_partition_system(fplog, mdlog, step, cr,
bMasterState, nstglobalcomm,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, wcycle,
do_verbose && !bPMETunePrinting);
&totalNumberOfBondedInteractions, &bSumEkinhOld,
CGLO_GSTAT | CGLO_TEMPERATURE | CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS);
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
}
clear_mat(force_vir);
/* Now is the time to relax the shells */
relax_shell_flexcon(fplog, cr, ms, mdrunOptions.verbose,
enforcedRotation, step,
- ir, bNS, force_flags, top,
+ ir, bNS, force_flags, &top,
constr, enerd, fcd,
state, f.arrayRefWithPadding(), force_vir, mdatoms,
nrnb, wcycle, graph, groups,
* Check comments in sim_util.c
*/
do_force(fplog, cr, ms, ir, awh.get(), enforcedRotation,
- step, nrnb, wcycle, top, groups,
+ step, nrnb, wcycle, &top, groups,
state->box, state->x.arrayRefWithPadding(), &state->hist,
f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
state->lambda, graph,
b) If we are using EkinAveEkin for the kinetic energy for the temperature control, we still feed in
EkinAveVel because it's needed for the pressure */
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
wallcycle_start(wcycle, ewcUPDATE);
}
shift_self(graph, state->box, state->x.rvec_array());
}
construct_vsites(vsite, state->x.rvec_array(), ir->delta_t, state->v.rvec_array(),
- top->idef.iparams, top->idef.il,
+ top.idef.iparams, top.idef.il,
fr->ePBC, fr->bMolPBC, cr, state->box);
if (graph != nullptr)
| (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0)
);
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
}
}
if ( (bExchanged || bNeedRepartition) && DOMAINDECOMP(cr) )
{
dd_partition_system(fplog, mdlog, step, cr, TRUE, 1,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, wcycle, FALSE);
shouldCheckNumberOfBondedInteractions = true;
destroy_enerdata(enerd);
sfree(enerd);
-
global_stat_destroy(gstat);
- /* Clean up topology. top->atomtypes has an allocated pointer if no domain decomposition*/
- if (!DOMAINDECOMP(cr))
- {
- done_localtop(top);
- }
- sfree(top);
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
int force_flags;
tensor force_vir, shake_vir, total_vir, pres;
rvec mu_tot;
- gmx_localtop_t *top;
+ gmx_localtop_t top;
t_mdebin *mdebin = nullptr;
gmx_enerdata_t *enerd;
PaddedVector<gmx::RVec> f {};
if (DOMAINDECOMP(cr))
{
- top = dd_init_local_top(top_global);
+ dd_init_local_top(*top_global, &top);
stateInstance = compat::make_unique<t_state>();
state = stateInstance.get();
/* Distribute the charge groups over the nodes from the master node */
dd_partition_system(fplog, mdlog, ir->init_step, cr, TRUE, 1,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, nullptr, FALSE);
shouldCheckNumberOfBondedInteractions = true;
/* Copy the pointer to the global state */
state = state_global;
- snew(top, 1);
- mdAlgorithmsSetupAtomData(cr, ir, top_global, top, fr,
+ mdAlgorithmsSetupAtomData(cr, ir, *top_global, &top, fr,
&graph, mdAtoms, constr, vsite, shellfc);
}
&totalNumberOfBondedInteractions, &bSumEkinhOld, cglo_flags);
}
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
if (MASTER(cr))
const bool bMasterState = true;
dd_partition_system(fplog, mdlog, step, cr,
bMasterState, nstglobalcomm,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, wcycle,
mdrunOptions.verbose);
/* Now is the time to relax the shells */
relax_shell_flexcon(fplog, cr, ms, mdrunOptions.verbose,
enforcedRotation, step,
- ir, bNS, force_flags, top,
+ ir, bNS, force_flags, &top,
constr, enerd, fcd,
state, f.arrayRefWithPadding(), force_vir, mdatoms,
nrnb, wcycle, graph, groups,
Awh *awh = nullptr;
gmx_edsam *ed = nullptr;
do_force(fplog, cr, ms, ir, awh, enforcedRotation,
- step, nrnb, wcycle, top, groups,
+ step, nrnb, wcycle, &top, groups,
state->box, state->x.arrayRefWithPadding(), &state->hist,
f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
state->lambda, graph,
shift_self(graph, state->box, as_rvec_array(state->x.data()));
}
construct_vsites(vsite, as_rvec_array(state->x.data()), ir->delta_t, as_rvec_array(state->v.data()),
- top->idef.iparams, top->idef.il,
+ top.idef.iparams, top.idef.il,
fr->ePBC, fr->bMolPBC, cr, state->box);
if (graph != nullptr)
| (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0)
);
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
}
destroy_enerdata(enerd);
sfree(enerd);
- sfree(top);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
t_inputrec *ir,
const MdrunOptions &mdrunOptions,
t_state *state_global, gmx_mtop_t *top_global,
- em_state_t *ems, gmx_localtop_t **top,
+ em_state_t *ems, gmx_localtop_t *top,
t_nrnb *nrnb, rvec mu_tot,
t_forcerec *fr, gmx_enerdata_t **enerd,
t_graph **graph, gmx::MDAtoms *mdAtoms, gmx_global_stat_t *gstat,
auto mdatoms = mdAtoms->mdatoms();
if (DOMAINDECOMP(cr))
{
- *top = dd_init_local_top(top_global);
+ top->useInDomainDecomp_ = true;
+ dd_init_local_top(*top_global, top);
dd_init_local_state(cr->dd, state_global, &ems->s);
/* Distribute the charge groups over the nodes from the master node */
dd_partition_system(fplog, mdlog, ir->init_step, cr, TRUE, 1,
- state_global, top_global, ir,
- &ems->s, &ems->f, mdAtoms, *top,
+ state_global, *top_global, ir,
+ &ems->s, &ems->f, mdAtoms, top,
fr, vsite, constr,
nrnb, nullptr, FALSE);
dd_store_state(cr->dd, &ems->s);
state_change_natoms(&ems->s, ems->s.natoms);
ems->f.resizeWithPadding(ems->s.natoms);
- snew(*top, 1);
- mdAlgorithmsSetupAtomData(cr, ir, top_global, *top, fr,
+ mdAlgorithmsSetupAtomData(cr, ir, *top_global, top, fr,
graph, mdAtoms,
constr, vsite, shellfc ? *shellfc : nullptr);
if (vsite)
{
- set_vsite_top(vsite, *top, mdatoms);
+ set_vsite_top(vsite, top, mdatoms);
}
}
{
/* Repartition the domain decomposition */
dd_partition_system(fplog, mdlog, step, cr, FALSE, 1,
- nullptr, top_global, ir,
+ nullptr, *top_global, ir,
&ems->s, &ems->f,
mdAtoms, top, fr, vsite, constr,
nrnb, wcycle, FALSE);
void
Integrator::do_cg()
{
- const char *CG = "Polak-Ribiere Conjugate Gradients";
+ const char *CG = "Polak-Ribiere Conjugate Gradients";
- gmx_localtop_t *top;
- gmx_enerdata_t *enerd;
- gmx_global_stat_t gstat;
- t_graph *graph;
- double tmp, minstep;
- real stepsize;
- real a, b, c, beta = 0.0;
- real epot_repl = 0;
- real pnorm;
- t_mdebin *mdebin;
- gmx_bool converged, foundlower;
- rvec mu_tot;
- gmx_bool do_log = FALSE, do_ene = FALSE, do_x, do_f;
- tensor vir, pres;
- int number_steps, neval = 0, nstcg = inputrec->nstcgsteep;
- gmx_mdoutf_t outf;
- int m, step, nminstep;
- auto mdatoms = mdAtoms->mdatoms();
+ gmx_localtop_t top;
+ gmx_enerdata_t *enerd;
+ gmx_global_stat_t gstat;
+ t_graph *graph;
+ double tmp, minstep;
+ real stepsize;
+ real a, b, c, beta = 0.0;
+ real epot_repl = 0;
+ real pnorm;
+ t_mdebin *mdebin;
+ gmx_bool converged, foundlower;
+ rvec mu_tot;
+ gmx_bool do_log = FALSE, do_ene = FALSE, do_x, do_f;
+ tensor vir, pres;
+ int number_steps, neval = 0, nstcg = inputrec->nstcgsteep;
+ gmx_mdoutf_t outf;
+ int m, step, nminstep;
+ auto mdatoms = mdAtoms->mdatoms();
GMX_LOG(mdlog.info).asParagraph().
appendText("Note that activating conjugate gradient energy minimization via the "
EnergyEvaluator energyEvaluator {
fplog, mdlog, cr, ms,
- top_global, top,
+ top_global, &top,
inputrec, nrnb, wcycle, gstat,
vsite, constr, fcd, graph,
mdAtoms, fr, ppForceWorkload, enerd
if (DOMAINDECOMP(cr) && s_min->s.ddp_count < cr->dd->ddp_count)
{
em_dd_partition_system(fplog, mdlog, step, cr, top_global, inputrec,
- s_min, top, mdAtoms, fr, vsite, constr,
+ s_min, &top, mdAtoms, fr, vsite, constr,
nrnb, wcycle);
}
{
/* Reload the old state */
em_dd_partition_system(fplog, mdlog, -1, cr, top_global, inputrec,
- s_min, top, mdAtoms, fr, vsite, constr,
+ s_min, &top, mdAtoms, fr, vsite, constr,
nrnb, wcycle);
}
{
static const char *LBFGS = "Low-Memory BFGS Minimizer";
em_state_t ems;
- gmx_localtop_t *top;
+ gmx_localtop_t top;
gmx_enerdata_t *enerd;
gmx_global_stat_t gstat;
t_graph *graph;
if (vsite)
{
construct_vsites(vsite, state_global->x.rvec_array(), 1, nullptr,
- top->idef.iparams, top->idef.il,
+ top.idef.iparams, top.idef.il,
fr->ePBC, fr->bMolPBC, cr, state_global->box);
}
neval++;
EnergyEvaluator energyEvaluator {
fplog, mdlog, cr, ms,
- top_global, top,
+ top_global, &top,
inputrec, nrnb, wcycle, gstat,
vsite, constr, fcd, graph,
mdAtoms, fr, ppForceWorkload, enerd
void
Integrator::do_steep()
{
- const char *SD = "Steepest Descents";
- gmx_localtop_t *top;
+ const char *SD = "Steepest Descents";
+ gmx_localtop_t top;
gmx_enerdata_t *enerd;
gmx_global_stat_t gstat;
t_graph *graph;
}
EnergyEvaluator energyEvaluator {
fplog, mdlog, cr, ms,
- top_global, top,
+ top_global, &top,
inputrec, nrnb, wcycle, gstat,
vsite, constr, fcd, graph,
mdAtoms, fr, ppForceWorkload, enerd
{
/* Reload the old state */
em_dd_partition_system(fplog, mdlog, count, cr, top_global, inputrec,
- s_min, top, mdAtoms, fr, vsite, constr,
+ s_min, &top, mdAtoms, fr, vsite, constr,
nrnb, wcycle);
}
}
const char *NM = "Normal Mode Analysis";
gmx_mdoutf_t outf;
int nnodes, node;
- gmx_localtop_t *top;
+ gmx_localtop_t top;
gmx_enerdata_t *enerd;
gmx_global_stat_t gstat;
t_graph *graph;
cr->nnodes = 1;
EnergyEvaluator energyEvaluator {
fplog, mdlog, cr, ms,
- top_global, top,
+ top_global, &top,
inputrec, nrnb, wcycle, gstat,
vsite, constr, fcd, graph,
mdAtoms, fr, ppForceWorkload, enerd
inputrec,
bNS,
force_flags,
- top,
+ &top,
constr,
enerd,
fcd,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
t_trxstatus *status;
rvec mu_tot;
t_trxframe rerun_fr;
- gmx_localtop_t *top;
+ gmx_localtop_t top;
t_mdebin *mdebin = nullptr;
gmx_enerdata_t *enerd;
PaddedVector<gmx::RVec> f {};
if (DOMAINDECOMP(cr))
{
- top = dd_init_local_top(top_global);
+ dd_init_local_top(*top_global, &top);
stateInstance = compat::make_unique<t_state>();
state = stateInstance.get();
/* Distribute the charge groups over the nodes from the master node */
dd_partition_system(fplog, mdlog, ir->init_step, cr, TRUE, 1,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, nullptr, FALSE);
shouldCheckNumberOfBondedInteractions = true;
/* Copy the pointer to the global state */
state = state_global;
- snew(top, 1);
- mdAlgorithmsSetupAtomData(cr, ir, top_global, top, fr,
+ mdAlgorithmsSetupAtomData(cr, ir, *top_global, &top, fr,
&graph, mdAtoms, constr, vsite, shellfc);
}
&totalNumberOfBondedInteractions, &bSumEkinhOld, cglo_flags);
}
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
if (MASTER(cr))
gmx_fatal(FARGS, "Vsite recalculation with -rerun is not implemented with domain decomposition, "
"use a single rank");
}
- prepareRerunState(rerun_fr, state_global, constructVsites, vsite, top->idef, ir->delta_t, *fr, graph);
+ prepareRerunState(rerun_fr, state_global, constructVsites, vsite, top.idef, ir->delta_t, *fr, graph);
}
isLastStep = isLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
const bool bMasterState = true;
dd_partition_system(fplog, mdlog, step, cr,
bMasterState, nstglobalcomm,
- state_global, top_global, ir,
- state, &f, mdAtoms, top, fr,
+ state_global, *top_global, ir,
+ state, &f, mdAtoms, &top, fr,
vsite, constr,
nrnb, wcycle,
mdrunOptions.verbose);
/* Now is the time to relax the shells */
relax_shell_flexcon(fplog, cr, ms, mdrunOptions.verbose,
enforcedRotation, step,
- ir, bNS, force_flags, top,
+ ir, bNS, force_flags, &top,
constr, enerd, fcd,
state, f.arrayRefWithPadding(), force_vir, mdatoms,
nrnb, wcycle, graph, groups,
Awh *awh = nullptr;
gmx_edsam *ed = nullptr;
do_force(fplog, cr, ms, ir, awh, enforcedRotation,
- step, nrnb, wcycle, top, groups,
+ step, nrnb, wcycle, &top, groups,
state->box, state->x.arrayRefWithPadding(), &state->hist,
f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
state->lambda, graph,
shift_self(graph, state->box, as_rvec_array(state->x.data()));
}
construct_vsites(vsite, as_rvec_array(state->x.data()), ir->delta_t, as_rvec_array(state->v.data()),
- top->idef.iparams, top->idef.il,
+ top.idef.iparams, top.idef.il,
fr->ePBC, fr->bMolPBC, cr, state->box);
if (graph != nullptr)
| (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0)
);
checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions,
- top_global, top, state,
+ top_global, &top, state,
&shouldCheckNumberOfBondedInteractions);
}
destroy_enerdata(enerd);
sfree(enerd);
- sfree(top);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void
Integrator::do_tpi()
{
- gmx_localtop_t *top;
+ gmx_localtop_t top;
gmx_groups_t *groups;
gmx_enerdata_t *enerd;
PaddedVector<gmx::RVec> f {};
nnodes = cr->nnodes;
- top = gmx_mtop_generate_local_top(top_global, inputrec->efep != efepNO);
+ gmx_mtop_generate_local_top(*top_global, &top, inputrec->efep != efepNO);
groups = &top_global->groups;
print_start(fplog, cr, walltime_accounting, "Test Particle Insertion");
/* The last charge group is the group to be inserted */
- cg_tp = top->cgs.nr - 1;
- a_tp0 = top->cgs.index[cg_tp];
- a_tp1 = top->cgs.index[cg_tp+1];
+ cg_tp = top.cgs.nr - 1;
+ a_tp0 = top.cgs.index[cg_tp];
+ a_tp1 = top.cgs.index[cg_tp+1];
if (debug)
{
fprintf(debug, "TPI cg %d, atoms %d-%d\n", cg_tp, a_tp0, a_tp1);
}
bRFExcl = (bCharge && EEL_RF(fr->ic->eeltype));
- calc_cgcm(fplog, cg_tp, cg_tp+1, &(top->cgs), state_global->x.rvec_array(), fr->cg_cm);
+ calc_cgcm(fplog, cg_tp, cg_tp+1, &(top.cgs), state_global->x.rvec_array(), fr->cg_cm);
if (bCavity)
{
if (norm(fr->cg_cm[cg_tp]) > 0.5*inputrec->rlist && fplog)
clear_mat(pres);
/* Set the charge group center of mass of the test particle */
- copy_rvec(x_init, fr->cg_cm[top->cgs.nr-1]);
+ copy_rvec(x_init, fr->cg_cm[top.cgs.nr-1]);
/* Calc energy (no forces) on new positions.
* Since we only need the intermolecular energy
std::fenv_t floatingPointEnvironment;
std::feholdexcept(&floatingPointEnvironment);
do_force(fplog, cr, ms, inputrec, nullptr, nullptr,
- step, nrnb, wcycle, top, &top_global->groups,
+ step, nrnb, wcycle, &top, &top_global->groups,
state_global->box, state_global->x.arrayRefWithPadding(), &state_global->hist,
f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
state_global->lambda,
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
static void chk_trj(const gmx_output_env_t *oenv, const char *fn, const char *tpr, real tol)
{
- t_trxframe fr;
- t_count count;
- t_fr_time first, last;
- int j = -1, new_natoms, natoms;
- real old_t1, old_t2;
- gmx_bool bShowTimestep = TRUE, newline = FALSE;
- t_trxstatus *status;
- gmx_mtop_t mtop;
- gmx_localtop_t *top = nullptr;
- t_state state;
- t_inputrec ir;
+ t_trxframe fr;
+ t_count count;
+ t_fr_time first, last;
+ int j = -1, new_natoms, natoms;
+ real old_t1, old_t2;
+ gmx_bool bShowTimestep = TRUE, newline = FALSE;
+ t_trxstatus *status;
+ gmx_mtop_t mtop;
+ gmx_localtop_t top;
+ t_state state;
+ t_inputrec ir;
if (tpr)
{
read_tpx_state(tpr, &ir, &state, &mtop);
- top = gmx_mtop_generate_local_top(&mtop, ir.efep != efepNO);
+ gmx_mtop_generate_local_top(mtop, &top, ir.efep != efepNO);
}
new_natoms = -1;
natoms = -1;
natoms = new_natoms;
if (tpr)
{
- chk_bonds(&top->idef, ir.ePBC, fr.x, fr.box, tol);
+ chk_bonds(&top.idef, ir.ePBC, fr.x, fr.box, tol);
}
if (fr.bX)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
block->index[0] = 0;
}
+void init_block_null(t_block *block)
+{
+ block->nr = 0;
+ block->nalloc_index = 0;
+ block->index = nullptr;
+}
+
void init_blocka(t_blocka *block)
{
block->nr = 0;
block->a = nullptr;
}
+void init_blocka_null(t_blocka *block)
+{
+ block->nr = 0;
+ block->nra = 0;
+ block->nalloc_index = 0;
+ block->index = nullptr;
+ block->nalloc_a = 0;
+ block->a = nullptr;
+}
+
t_blocka *new_blocka()
{
t_blocka *block;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
int nalloc_a; /* The allocation size for a */
};
+/*! \brief
+ * Fully initialize t_block datastructure.
+ *
+ * Initializes a \p block and sets up the first index to zero.
+ *
+ * \param[in,out] block datastructure to initialize.
+ */
void init_block(t_block *block);
+
+/*! \brief
+ * Fully initialize t_blocka datastructure.
+ *
+ * Initializes a \p block and sets up the first index to zero.
+ * The atom number array is initialized to nullptr.
+ *
+ * \param[in,out] block datastructure to initialize.
+ */
void init_blocka(t_blocka *block);
+
+/* TODO
+ * In general all t_block datastructures should be avoided
+ * in favour of RangePartitioning. This here is a simple cludge
+ * to use more modern initialization while we move to the use
+ * of RangePartitioning.
+ */
+
+/*! \brief
+ * Minimal initialization of t_block datastructure.
+ *
+ * Performs the equivalent to a snew on a t_block, setting all
+ * values to zero or nullptr. Needed for some cases where the topology
+ * handling expects a block to be valid initialized (e.g. during domain
+ * decomposition) but without the first block set to zero.
+ *
+ * \param[in,out] block datastructure to initialize.
+ */
+void init_block_null(t_block *block);
+
+/*! \brief
+ * Minimal initialization of t_blocka datastructure.
+ *
+ * Performs the equivalent to a snew on a t_blocka, setting all
+ * values to zero or nullptr. Needed for some cases where the topology
+ * handling expects a block to be valid initialized (e.g. during domain
+ * decomposition) but without the first block set to zero.
+ *
+ * \param[in,out] block datastructure to initialize.
+ */
+void init_blocka_null(t_blocka *block);
+
t_blocka *new_blocka();
/* allocate new block */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2008,2009,2010,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2008,2009,2010,
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
}
}
-gmx_localtop_t *
-gmx_mtop_generate_local_top(const gmx_mtop_t *mtop,
+void
+gmx_mtop_generate_local_top(const gmx_mtop_t &mtop,
+ gmx_localtop_t *top,
bool freeEnergyInteractionsAtEnd)
{
- gmx_localtop_t *top;
-
- snew(top, 1);
-
- gen_local_top(*mtop, freeEnergyInteractionsAtEnd, true, top);
-
- return top;
+ gen_local_top(mtop, freeEnergyInteractionsAtEnd, true, top);
}
/*! \brief Fills an array with molecule begin/end atom indices
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2013,2014,2015,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
gmx_mtop_global_atoms(const gmx_mtop_t *mtop);
-/* Generate a 'local' topology for the whole system.
+/*! \brief
+ * Populate a 'local' topology for the whole system.
+ *
* When freeEnergyInteractionsAtEnd == true, the free energy interactions will
* be sorted to the end.
+ *
+ * \param[in] mtop The global topology used to populate the local one.
+ * \param[in,out] top New local topology populated from global \p mtop.
+ * \param[in] freeEnergyInteractionsAtEnd If free energy interactions will be sorted.
*/
-gmx_localtop_t *
-gmx_mtop_generate_local_top(const gmx_mtop_t *mtop, bool freeEnergyInteractionsAtEnd);
+void
+gmx_mtop_generate_local_top(const gmx_mtop_t &mtop,
+ gmx_localtop_t *top,
+ bool freeEnergyInteractionsAtEnd);
/*!\brief Creates and returns a struct with begin/end atom indices of all molecules
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
}
}
-void init_localtop(gmx_localtop_t *top)
+gmx_localtop_t::gmx_localtop_t()
{
- init_block(&top->cgs);
- init_blocka(&top->excls);
- init_idef(&top->idef);
- init_atomtypes(&top->atomtypes);
+ init_block_null(&cgs);
+ init_blocka_null(&excls);
+ init_idef(&idef);
+ init_atomtypes(&atomtypes);
}
-void done_localtop(gmx_localtop_t *top)
+gmx_localtop_t::~gmx_localtop_t()
{
- if (top == nullptr)
+ if (!useInDomainDecomp_)
{
- return;
+ done_idef(&idef);
+ done_block(&cgs);
+ done_blocka(&excls);
+ done_atomtypes(&atomtypes);
}
- done_idef(&top->idef);
- done_block(&top->cgs);
- done_blocka(&top->excls);
- done_atomtypes(&top->atomtypes);
-}
-
-void done_and_sfree_localtop(gmx_localtop_t *top)
-{
- done_localtop(top);
- sfree(top);
}
bool gmx_mtop_has_masses(const gmx_mtop_t *mtop)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2014,2015,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2014,2015,2016,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
std::vector<MoleculeBlockIndices> moleculeBlockIndices;
};
-/* The mdrun node-local topology struct, completely written out */
-typedef struct gmx_localtop_t
+/* \brief
+ * The fully written out topology for a domain over its lifetime
+ *
+ * Also used in some analysis code.
+ */
+struct gmx_localtop_t
{
- t_idef idef; /* The interaction function definition */
- t_atomtypes atomtypes; /* Atomtype properties */
- t_block cgs; /* The charge groups */
- t_blocka excls; /* The exclusions */
-} gmx_localtop_t;
+ //! Constructor used for normal operation, manages own resources.
+ gmx_localtop_t();
+
+ ~gmx_localtop_t();
+
+ //! The interaction function definition
+ t_idef idef;
+ //! Atomtype properties
+ t_atomtypes atomtypes;
+ //! The charge groups
+ t_block cgs;
+ //! The exclusions
+ t_blocka excls;
+ //! Flag for domain decomposition so we don't free already freed memory.
+ bool useInDomainDecomp_ = false;
+};
/* The old topology struct, completely written out, used in analysis tools */
typedef struct t_topology
// Frees both t_topology and gmx_mtop_t when the former has been created from
// the latter.
void done_top_mtop(t_topology *top, gmx_mtop_t *mtop);
-/*! \brief
- * Properly initialize local topology.
- *
- * \param[in] top Pointer to topology to initialize.
- */
-void init_localtop(gmx_localtop_t *top);
-/*! \brief
- * Properly clear up local topology,
- *
- * \param[in] top Pointer to topology to clear up.
- */
-void done_localtop(gmx_localtop_t *top);
-void done_and_sfree_localtop(gmx_localtop_t *top);
bool gmx_mtop_has_masses(const gmx_mtop_t *mtop);
bool gmx_mtop_has_charges(const gmx_mtop_t *mtop);
void compareAtomGroups(FILE *fp, const gmx_groups_t &g0, const gmx_groups_t &g1,
int natoms0, int natoms1);
-//! Deleter for gmx_localtop_t, needed until it has a proper destructor.
-using ExpandedTopologyPtr = gmx::unique_cptr<gmx_localtop_t, done_and_sfree_localtop>;
+//! Typedef for gmx_localtop in analysis tools.
+using ExpandedTopologyPtr = std::unique_ptr<gmx_localtop_t>;
void copy_moltype(const gmx_moltype_t *src, gmx_moltype_t *dst);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
// Do lazy initialization
if (expandedTopology_ == nullptr && hasTopology())
{
- expandedTopology_.reset(gmx_mtop_generate_local_top(mtop_.get(), false));
+ expandedTopology_ = gmx::compat::make_unique<gmx_localtop_t>();
+ gmx_mtop_generate_local_top(*mtop_, expandedTopology_.get(), false);
}
return expandedTopology_.get();