From 8b5ddb23880b604099f7ff5d312779f70c72eeec Mon Sep 17 00:00:00 2001 From: Paul Bauer Date: Fri, 19 Mar 2021 12:45:06 +0100 Subject: [PATCH] Bulk change to const ref for mtop Change function signatures in mtop_lookup.h and mtop_util.h to be const ref only for mtop. Also change signatures in other files as I went along. This change is only refactoring. --- api/gmxapi/cpp/tpr.cpp | 6 +- api/legacy/include/gromacs/fileio/confio.h | 4 +- api/legacy/include/gromacs/fileio/tpxio.h | 2 +- api/legacy/include/gromacs/fileio/trxio.h | 4 +- src/gromacs/coordinateio/coordinatefile.cpp | 4 +- src/gromacs/domdec/domdec_constraints.cpp | 4 +- src/gromacs/essentialdynamics/edsam.cpp | 4 +- src/gromacs/fileio/confio.cpp | 6 +- src/gromacs/fileio/groio.cpp | 8 +- src/gromacs/fileio/groio.h | 4 +- src/gromacs/fileio/tpxio.cpp | 8 +- src/gromacs/gmxana/gmx_clustsize.cpp | 10 +-- src/gromacs/gmxana/gmx_disre.cpp | 2 +- src/gromacs/gmxana/gmx_nmeig.cpp | 2 +- src/gromacs/gmxana/gmx_nmr.cpp | 5 +- src/gromacs/gmxpreprocess/genconf.cpp | 2 +- src/gromacs/gmxpreprocess/genrestr.cpp | 4 +- src/gromacs/gmxpreprocess/grompp.cpp | 8 +- .../gmxpreprocess/insert_molecules.cpp | 4 +- src/gromacs/gmxpreprocess/readir.cpp | 42 +++++----- src/gromacs/gmxpreprocess/readir.h | 4 +- src/gromacs/gmxpreprocess/readpull.cpp | 10 +-- src/gromacs/gmxpreprocess/solvate.cpp | 4 +- src/gromacs/imd/imd.cpp | 12 +-- src/gromacs/imd/imd.h | 6 +- src/gromacs/listed_forces/disre.cpp | 4 +- src/gromacs/listed_forces/disre.h | 2 +- src/gromacs/listed_forces/orires.cpp | 14 ++-- src/gromacs/listed_forces/orires.h | 2 +- src/gromacs/mdlib/dispersioncorrection.cpp | 2 +- src/gromacs/mdlib/mdatoms.cpp | 6 +- src/gromacs/mdlib/mdoutf.cpp | 14 ++-- src/gromacs/mdlib/mdoutf.h | 4 +- src/gromacs/mdlib/membed.cpp | 56 +++++++------- src/gromacs/mdlib/trajectory_writing.cpp | 8 +- src/gromacs/mdlib/trajectory_writing.h | 2 +- src/gromacs/mdlib/update_vv.cpp | 4 +- src/gromacs/mdlib/update_vv.h | 2 +- src/gromacs/mdlib/updategroupscog.cpp | 4 +- src/gromacs/mdlib/vsite.cpp | 2 +- src/gromacs/mdrun/isimulator.h | 4 +- src/gromacs/mdrun/md.cpp | 34 ++++----- src/gromacs/mdrun/mimic.cpp | 28 +++---- src/gromacs/mdrun/minimize.cpp | 50 ++++++------ src/gromacs/mdrun/rerun.cpp | 28 +++---- src/gromacs/mdrun/runner.cpp | 24 +++--- src/gromacs/mdrun/shellfc.cpp | 76 +++++++------------ src/gromacs/mdrun/shellfc.h | 2 +- src/gromacs/mdrun/simulatorbuilder.h | 6 +- src/gromacs/mdrun/tpi.cpp | 16 ++-- .../computeglobalselement.cpp | 6 +- .../modularsimulator/computeglobalselement.h | 6 +- src/gromacs/modularsimulator/energydata.cpp | 8 +- src/gromacs/modularsimulator/energydata.h | 6 +- src/gromacs/modularsimulator/forceelement.cpp | 2 +- src/gromacs/modularsimulator/forceelement.h | 2 +- .../modularsimulator/modularsimulator.cpp | 2 +- .../modularsimulator/simulatoralgorithm.cpp | 6 +- .../modularsimulator/statepropagatordata.cpp | 8 +- .../modularsimulator/statepropagatordata.h | 8 +- .../modularsimulator/trajectoryelement.cpp | 4 +- .../modularsimulator/trajectoryelement.h | 4 +- src/gromacs/pulling/pull.cpp | 6 +- src/gromacs/pulling/pull.h | 4 +- src/gromacs/pulling/pull_rotation.cpp | 28 +++---- src/gromacs/pulling/pull_rotation.h | 2 +- src/gromacs/selection/centerofmass.cpp | 14 ++-- src/gromacs/selection/indexutil.cpp | 22 +++--- src/gromacs/selection/selection.cpp | 4 +- src/gromacs/selection/sm_simple.cpp | 30 ++++---- src/gromacs/swap/swapcoords.cpp | 24 +++--- src/gromacs/swap/swapcoords.h | 2 +- .../taskassignment/resourcedivision.cpp | 6 +- src/gromacs/taskassignment/resourcedivision.h | 4 +- src/gromacs/tools/convert_tpr.cpp | 8 +- src/gromacs/tools/make_ndx.cpp | 4 +- src/gromacs/tools/pme_error.cpp | 2 +- src/gromacs/tools/report_methods.cpp | 2 +- src/gromacs/tools/tune_pme.cpp | 4 +- src/gromacs/topology/mtop_lookup.h | 59 ++++++-------- src/gromacs/topology/mtop_util.cpp | 60 ++++++--------- src/gromacs/topology/mtop_util.h | 16 ++-- .../topologyinformation.cpp | 2 +- 83 files changed, 438 insertions(+), 490 deletions(-) diff --git a/api/gmxapi/cpp/tpr.cpp b/api/gmxapi/cpp/tpr.cpp index 2ea116e362..b59f7f971e 100644 --- a/api/gmxapi/cpp/tpr.cpp +++ b/api/gmxapi/cpp/tpr.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -706,7 +706,7 @@ void writeTprFile(const std::string& filename, const auto& inputRecord = tprFile->inputRecord(); const auto& writeState = tprFile->state(); const auto& writeTopology = tprFile->molecularTopology(); - write_tpx_state(filename.c_str(), &inputRecord, &writeState, &writeTopology); + write_tpx_state(filename.c_str(), &inputRecord, &writeState, writeTopology); } TprReadHandle::TprReadHandle(TprContents&& tprFile) : @@ -774,7 +774,7 @@ bool rewrite_tprfile(const std::string& inFile, const std::string& outFile, doub irInstance.nsteps = lround((endTime - run_t) / irInstance.delta_t); - write_tpx_state(outFile.c_str(), &irInstance, &state, &mtop); + write_tpx_state(outFile.c_str(), &irInstance, &state, mtop); success = true; return success; diff --git a/api/legacy/include/gromacs/fileio/confio.h b/api/legacy/include/gromacs/fileio/confio.h index 08af69c205..bd69125d2e 100644 --- a/api/legacy/include/gromacs/fileio/confio.h +++ b/api/legacy/include/gromacs/fileio/confio.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -73,7 +73,7 @@ void write_sto_conf(const char* outfile, void write_sto_conf_mtop(const char* outfile, const char* title, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const rvec x[], const rvec* v, PbcType pbcType, diff --git a/api/legacy/include/gromacs/fileio/tpxio.h b/api/legacy/include/gromacs/fileio/tpxio.h index 08229c62a4..96ff4f6ca5 100644 --- a/api/legacy/include/gromacs/fileio/tpxio.h +++ b/api/legacy/include/gromacs/fileio/tpxio.h @@ -144,7 +144,7 @@ struct PartialDeserializedTprFile */ TpxFileHeader readTpxHeader(const char* fileName, bool canReadTopologyOnly); -void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, const gmx_mtop_t* mtop); +void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, const gmx_mtop_t& mtop); /* Write a file, and close it again. */ diff --git a/api/legacy/include/gromacs/fileio/trxio.h b/api/legacy/include/gromacs/fileio/trxio.h index ae1660c99a..9e9bedf421 100644 --- a/api/legacy/include/gromacs/fileio/trxio.h +++ b/api/legacy/include/gromacs/fileio/trxio.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -138,7 +138,7 @@ t_trxstatus* trjtools_gmx_prepare_tng_writing(const char* filename, t_trxstatus* in, const char* infile, int natoms, - const struct gmx_mtop_t* mtop, + const gmx_mtop_t* mtop, gmx::ArrayRef index, const char* index_group_name); diff --git a/src/gromacs/coordinateio/coordinatefile.cpp b/src/gromacs/coordinateio/coordinatefile.cpp index 2899ed0db8..549e37693e 100644 --- a/src/gromacs/coordinateio/coordinatefile.cpp +++ b/src/gromacs/coordinateio/coordinatefile.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -363,7 +363,7 @@ static t_trxstatus* openTNG(const std::string& name, const Selection& sel, const nullptr, mtop->natoms, mtop, - get_atom_index(mtop), + get_atom_index(*mtop), "System"); } } diff --git a/src/gromacs/domdec/domdec_constraints.cpp b/src/gromacs/domdec/domdec_constraints.cpp index 8afb7c9bf7..9bc5a5378d 100644 --- a/src/gromacs/domdec/domdec_constraints.cpp +++ b/src/gromacs/domdec/domdec_constraints.cpp @@ -240,7 +240,7 @@ static void atoms_to_settles(gmx_domdec_t* dd, { int a_gl = dd->globalAtomIndices[a]; int a_mol = 0; - mtopGetMolblockIndex(&mtop, a_gl, &mb, nullptr, &a_mol); + mtopGetMolblockIndex(mtop, a_gl, &mb, nullptr, &a_mol); const gmx_molblock_t* molb = &mtop.molblock[mb]; int settle = at2settle_mt[molb->type][a_mol]; @@ -321,7 +321,7 @@ static void atoms_to_constraints(gmx_domdec_t* dd, int a_gl = dd->globalAtomIndices[a]; int molnr = 0; int a_mol = 0; - mtopGetMolblockIndex(&mtop, a_gl, &mb, &molnr, &a_mol); + mtopGetMolblockIndex(mtop, a_gl, &mb, &molnr, &a_mol); const gmx_molblock_t& molb = mtop.molblock[mb]; diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index d4c9de8e34..fa612d238d 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -1335,7 +1335,7 @@ static void init_edi(const gmx_mtop_t& mtop, t_edpar* edi) { if (edi->fitmas) { - edi->sref.m[i] = mtopGetAtomMass(&mtop, edi->sref.anrs[i], &molb); + edi->sref.m[i] = mtopGetAtomMass(mtop, edi->sref.anrs[i], &molb); } else { @@ -1366,7 +1366,7 @@ static void init_edi(const gmx_mtop_t& mtop, t_edpar* edi) snew(edi->sav.m, edi->sav.nr); for (i = 0; i < edi->sav.nr; i++) { - edi->sav.m[i] = mtopGetAtomMass(&mtop, edi->sav.anrs[i], &molb); + edi->sav.m[i] = mtopGetAtomMass(mtop, edi->sav.anrs[i], &molb); if (edi->pcamas) { edi->sav.sqrtm[i] = sqrt(edi->sav.m[i]); diff --git a/src/gromacs/fileio/confio.cpp b/src/gromacs/fileio/confio.cpp index fe71e265d9..6af30e2a01 100644 --- a/src/gromacs/fileio/confio.cpp +++ b/src/gromacs/fileio/confio.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -174,7 +174,7 @@ void write_sto_conf(const char* outfile, void write_sto_conf_mtop(const char* outfile, const char* title, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const rvec x[], const rvec* v, PbcType pbcType, @@ -407,7 +407,7 @@ void readConfAndAtoms(const char* infile, readConfAndTopology(infile, &haveTopology, &mtop, pbcType, x, v, box); *symtab = mtop.symtab; *name = gmx_strdup(*mtop.name); - *atoms = gmx_mtop_global_atoms(&mtop); + *atoms = gmx_mtop_global_atoms(mtop); gmx::RangePartitioning molecules = gmx_mtop_molecules(mtop); makeChainIdentifiersAfterTprReading(atoms, molecules); diff --git a/src/gromacs/fileio/groio.cpp b/src/gromacs/fileio/groio.cpp index fdc1ebcb41..4852b720b8 100644 --- a/src/gromacs/fileio/groio.cpp +++ b/src/gromacs/fileio/groio.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -529,14 +529,14 @@ void write_hconf_indexed_p(FILE* out, fflush(out); } -void write_hconf_mtop(FILE* out, const char* title, const gmx_mtop_t* mtop, const rvec* x, const rvec* v, const matrix box) +void write_hconf_mtop(FILE* out, const char* title, const gmx_mtop_t& mtop, const rvec* x, const rvec* v, const matrix box) { fprintf(out, "%s\n", (title && title[0]) ? title : gmx::bromacs().c_str()); - fprintf(out, "%5d\n", mtop->natoms); + fprintf(out, "%5d\n", mtop.natoms); const char* format = get_hconf_format(v != nullptr); - for (const AtomProxy atomP : AtomRange(*mtop)) + for (const AtomProxy atomP : AtomRange(mtop)) { int i = atomP.globalAtomNumber(); int residueNumber = atomP.residueNumber(); diff --git a/src/gromacs/fileio/groio.h b/src/gromacs/fileio/groio.h index 3361893f9a..c310cf6ef6 100644 --- a/src/gromacs/fileio/groio.h +++ b/src/gromacs/fileio/groio.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -65,7 +65,7 @@ void write_hconf_indexed_p(FILE* out, const rvec* v, const matrix box); -void write_hconf_mtop(FILE* out, const char* title, const gmx_mtop_t* mtop, const rvec* x, const rvec* v, const matrix box); +void write_hconf_mtop(FILE* out, const char* title, const gmx_mtop_t& mtop, const rvec* x, const rvec* v, const matrix box); void write_hconf_p(FILE* out, const char* title, const t_atoms* atoms, const rvec* x, const rvec* v, const matrix box); /* Write a Gromos file with precision ndec: number of decimal places in x, diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index bcaaca2b88..3d1dbb3c68 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -2536,7 +2536,7 @@ static void set_disres_npair(gmx_mtop_t* mtop) gmx::ArrayRef ip = mtop->ffparams.iparams; - iloop = gmx_mtop_ilistloop_init(mtop); + iloop = gmx_mtop_ilistloop_init(*mtop); while (const InteractionLists* ilist = gmx_mtop_ilistloop_next(iloop, &nmol)) { const InteractionList& il = (*ilist)[F_DISRES]; @@ -3293,7 +3293,7 @@ TpxFileHeader readTpxHeader(const char* fileName, bool canReadTopologyOnly) return tpx; } -void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, const gmx_mtop_t* mtop) +void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, const gmx_mtop_t& mtop) { /* To write a state, we first need to write the state information to a buffer before * we append the raw bytes to the file. For this, the header information needs to be @@ -3303,7 +3303,7 @@ void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, t_fileio* fio; - TpxFileHeader tpx = populateTpxHeader(*state, ir, mtop); + TpxFileHeader tpx = populateTpxHeader(*state, ir, &mtop); // Long-term we should move to use little endian in files to avoid extra byte swapping, // but since we just used the default XDR format (which is big endian) for the TPR // header it would cause third-party libraries reading our raw data to tear their hair @@ -3317,7 +3317,7 @@ void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, const_cast(state), nullptr, nullptr, - const_cast(mtop)); + const_cast(&mtop)); std::vector tprBody = tprBodySerializer.finishAndGetBuffer(); tpx.sizeOfTprBody = tprBody.size(); diff --git a/src/gromacs/gmxana/gmx_clustsize.cpp b/src/gromacs/gmxana/gmx_clustsize.cpp index 44ec18ba8c..154728d519 100644 --- a/src/gromacs/gmxana/gmx_clustsize.cpp +++ b/src/gromacs/gmxana/gmx_clustsize.cpp @@ -96,7 +96,7 @@ static void clust_size(const char* ndx, /* Topology stuff */ t_trxframe fr; TpxFileHeader tpxh; - gmx_mtop_t* mtop = nullptr; + gmx_mtop_t mtop; PbcType pbcType = PbcType::Unset; int ii, jj; real temp, tfac; @@ -127,13 +127,12 @@ static void clust_size(const char* ndx, if (tpr) { - mtop = new gmx_mtop_t; tpxh = readTpxHeader(tpr, true); if (tpxh.natoms != natoms) { gmx_fatal(FARGS, "tpr (%d atoms) and trajectory (%d atoms) do not match!", tpxh.natoms, natoms); } - pbcType = read_tpx(tpr, nullptr, nullptr, &natoms, nullptr, nullptr, mtop); + pbcType = read_tpx(tpr, nullptr, nullptr, &natoms, nullptr, nullptr, &mtop); } if (ndf <= -1) { @@ -151,8 +150,8 @@ static void clust_size(const char* ndx, { printf("Using molecules rather than atoms. Not reading index file %s\n", ndx); } - GMX_RELEASE_ASSERT(mtop != nullptr, "Trying to access mtop->mols from NULL mtop pointer"); - mols = gmx_mtop_molecules(*mtop); + GMX_RELEASE_ASSERT(tpr, "Cannot access topology without having read it from TPR"); + mols = gmx_mtop_molecules(mtop); /* Make dummy index */ nindex = mols.numBlocks(); @@ -486,7 +485,6 @@ static void clust_size(const char* ndx, rhi, &nlevels); gmx_ffclose(fp); - delete mtop; sfree(t_x); sfree(t_y); for (i = 0; (i < n_x); i++) diff --git a/src/gromacs/gmxana/gmx_disre.cpp b/src/gromacs/gmxana/gmx_disre.cpp index 5f32405b24..54865bc612 100644 --- a/src/gromacs/gmxana/gmx_disre.cpp +++ b/src/gromacs/gmxana/gmx_disre.cpp @@ -839,7 +839,7 @@ int gmx_disre(int argc, char* argv[]) ir->dr_tau = 0.0; t_disresdata disresdata; init_disres(fplog, - topInfo.mtop(), + *topInfo.mtop(), ir, DisResRunMode::AnalysisTool, DDRole::Master, diff --git a/src/gromacs/gmxana/gmx_nmeig.cpp b/src/gromacs/gmxana/gmx_nmeig.cpp index 7f308a16f0..8d31e78927 100644 --- a/src/gromacs/gmxana/gmx_nmeig.cpp +++ b/src/gromacs/gmxana/gmx_nmeig.cpp @@ -545,7 +545,7 @@ int gmx_nmeig(int argc, char* argv[]) { nharm = get_nharm(&mtop); } - std::vector atom_index = get_atom_index(&mtop); + std::vector atom_index = get_atom_index(mtop); top = gmx_mtop_t_to_t_topology(&mtop, true); diff --git a/src/gromacs/gmxana/gmx_nmr.cpp b/src/gromacs/gmxana/gmx_nmr.cpp index 7a6ac17faa..d98f5fc236 100644 --- a/src/gromacs/gmxana/gmx_nmr.cpp +++ b/src/gromacs/gmxana/gmx_nmr.cpp @@ -686,8 +686,9 @@ int gmx_nmr(int argc, char* argv[]) snew(pairleg[i], 30); j = fa[3 * i + 1]; k = fa[3 * i + 2]; - mtopGetAtomAndResidueName(topInfo.mtop(), j, &molb, &anm_j, &resnr_j, &resnm_j, nullptr); - mtopGetAtomAndResidueName(topInfo.mtop(), k, &molb, &anm_k, &resnr_k, &resnm_k, nullptr); + GMX_ASSERT(topInfo.hasTopology(), "Need to have a valid topology"); + 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, diff --git a/src/gromacs/gmxpreprocess/genconf.cpp b/src/gromacs/gmxpreprocess/genconf.cpp index 8f80c794af..d660eb37fa 100644 --- a/src/gromacs/gmxpreprocess/genconf.cpp +++ b/src/gromacs/gmxpreprocess/genconf.cpp @@ -180,7 +180,7 @@ int gmx_genconf(int argc, char* argv[]) gmx_mtop_t mtop; bool haveTop = false; readConfAndTopology(opt2fn("-f", NFILE, fnm), &haveTop, &mtop, &pbcType, &x, &v, box); - t_atoms atoms = gmx_mtop_global_atoms(&mtop); + t_atoms atoms = gmx_mtop_global_atoms(mtop); natoms = atoms.nr; nres = atoms.nres; /* nr of residues in one element? */ /* make space for all the atoms */ diff --git a/src/gromacs/gmxpreprocess/genrestr.cpp b/src/gromacs/gmxpreprocess/genrestr.cpp index 2670ae994b..8a4c60c746 100644 --- a/src/gromacs/gmxpreprocess/genrestr.cpp +++ b/src/gromacs/gmxpreprocess/genrestr.cpp @@ -4,7 +4,7 @@ * 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. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -190,7 +190,7 @@ int gmx_genrestr(int argc, char* argv[]) fprintf(stderr, "\nReading structure file\n"); readConfAndTopology(xfn, &haveTopology, &mtop, nullptr, &x, &v, box); title = *mtop.name; - atoms = gmx_mtop_global_atoms(&mtop); + atoms = gmx_mtop_global_atoms(mtop); if (atoms.pdbinfo == nullptr) { snew(atoms.pdbinfo, atoms.nr); diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 9bd9996437..11a7d0c551 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -680,7 +680,7 @@ static void new_status(const char* topfile, * constraints only. Do not print note with large timesteps or vsites. */ if (opts->nshake == eshALLBONDS && ffParametrizedWithHBondConstraints && ir->delta_t < 0.0026 - && gmx_mtop_ftype_count(sys, F_VSITE3FD) == 0) + && gmx_mtop_ftype_count(*sys, F_VSITE3FD) == 0) { set_warning_line(wi, "unknown", -1); warning_note(wi, @@ -2392,7 +2392,7 @@ int gmx_grompp(int argc, char* argv[]) if (ir->bPull) { pull = set_pull_init(ir, - &sys, + sys, state.x.rvec_array(), state.box, state.lambda[FreeEnergyPerturbationCouplingType::Mass], @@ -2522,10 +2522,10 @@ int gmx_grompp(int argc, char* argv[]) } done_warning(wi, FARGS); - write_tpx_state(ftp2fn(efTPR, NFILE, fnm), ir, &state, &sys); + write_tpx_state(ftp2fn(efTPR, NFILE, fnm), ir, &state, sys); /* Output IMD group, if bIMD is TRUE */ - gmx::write_IMDgroup_to_file(ir->bIMD, ir, &state, &sys, NFILE, fnm); + gmx::write_IMDgroup_to_file(ir->bIMD, ir, &state, sys, NFILE, fnm); sfree(opts->define); sfree(opts->wall_atomtype[0]); diff --git a/src/gromacs/gmxpreprocess/insert_molecules.cpp b/src/gromacs/gmxpreprocess/insert_molecules.cpp index 6cc985536a..5667dcb965 100644 --- a/src/gromacs/gmxpreprocess/insert_molecules.cpp +++ b/src/gromacs/gmxpreprocess/insert_molecules.cpp @@ -575,7 +575,7 @@ int InsertMolecules::run() insertConfFile_.c_str(), &bTprFileWasRead, &topInserted, &pbcType_dummy, &temporaryX, nullptr, box_dummy); xInserted.assign(temporaryX, temporaryX + topInserted.natoms); sfree(temporaryX); - atomsInserted = gmx_mtop_global_atoms(&topInserted); + atomsInserted = gmx_mtop_global_atoms(topInserted); if (atomsInserted.nr == 0) { gmx_fatal(FARGS, "No molecule in %s, please check your input", insertConfFile_.c_str()); @@ -590,7 +590,7 @@ int InsertMolecules::run() } } - t_atoms atoms = gmx_mtop_global_atoms(&top_); + t_atoms atoms = gmx_mtop_global_atoms(top_); /* add nmol_ins molecules of atoms_ins in random orientation at random place */ diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index fba69a3e46..6eac6098c8 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -3479,7 +3479,7 @@ void do_index(const char* mdparin, snew(defaultIndexGroups, 1); snew(defaultIndexGroups->index, 1); snew(gnames, 1); - atoms_all = gmx_mtop_global_atoms(mtop); + atoms_all = gmx_mtop_global_atoms(*mtop); analyse(&atoms_all, defaultIndexGroups, &gnames, FALSE, TRUE); done_atom(&atoms_all); } @@ -4078,11 +4078,11 @@ void do_index(const char* mdparin, } -static void check_disre(const gmx_mtop_t* mtop) +static void check_disre(const gmx_mtop_t& mtop) { if (gmx_mtop_ftype_count(mtop, F_DISRES) > 0) { - const gmx_ffparams_t& ffparams = mtop->ffparams; + const gmx_ffparams_t& ffparams = mtop.ffparams; int ndouble = 0; int old_label = -1; for (int i = 0; i < ffparams.numTypes(); i++) @@ -4110,7 +4110,7 @@ static void check_disre(const gmx_mtop_t* mtop) } } -static bool absolute_reference(const t_inputrec* ir, const gmx_mtop_t* sys, const bool posres_only, ivec AbsRef) +static bool absolute_reference(const t_inputrec* ir, const gmx_mtop_t& sys, const bool posres_only, ivec AbsRef) { int d, g, i; gmx_mtop_ilistloop_t iloop; @@ -4147,7 +4147,7 @@ static bool absolute_reference(const t_inputrec* ir, const gmx_mtop_t* sys, cons { for (i = 0; i < (*ilist)[F_POSRES].size(); i += 2) { - pr = &sys->ffparams.iparams[(*ilist)[F_POSRES].iatoms[i]]; + pr = &sys.ffparams.iparams[(*ilist)[F_POSRES].iatoms[i]]; for (d = 0; d < DIM; d++) { if (pr->posres.fcA[d] != 0) @@ -4159,7 +4159,7 @@ static bool absolute_reference(const t_inputrec* ir, const gmx_mtop_t* sys, cons for (i = 0; i < (*ilist)[F_FBPOSRES].size(); i += 2) { /* Check for flat-bottom posres */ - pr = &sys->ffparams.iparams[(*ilist)[F_FBPOSRES].iatoms[i]]; + pr = &sys.ffparams.iparams[(*ilist)[F_FBPOSRES].iatoms[i]]; if (pr->fbposres.k != 0) { switch (pr->fbposres.geom) @@ -4191,7 +4191,7 @@ static bool absolute_reference(const t_inputrec* ir, const gmx_mtop_t* sys, cons return (AbsRef[XX] != 0 && AbsRef[YY] != 0 && AbsRef[ZZ] != 0); } -static void check_combination_rule_differences(const gmx_mtop_t* mtop, +static void check_combination_rule_differences(const gmx_mtop_t& mtop, int state, bool* bC6ParametersWorkWithGeometricRules, bool* bC6ParametersWorkWithLBRules, @@ -4227,19 +4227,19 @@ static void check_combination_rule_differences(const gmx_mtop_t* mtop, *bC6ParametersWorkWithLBRules = TRUE; *bC6ParametersWorkWithGeometricRules = TRUE; bCanDoLBRules = TRUE; - ntypes = mtop->ffparams.atnr; + ntypes = mtop.ffparams.atnr; snew(typecount, ntypes); gmx_mtop_count_atomtypes(mtop, state, typecount); *bLBRulesPossible = TRUE; for (tpi = 0; tpi < ntypes; ++tpi) { - c6i = mtop->ffparams.iparams[(ntypes + 1) * tpi].lj.c6; - c12i = mtop->ffparams.iparams[(ntypes + 1) * tpi].lj.c12; + c6i = mtop.ffparams.iparams[(ntypes + 1) * tpi].lj.c6; + c12i = mtop.ffparams.iparams[(ntypes + 1) * tpi].lj.c12; for (tpj = tpi; tpj < ntypes; ++tpj) { - c6j = mtop->ffparams.iparams[(ntypes + 1) * tpj].lj.c6; - c12j = mtop->ffparams.iparams[(ntypes + 1) * tpj].lj.c12; - c6 = mtop->ffparams.iparams[ntypes * tpi + tpj].lj.c6; + c6j = mtop.ffparams.iparams[(ntypes + 1) * tpj].lj.c6; + c12j = mtop.ffparams.iparams[(ntypes + 1) * tpj].lj.c12; + c6 = mtop.ffparams.iparams[ntypes * tpi + tpj].lj.c6; c6_geometric = std::sqrt(c6i * c6j); if (!gmx_numzero(c6_geometric)) { @@ -4275,7 +4275,7 @@ static void check_combination_rule_differences(const gmx_mtop_t* mtop, sfree(typecount); } -static void check_combination_rules(const t_inputrec* ir, const gmx_mtop_t* mtop, warninp_t wi) +static void check_combination_rules(const t_inputrec* ir, const gmx_mtop_t& mtop, warninp_t wi) { bool bLBRulesPossible, bC6ParametersWorkWithGeometricRules, bC6ParametersWorkWithLBRules; @@ -4335,7 +4335,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ set_warning_line(wi, mdparin, -1); - if (absolute_reference(ir, sys, false, AbsRef)) + if (absolute_reference(ir, *sys, false, AbsRef)) { warning_note(wi, "Removing center of mass motion in the presence of position restraints might " @@ -4432,7 +4432,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ if (EI_DYNAMICS(ir->eI) && !EI_SD(ir->eI) && ir->eI != IntegrationAlgorithm::BD && ir->comm_mode == ComRemovalAlgorithm::No - && !(absolute_reference(ir, sys, FALSE, AbsRef) || ir->nsteps <= 10) && !ETC_ANDERSEN(ir->etc)) + && !(absolute_reference(ir, *sys, FALSE, AbsRef) || ir->nsteps <= 10) && !ETC_ANDERSEN(ir->etc)) { warning(wi, "You are not using center of mass motion removal (mdp option comm-mode), numerical " @@ -4464,7 +4464,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ /* Check for pressure coupling with absolute position restraints */ if (ir->epc != PressureCoupling::No && ir->refcoord_scaling == RefCoordScaling::No) { - absolute_reference(ir, sys, TRUE, AbsRef); + absolute_reference(ir, *sys, TRUE, AbsRef); { for (m = 0; m < DIM; m++) { @@ -4480,7 +4480,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ } bCharge = FALSE; - aloopb = gmx_mtop_atomloop_block_init(sys); + aloopb = gmx_mtop_atomloop_block_init(*sys); const t_atom* atom; while (gmx_mtop_atomloop_block_next(aloopb, &atom, &nmol)) { @@ -4518,7 +4518,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ /* Check if combination rules used in LJ-PME are the same as in the force field */ if (EVDW_PME(ir->vdwtype)) { - check_combination_rules(ir, sys, wi); + check_combination_rules(ir, *sys, wi); } /* Generalized reaction field */ @@ -4545,7 +4545,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ { if (ir->pull->coord[i].group[0] == 0 || ir->pull->coord[i].group[1] == 0) { - absolute_reference(ir, sys, FALSE, AbsRef); + absolute_reference(ir, *sys, FALSE, AbsRef); for (m = 0; m < DIM; m++) { if (ir->pull->coord[i].dim[m] && !AbsRef[m]) @@ -4584,7 +4584,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_ } } - check_disre(sys); + check_disre(*sys); } void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool bHasAnyConstraints, warninp_t wi) diff --git a/src/gromacs/gmxpreprocess/readir.h b/src/gromacs/gmxpreprocess/readir.h index a936ef43d5..dfec8859a6 100644 --- a/src/gromacs/gmxpreprocess/readir.h +++ b/src/gromacs/gmxpreprocess/readir.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -165,7 +165,7 @@ void checkPullCoords(gmx::ArrayRef pullGroups, gmx::ArrayRef pullCoords); /* Process the pull coordinates after reading the pull groups */ -pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix box, real lambda, warninp_t wi); +pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t& mtop, rvec* x, matrix box, real lambda, warninp_t wi); /* Prints the initial pull group distances in x. * If requested, adds the current distance to the initial reference location. * Returns the pull_t pull work struct. This should be passed to finish_pull() diff --git a/src/gromacs/gmxpreprocess/readpull.cpp b/src/gromacs/gmxpreprocess/readpull.cpp index 60f515da09..f89ff7986e 100644 --- a/src/gromacs/gmxpreprocess/readpull.cpp +++ b/src/gromacs/gmxpreprocess/readpull.cpp @@ -549,7 +549,7 @@ void checkPullCoords(gmx::ArrayRef pullGroups, gmx::ArrayRef } } -pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix box, real lambda, warninp_t wi) +pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t& mtop, rvec* x, matrix box, real lambda, warninp_t wi) { pull_t* pull_work; t_pbc pbc; @@ -559,9 +559,9 @@ pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix bo pull_params_t* pull = ir->pull.get(); gmx::LocalAtomSetManager atomSets; pull_work = init_pull(nullptr, pull, ir, mtop, nullptr, &atomSets, lambda); - auto mdAtoms = gmx::makeMDAtoms(nullptr, *mtop, *ir, false); + auto mdAtoms = gmx::makeMDAtoms(nullptr, mtop, *ir, false); auto md = mdAtoms->mdatoms(); - atoms2md(*mtop, *ir, -1, {}, mtop->natoms, mdAtoms.get()); + atoms2md(mtop, *ir, -1, {}, mtop.natoms, mdAtoms.get()); if (ir->efep != FreeEnergyPerturbationType::No) { update_mdatoms(md, lambda); @@ -581,7 +581,7 @@ pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix bo { bool groupObeysPbc = pullCheckPbcWithinGroup( *pull_work, - gmx::arrayRefFromArray(reinterpret_cast(x), mtop->natoms), + gmx::arrayRefFromArray(reinterpret_cast(x), mtop.natoms), pbc, g, c_pullGroupSmallGroupThreshold); @@ -618,7 +618,7 @@ pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix bo { groupObeysPbc = pullCheckPbcWithinGroup( *pull_work, - gmx::arrayRefFromArray(reinterpret_cast(x), mtop->natoms), + gmx::arrayRefFromArray(reinterpret_cast(x), mtop.natoms), pbc, g, c_pullGroupPbcMargin); diff --git a/src/gromacs/gmxpreprocess/solvate.cpp b/src/gromacs/gmxpreprocess/solvate.cpp index 62ab86c576..b0a9c09a57 100644 --- a/src/gromacs/gmxpreprocess/solvate.cpp +++ b/src/gromacs/gmxpreprocess/solvate.cpp @@ -634,7 +634,7 @@ static void add_solv(const char* filename, boxSolvent); t_atoms* atomsSolvent; snew(atomsSolvent, 1); - *atomsSolvent = gmx_mtop_global_atoms(&topSolvent); + *atomsSolvent = gmx_mtop_global_atoms(topSolvent); xSolvent.assign(temporaryX, temporaryX + topSolvent.natoms); sfree(temporaryX); vSolvent.assign(temporaryV, temporaryV + topSolvent.natoms); @@ -991,7 +991,7 @@ int gmx_solvate(int argc, char* argv[]) rvec *temporaryX = nullptr, *temporaryV = nullptr; readConfAndTopology( conf_prot, &bTprFileWasRead, &top, &pbcType, &temporaryX, bReadV ? &temporaryV : nullptr, box); - *atoms = gmx_mtop_global_atoms(&top); + *atoms = gmx_mtop_global_atoms(top); x.assign(temporaryX, temporaryX + top.natoms); sfree(temporaryX); if (temporaryV) diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index aaec29e3ad..edc6a2fed9 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -199,7 +199,7 @@ public: */ void openOutputFile(const char* fn, int nat_total, const gmx_output_env_t* oenv, StartingBehavior startingBehavior); /*! \brief Creates the molecule start-end position array of molecules in the IMD group. */ - void prepareMoleculesInImdGroup(const gmx_mtop_t* top_global); + void prepareMoleculesInImdGroup(const gmx_mtop_t& top_global); /*! \brief Removes shifts of molecules diffused outside of the box. */ void removeMolecularShifts(const matrix box); /*! \brief Initialize arrays used to assemble the positions from the other nodes. */ @@ -516,7 +516,7 @@ static bool imd_recv_mdcomm(IMDSocket* socket, int32_t nforces, int32_t* forcend void write_IMDgroup_to_file(bool bIMD, t_inputrec* ir, const t_state* state, - const gmx_mtop_t* sys, + const gmx_mtop_t& sys, int nfile, const t_filenm fnm[]) { @@ -1080,7 +1080,7 @@ ImdSession::Impl::~Impl() } -void ImdSession::Impl::prepareMoleculesInImdGroup(const gmx_mtop_t* top_global) +void ImdSession::Impl::prepareMoleculesInImdGroup(const gmx_mtop_t& top_global) { /* check whether index is sorted */ for (int i = 0; i < nat - 1; i++) @@ -1091,7 +1091,7 @@ void ImdSession::Impl::prepareMoleculesInImdGroup(const gmx_mtop_t* top_global) } } - RangePartitioning gmols = gmx_mtop_molecules(*top_global); + RangePartitioning gmols = gmx_mtop_molecules(top_global); t_block lmols; lmols.nr = 0; snew(lmols.index, gmols.numBlocks() + 1); @@ -1302,7 +1302,7 @@ std::unique_ptr makeImdSession(const t_inputrec* ir, gmx_wallcycle* wcycle, gmx_enerdata_t* enerd, const gmx_multisim_t* ms, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const MDLogger& mdlog, const rvec x[], int nfile, @@ -1404,7 +1404,7 @@ std::unique_ptr makeImdSession(const t_inputrec* ir, ***************************************************** */ - int nat_total = top_global->natoms; + int nat_total = top_global.natoms; /* Initialize IMD session. If we read in a pre-IMD .tpr file, ir->imd->nat * will be zero. For those cases we transfer _all_ atomic positions */ diff --git a/src/gromacs/imd/imd.h b/src/gromacs/imd/imd.h index 2b0ea59606..6c6517717c 100644 --- a/src/gromacs/imd/imd.h +++ b/src/gromacs/imd/imd.h @@ -114,7 +114,7 @@ static const char IMDstr[] = "IMD:"; /**< Tag output from the IMD module with th void write_IMDgroup_to_file(bool bIMD, t_inputrec* ir, const t_state* state, - const gmx_mtop_t* sys, + const gmx_mtop_t& sys, int nfile, const t_filenm fnm[]); @@ -142,7 +142,7 @@ std::unique_ptr makeImdSession(const t_inputrec* ir, gmx_wallcycle* wcycle, gmx_enerdata_t* enerd, const gmx_multisim_t* ms, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const MDLogger& mdlog, const rvec x[], int nfile, @@ -225,7 +225,7 @@ public: gmx_wallcycle* wcycle, gmx_enerdata_t* enerd, const gmx_multisim_t* ms, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const MDLogger& mdlog, const rvec x[], int nfile, diff --git a/src/gromacs/listed_forces/disre.cpp b/src/gromacs/listed_forces/disre.cpp index b5630b4aeb..8a901875c7 100644 --- a/src/gromacs/listed_forces/disre.cpp +++ b/src/gromacs/listed_forces/disre.cpp @@ -70,7 +70,7 @@ #include "gromacs/utility/smalloc.h" void init_disres(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, t_inputrec* ir, DisResRunMode disResRunMode, DDRole ddRole, @@ -157,7 +157,7 @@ void init_disres(FILE* fplog, type = (*il)[F_DISRES].iatoms[fa]; np++; - npair = mtop->ffparams.iparams[type].disres.npair; + npair = mtop.ffparams.iparams[type].disres.npair; if (np == npair) { dd->nres += (ir->eDisre == DistanceRestraintRefinement::Ensemble ? 1 : nmol); diff --git a/src/gromacs/listed_forces/disre.h b/src/gromacs/listed_forces/disre.h index 7d885ab944..34aaba06b7 100644 --- a/src/gromacs/listed_forces/disre.h +++ b/src/gromacs/listed_forces/disre.h @@ -88,7 +88,7 @@ enum class DisResRunMode * must differ according to whether REMD is active. */ void init_disres(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, t_inputrec* ir, DisResRunMode disResRunMode, DDRole ddRole, diff --git a/src/gromacs/listed_forces/orires.cpp b/src/gromacs/listed_forces/orires.cpp index be62d1139b..26de7b7725 100644 --- a/src/gromacs/listed_forces/orires.cpp +++ b/src/gromacs/listed_forces/orires.cpp @@ -70,7 +70,7 @@ using gmx::RVec; // a user can't just do multi-sim with single-sim orientation restraints. void init_orires(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_inputrec* ir, const t_commrec* cr, const gmx_multisim_t* ms, @@ -141,7 +141,7 @@ void init_orires(FILE* fplog, for (int i = 0; i < numOrires; i += 3) { int type = (*il)[F_ORIRES].iatoms[i]; - int ex = mtop->ffparams.iparams[type].orires.ex; + int ex = mtop.ffparams.iparams[type].orires.ex; if (ex >= od->nex) { srenew(nr_ex, ex + 1); @@ -220,9 +220,9 @@ void init_orires(FILE* fplog, snew(od->tmpEq, od->nex); od->nref = 0; - for (int i = 0; i < mtop->natoms; i++) + for (int i = 0; i < mtop.natoms; i++) { - if (getGroupType(mtop->groups, SimulationAtomGroupType::OrientationRestraintsFit, i) == 0) + if (getGroupType(mtop.groups, SimulationAtomGroupType::OrientationRestraintsFit, i) == 0) { od->nref++; } @@ -241,12 +241,12 @@ void init_orires(FILE* fplog, rvec com = { 0, 0, 0 }; double mtot = 0.0; int j = 0; - for (const AtomProxy atomP : AtomRange(*mtop)) + for (const AtomProxy atomP : AtomRange(mtop)) { const t_atom& local = atomP.atom(); int i = atomP.globalAtomNumber(); - if (mtop->groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit].empty() - || mtop->groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit][i] == 0) + if (mtop.groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit].empty() + || mtop.groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit][i] == 0) { /* Not correct for free-energy with changing masses */ od->mref[j] = local.m; diff --git a/src/gromacs/listed_forces/orires.h b/src/gromacs/listed_forces/orires.h index bff4c3102f..981cbed67e 100644 --- a/src/gromacs/listed_forces/orires.h +++ b/src/gromacs/listed_forces/orires.h @@ -76,7 +76,7 @@ class ArrayRef; * restraints can not run in parallel). */ void init_orires(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_inputrec* ir, const t_commrec* cr, const gmx_multisim_t* ms, diff --git a/src/gromacs/mdlib/dispersioncorrection.cpp b/src/gromacs/mdlib/dispersioncorrection.cpp index 2c8976f89a..4494d09f68 100644 --- a/src/gromacs/mdlib/dispersioncorrection.cpp +++ b/src/gromacs/mdlib/dispersioncorrection.cpp @@ -150,7 +150,7 @@ DispersionCorrection::TopologyParams::TopologyParams(const gmx_mtop_t& m /* Count the types so we avoid natoms^2 operations */ std::vector typecount(ntp); - gmx_mtop_count_atomtypes(&mtop, q, typecount.data()); + gmx_mtop_count_atomtypes(mtop, q, typecount.data()); for (int tpi = 0; tpi < ntp; tpi++) { diff --git a/src/gromacs/mdlib/mdatoms.cpp b/src/gromacs/mdlib/mdatoms.cpp index 22c1094e9c..025634b9d8 100644 --- a/src/gromacs/mdlib/mdatoms.cpp +++ b/src/gromacs/mdlib/mdatoms.cpp @@ -147,7 +147,7 @@ std::unique_ptr makeMDAtoms(FILE* fp, const gmx_mtop_t& mtop, const t_i double totalMassB = 0.0; md->haveVsites = FALSE; - gmx_mtop_atomloop_block_t aloop = gmx_mtop_atomloop_block_init(&mtop); + gmx_mtop_atomloop_block_t aloop = gmx_mtop_atomloop_block_init(mtop); const t_atom* atom; int nmol; while (gmx_mtop_atomloop_block_next(aloop, &atom, &nmol)) @@ -201,7 +201,7 @@ std::unique_ptr makeMDAtoms(FILE* fp, const gmx_mtop_t& mtop, const t_i } } - md->bOrires = (gmx_mtop_ftype_count(&mtop, F_ORIRES) != 0); + md->bOrires = (gmx_mtop_ftype_count(mtop, F_ORIRES) != 0); return mdAtoms; } @@ -340,7 +340,7 @@ void atoms2md(const gmx_mtop_t& mtop, { ag = index[i]; } - const t_atom& atom = mtopGetAtomParameters(&mtop, ag, &molb); + const t_atom& atom = mtopGetAtomParameters(mtop, ag, &molb); if (md->cFREEZE) { diff --git a/src/gromacs/mdlib/mdoutf.cpp b/src/gromacs/mdlib/mdoutf.cpp index 89b70e0f1b..ee2335ddf7 100644 --- a/src/gromacs/mdlib/mdoutf.cpp +++ b/src/gromacs/mdlib/mdoutf.cpp @@ -108,7 +108,7 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, gmx::IMDOutputProvider* outputProvider, const gmx::MdModulesNotifier& mdModulesNotifier, const t_inputrec* ir, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const gmx_output_env_t* oenv, gmx_wallcycle_t wcycle, const gmx::StartingBehavior startingBehavior, @@ -164,7 +164,7 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, gmx_tng_open(filename, filemode[0], &of->tng_low_prec); if (filemode[0] == 'w') { - gmx_tng_prepare_low_prec_writing(of->tng_low_prec, top_global, ir); + gmx_tng_prepare_low_prec_writing(of->tng_low_prec, &top_global, ir); } bCiteTng = TRUE; break; @@ -193,7 +193,7 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, gmx_tng_open(filename, filemode[0], &of->tng); if (filemode[0] == 'w') { - gmx_tng_prepare_md_writing(of->tng, top_global, ir); + gmx_tng_prepare_md_writing(of->tng, &top_global, ir); } bCiteTng = TRUE; break; @@ -226,10 +226,10 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, trajectory-writing routines later. Also, XTC writing needs to know what (and how many) atoms might be in the XTC groups, and how to look up later which ones they are. */ - of->natoms_global = top_global->natoms; - of->groups = &top_global->groups; + of->natoms_global = top_global.natoms; + of->groups = &top_global.groups; of->natoms_x_compressed = 0; - for (i = 0; (i < top_global->natoms); i++) + for (i = 0; (i < top_global.natoms); i++) { if (getGroupType(*of->groups, SimulationAtomGroupType::CompressedPositionOutput, i) == 0) { @@ -239,7 +239,7 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, if (ir->nstfout && DOMAINDECOMP(cr)) { - snew(of->f_global, top_global->natoms); + snew(of->f_global, top_global.natoms); } } diff --git a/src/gromacs/mdlib/mdoutf.h b/src/gromacs/mdlib/mdoutf.h index 88ef9068bf..d727d89474 100644 --- a/src/gromacs/mdlib/mdoutf.h +++ b/src/gromacs/mdlib/mdoutf.h @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2013,2014,2015,2016,2017 The GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -77,7 +77,7 @@ gmx_mdoutf_t init_mdoutf(FILE* fplog, gmx::IMDOutputProvider* outputProvider, const gmx::MdModulesNotifier& mdModulesNotifier, const t_inputrec* ir, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const gmx_output_env_t* oenv, gmx_wallcycle_t wcycle, gmx::StartingBehavior startingBehavior, diff --git a/src/gromacs/mdlib/membed.cpp b/src/gromacs/mdlib/membed.cpp index 61e676c338..1456ae6c9c 100644 --- a/src/gromacs/mdlib/membed.cpp +++ b/src/gromacs/mdlib/membed.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -109,7 +109,7 @@ typedef struct /* Get the global molecule id, and the corresponding molecule type and id of the * * molblock from the global atom nr. */ -static int get_mol_id(int at, gmx_mtop_t* mtop, int* type, int* block) +static int get_mol_id(int at, const gmx_mtop_t& mtop, int* type, int* block) { int mol_id = 0; int i; @@ -119,9 +119,9 @@ static int get_mol_id(int at, gmx_mtop_t* mtop, int* type, int* block) mtopGetMolblockIndex(mtop, at, block, &mol_id, &atnr_mol); for (i = 0; i < *block; i++) { - mol_id += mtop->molblock[i].nmol; + mol_id += mtop.molblock[i].nmol; } - *type = mtop->molblock[*block].type; + *type = mtop.molblock[*block].type; return mol_id; } @@ -148,7 +148,7 @@ static int get_molblock(int mol_id, const std::vector& mblock) * level, if the same molecule type is found in another part of the system, these * * would also be affected. Therefore we have to check if the embedded and rest group * * share common molecule types. If so, membed will stop with an error. */ -static int get_mtype_list(t_block* at, gmx_mtop_t* mtop, t_block* tlist) +static int get_mtype_list(t_block* at, const gmx_mtop_t& mtop, t_block* tlist) { int i, j, nr; int type = 0, block = 0; @@ -179,7 +179,7 @@ static int get_mtype_list(t_block* at, gmx_mtop_t* mtop, t_block* tlist) } /* Do the actual check of the molecule types between embedded and rest group */ -static void check_types(t_block* ins_at, t_block* rest_at, gmx_mtop_t* mtop) +static void check_types(t_block* ins_at, t_block* rest_at, const gmx_mtop_t& mtop) { t_block *ins_mtype, *rest_mtype; int i, j; @@ -209,9 +209,9 @@ static void check_types(t_block* ins_at, t_block* rest_at, gmx_mtop_t* mtop) "moleculetype of the molecules %s in the inserted group. Do not forget to " "provide\n" "an appropriate *.itp file", - *(mtop->moltype[rest_mtype->index[j]].name), - *(mtop->moltype[rest_mtype->index[j]].name), - *(mtop->moltype[rest_mtype->index[j]].name)); + *(mtop.moltype[rest_mtype->index[j]].name), + *(mtop.moltype[rest_mtype->index[j]].name), + *(mtop.moltype[rest_mtype->index[j]].name)); } } } @@ -381,7 +381,7 @@ static real est_prot_area(pos_ins_t* pos_ins, rvec* r, t_block* ins_at, mem_t* m return area; } -static int init_mem_at(mem_t* mem_p, gmx_mtop_t* mtop, rvec* r, matrix box, pos_ins_t* pos_ins) +static int init_mem_at(mem_t* mem_p, const gmx_mtop_t& mtop, rvec* r, matrix box, pos_ins_t* pos_ins) { int i, j, at, mol, nmol, nmolbox, count; t_block* mem_a; @@ -454,7 +454,7 @@ static int init_mem_at(mem_t* mem_p, gmx_mtop_t* mtop, rvec* r, matrix box, pos_ mem_p->zmed = (zmax - zmin) / 2 + zmin; /*number of membrane molecules in protein box*/ - nmolbox = count / mtop->moltype[mtop->molblock[block].type].atoms.nr; + nmolbox = count / mtop.moltype[mtop.molblock[block].type].atoms.nr; /*membrane area within the box defined by the min and max coordinates of the embedded molecule*/ mem_area = (pos_ins->xmax[XX] - pos_ins->xmin[XX]) * (pos_ins->xmax[YY] - pos_ins->xmin[YY]); /*rough estimate of area per lipid, assuming there is only one type of lipid in the membrane*/ @@ -546,17 +546,17 @@ static void resize(rvec* r_ins, rvec* r, pos_ins_t* pos_ins, const rvec fac) /* generate the list of membrane molecules that overlap with the molecule to be embedded. * * The molecule to be embedded is already reduced in size. */ -static int gen_rm_list(rm_t* rm_p, - t_block* ins_at, - t_block* rest_at, - t_pbc* pbc, - gmx_mtop_t* mtop, - rvec* r, - mem_t* mem_p, - pos_ins_t* pos_ins, - real probe_rad, - int low_up_rm, - gmx_bool bALLOW_ASYMMETRY) +static int gen_rm_list(rm_t* rm_p, + t_block* ins_at, + t_block* rest_at, + t_pbc* pbc, + const gmx_mtop_t& mtop, + rvec* r, + mem_t* mem_p, + pos_ins_t* pos_ins, + real probe_rad, + int low_up_rm, + gmx_bool bALLOW_ASYMMETRY) { int i, j, k, l, at, at2, mol_id; int type = 0, block = 0; @@ -568,7 +568,7 @@ static int gen_rm_list(rm_t* rm_p, int* order; r_min_rad = probe_rad * probe_rad; - gmx::RangePartitioning molecules = gmx_mtop_molecules(*mtop); + gmx::RangePartitioning molecules = gmx_mtop_molecules(mtop); snew(rm_p->block, molecules.numBlocks()); snew(rm_p->mol, molecules.numBlocks()); nrm = nupper = 0; @@ -660,7 +660,7 @@ static int gen_rm_list(rm_t* rm_p, while (nupper != nlower) { mol_id = mem_p->mol_id[order[i]]; - block = get_molblock(mol_id, mtop->molblock); + block = get_molblock(mol_id, mtop.molblock); bRM = TRUE; for (l = 0; l < nrm; l++) { @@ -1110,7 +1110,7 @@ gmx_membed_t* init_membed(FILE* fplog, gnames.emplace_back(*groupName); } - atoms = gmx_mtop_global_atoms(mtop); + atoms = gmx_mtop_global_atoms(*mtop); snew(mem_p, 1); fprintf(stderr, "\nSelect a group to embed in the membrane:\n"); get_index(&atoms, opt2fn_null("-mn", nfile, fnm), 1, &(ins_at->nr), &(ins_at->index), &ins); @@ -1276,9 +1276,9 @@ gmx_membed_t* init_membed(FILE* fplog, snew(rest_at, 1); init_ins_at(ins_at, rest_at, state, pos_ins, groups, ins_grp_id, xy_max); /* Check that moleculetypes in insertion group are not part of the rest of the system */ - check_types(ins_at, rest_at, mtop); + check_types(ins_at, rest_at, *mtop); - init_mem_at(mem_p, mtop, state->x.rvec_array(), state->box, pos_ins); + init_mem_at(mem_p, *mtop, state->x.rvec_array(), state->box, pos_ins); prot_area = est_prot_area(pos_ins, state->x.rvec_array(), ins_at, mem_p); if ((prot_area > prot_vs_box) @@ -1341,7 +1341,7 @@ gmx_membed_t* init_membed(FILE* fplog, snew(rm_p, 1); lip_rm = gen_rm_list( - rm_p, ins_at, rest_at, pbc, mtop, state->x.rvec_array(), mem_p, pos_ins, probe_rad, low_up_rm, bALLOW_ASYMMETRY); + rm_p, ins_at, rest_at, pbc, *mtop, state->x.rvec_array(), mem_p, pos_ins, probe_rad, low_up_rm, bALLOW_ASYMMETRY); lip_rm -= low_up_rm; if (fplog) diff --git a/src/gromacs/mdlib/trajectory_writing.cpp b/src/gromacs/mdlib/trajectory_writing.cpp index 405174ef7f..a7787ea97d 100644 --- a/src/gromacs/mdlib/trajectory_writing.cpp +++ b/src/gromacs/mdlib/trajectory_writing.cpp @@ -66,7 +66,7 @@ void do_md_trajectory_writing(FILE* fplog, t_state* state, t_state* state_global, ObservablesHistory* observablesHistory, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, t_forcerec* fr, gmx_mdoutf_t outf, const gmx::EnergyOutput& energyOutput, @@ -147,7 +147,7 @@ void do_md_trajectory_writing(FILE* fplog, // This duplication is needed while both legacy and modular code paths are in use. // TODO: Remove duplication asap, make sure to keep in sync in the meantime. mdoutf_write_to_trajectory_files( - fplog, cr, outf, mdof_flags, top_global->natoms, step, t, state, state_global, observablesHistory, f, &checkpointDataHolder); + fplog, cr, outf, mdof_flags, top_global.natoms, step, t, state, state_global, observablesHistory, f, &checkpointDataHolder); if (bLastStep && step_rel == ir->nsteps && bDoConfOut && MASTER(cr) && !bRerunMD) { if (fr->bMolPBC && state == state_global) @@ -177,10 +177,10 @@ void do_md_trajectory_writing(FILE* fplog, if (fr->bMolPBC && !ir->bPeriodicMols) { /* Make molecules whole only for confout writing */ - do_pbc_mtop(ir->pbcType, state->box, top_global, x_for_confout); + do_pbc_mtop(ir->pbcType, state->box, &top_global, x_for_confout); } write_sto_conf_mtop(ftp2fn(efSTO, nfile, fnm), - *top_global->name, + *top_global.name, top_global, x_for_confout, state_global->v.rvec_array(), diff --git a/src/gromacs/mdlib/trajectory_writing.h b/src/gromacs/mdlib/trajectory_writing.h index bb2da64383..5d60396834 100644 --- a/src/gromacs/mdlib/trajectory_writing.h +++ b/src/gromacs/mdlib/trajectory_writing.h @@ -71,7 +71,7 @@ void do_md_trajectory_writing(FILE* fplog, t_state* state, t_state* state_global, ObservablesHistory* observablesHistory, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, t_forcerec* fr, gmx_mdoutf_t outf, const gmx::EnergyOutput& energyOutput, diff --git a/src/gromacs/mdlib/update_vv.cpp b/src/gromacs/mdlib/update_vv.cpp index b1d3b76c69..aec700bce9 100644 --- a/src/gromacs/mdlib/update_vv.cpp +++ b/src/gromacs/mdlib/update_vv.cpp @@ -83,7 +83,7 @@ void integrateVVFirstStep(int64_t step, const t_fcdata& fcdata, t_extmass* MassQ, t_vcm* vcm, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const gmx_localtop_t& top, gmx_enerdata_t* enerd, gmx_ekindata_t* ekind, @@ -204,7 +204,7 @@ void integrateVVFirstStep(int64_t step, checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, diff --git a/src/gromacs/mdlib/update_vv.h b/src/gromacs/mdlib/update_vv.h index 9c56cf4927..71beb39db5 100644 --- a/src/gromacs/mdlib/update_vv.h +++ b/src/gromacs/mdlib/update_vv.h @@ -131,7 +131,7 @@ void integrateVVFirstStep(int64_t step, const t_fcdata& fcdata, t_extmass* MassQ, t_vcm* vcm, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const gmx_localtop_t& top, gmx_enerdata_t* enerd, gmx_ekindata_t* ekind, diff --git a/src/gromacs/mdlib/updategroupscog.cpp b/src/gromacs/mdlib/updategroupscog.cpp index 2739a398bc..58cfb7d8ae 100644 --- a/src/gromacs/mdlib/updategroupscog.cpp +++ b/src/gromacs/mdlib/updategroupscog.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2021, 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. @@ -95,7 +95,7 @@ void UpdateGroupsCog::addCogs(gmx::ArrayRef globalAtomIndices, const int globalAtom = globalAtomIndices[localAtom]; int moleculeIndex; int atomIndexInMolecule; - mtopGetMolblockIndex(&mtop_, globalAtom, &moleculeBlock, &moleculeIndex, &atomIndexInMolecule); + mtopGetMolblockIndex(mtop_, globalAtom, &moleculeBlock, &moleculeIndex, &atomIndexInMolecule); const auto& indicesForBlock = indicesPerMoleculeblock_[moleculeBlock]; int globalUpdateGroupIndex = indicesForBlock.groupStart_ + moleculeIndex * indicesForBlock.numGroupsPerMolecule_ diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index 44c57af644..adcf0ea8d6 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -2587,7 +2587,7 @@ std::unique_ptr makeVirtualSitesHandler(const gmx_mtop_t& m GMX_ASSERT(ftype >= c_ftypeVsiteStart && ftype < c_ftypeVsiteEnd, "c_ftypeVsiteStart and/or c_ftypeVsiteEnd do not have correct values"); - nvsite += gmx_mtop_ftype_count(&mtop, ftype); + nvsite += gmx_mtop_ftype_count(mtop, ftype); } else { diff --git a/src/gromacs/mdrun/isimulator.h b/src/gromacs/mdrun/isimulator.h index e6957b97fb..6e9c6c6149 100644 --- a/src/gromacs/mdrun/isimulator.h +++ b/src/gromacs/mdrun/isimulator.h @@ -128,7 +128,7 @@ public: ImdSession* imdSession, pull_t* pull_work, t_swap* swap, - gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, t_state* state_global, ObservablesHistory* observablesHistory, MDAtoms* mdAtoms, @@ -219,7 +219,7 @@ public: //! The coordinate-swapping session. t_swap* swap; //! Full system topology. - const gmx_mtop_t* top_global; + const gmx_mtop_t& top_global; //! Full simulation state (only non-nullptr on master rank). t_state* state_global; //! History of simulation observables. diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index cb086641f4..6f1409031c 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -238,7 +238,7 @@ void gmx::LegacySimulator::do_md() int nstglobalcomm = computeGlobalCommunicationPeriod(mdlog, ir, cr); bGStatEveryStep = (nstglobalcomm == 1); - const SimulationGroups* groups = &top_global->groups; + const SimulationGroups* groups = &top_global.groups; std::unique_ptr ed = nullptr; if (opt2bSet("-ei", nfile, fnm)) @@ -247,7 +247,7 @@ void gmx::LegacySimulator::do_md() ed = init_edsam(mdlog, opt2fn_null("-ei", nfile, fnm), opt2fn("-eo", nfile, fnm), - *top_global, + top_global, *ir, cr, constr, @@ -325,7 +325,7 @@ void gmx::LegacySimulator::do_md() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *ir, pull_work, mdoutf_get_fp_dhdl(outf), @@ -351,7 +351,7 @@ void gmx::LegacySimulator::do_md() useGpuForPme); { - double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1); + double io = compute_io(ir, top_global.natoms, *groups, energyOutput.numEnergyTerms(), 1); if ((io > 2000) && MASTER(cr)) { fprintf(stderr, "\nWARNING: This run will generate roughly %.0f Mb of data\n\n", io); @@ -362,7 +362,7 @@ void gmx::LegacySimulator::do_md() std::unique_ptr stateInstance; t_state* state; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); auto mdatoms = mdAtoms->mdatoms(); @@ -384,7 +384,7 @@ void gmx::LegacySimulator::do_md() TRUE, 1, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -408,7 +408,7 @@ void gmx::LegacySimulator::do_md() state = state_global; /* Generate and initialize new topology */ - mdAlgorithmsSetupAtomData(cr, *ir, *top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); + mdAlgorithmsSetupAtomData(cr, *ir, top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); upd.setNumAtoms(state->natoms); } @@ -450,7 +450,7 @@ void gmx::LegacySimulator::do_md() "Orientation restraints are not supported with the GPU update.\n"); GMX_RELEASE_ASSERT( ir->efep == FreeEnergyPerturbationType::No - || (!haveFepPerturbedMasses(*top_global) && !havePerturbedConstraints(*top_global)), + || (!haveFepPerturbedMasses(top_global) && !havePerturbedConstraints(top_global)), "Free energy perturbation of masses and constraints are not supported with the GPU " "update."); @@ -473,7 +473,7 @@ void gmx::LegacySimulator::do_md() "update-constraints."); integrator = std::make_unique( *ir, - *top_global, + top_global, ekind->ngtc, fr->deviceStreamManager->context(), fr->deviceStreamManager->stream(gmx::DeviceStreamType::UpdateAndConstraints), @@ -531,7 +531,7 @@ void gmx::LegacySimulator::do_md() if (useReplicaExchange && MASTER(cr)) { - repl_ex = init_replica_exchange(fplog, ms, top_global->natoms, ir, replExParams); + repl_ex = init_replica_exchange(fplog, ms, top_global.natoms, ir, replExParams); } /* PME tuning is only supported in the Verlet scheme, with PME for * Coulomb. It is not supported with only LJ PME. */ @@ -636,7 +636,7 @@ void gmx::LegacySimulator::do_md() bSumEkinhOld = FALSE; - t_vcm vcm(top_global->groups, *ir); + t_vcm vcm(top_global.groups, *ir); reportComRemovalInfo(fplog, vcm); /* To minimize communication, compute_globals computes the COM velocity @@ -692,7 +692,7 @@ void gmx::LegacySimulator::do_md() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -768,7 +768,7 @@ void gmx::LegacySimulator::do_md() } char tbuf[20]; - fprintf(stderr, "starting mdrun '%s'\n", *(top_global->name)); + fprintf(stderr, "starting mdrun '%s'\n", *(top_global.name)); if (ir->nsteps >= 0) { sprintf(tbuf, "%8.1f", (ir->init_step + ir->nsteps) * ir->delta_t); @@ -1002,7 +1002,7 @@ void gmx::LegacySimulator::do_md() bMasterState, nstglobalcomm, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -1072,7 +1072,7 @@ void gmx::LegacySimulator::do_md() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -1648,7 +1648,7 @@ void gmx::LegacySimulator::do_md() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -1891,7 +1891,7 @@ void gmx::LegacySimulator::do_md() TRUE, 1, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, diff --git a/src/gromacs/mdrun/mimic.cpp b/src/gromacs/mdrun/mimic.cpp index a55cb245d1..f64a8c3e5d 100644 --- a/src/gromacs/mdrun/mimic.cpp +++ b/src/gromacs/mdrun/mimic.cpp @@ -218,7 +218,7 @@ void gmx::LegacySimulator::do_mimic() if (MASTER(cr)) { MimicCommunicator::init(); - auto nonConstGlobalTopology = const_cast(top_global); + auto nonConstGlobalTopology = const_cast(&top_global); MimicCommunicator::sendInitData(nonConstGlobalTopology, state_global->x); // TODO: Avoid changing inputrec (#3854) auto* nonConstInputrec = const_cast(inputrec); @@ -231,10 +231,10 @@ void gmx::LegacySimulator::do_mimic() gmx_bcast(sizeof(ir->nsteps), &nonConstInputrec->nsteps, cr->mpi_comm_mygroup); } - const SimulationGroups* groups = &top_global->groups; + const SimulationGroups* groups = &top_global.groups; { - auto nonConstGlobalTopology = const_cast(top_global); - nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(*top_global); + auto nonConstGlobalTopology = const_cast(&top_global); + nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(top_global); } initialize_lambdas(fplog, *ir, MASTER(cr), &state_global->fep_state, state_global->lambda); @@ -255,7 +255,7 @@ void gmx::LegacySimulator::do_mimic() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *ir, pull_work, mdoutf_get_fp_dhdl(outf), @@ -275,7 +275,7 @@ void gmx::LegacySimulator::do_mimic() runScheduleWork->simulationWork.useGpuPme); { - double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1); + double io = compute_io(ir, top_global.natoms, *groups, energyOutput.numEnergyTerms(), 1); if ((io > 2000) && MASTER(cr)) { fprintf(stderr, "\nWARNING: This run will generate roughly %.0f Mb of data\n\n", io); @@ -286,7 +286,7 @@ void gmx::LegacySimulator::do_mimic() std::unique_ptr stateInstance; t_state* state; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); if (DOMAINDECOMP(cr)) { @@ -302,7 +302,7 @@ void gmx::LegacySimulator::do_mimic() TRUE, 1, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -324,7 +324,7 @@ void gmx::LegacySimulator::do_mimic() /* Copy the pointer to the global state */ state = state_global; - mdAlgorithmsSetupAtomData(cr, *ir, *top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); + mdAlgorithmsSetupAtomData(cr, *ir, top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); } auto mdatoms = mdAtoms->mdatoms(); @@ -374,7 +374,7 @@ void gmx::LegacySimulator::do_mimic() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -382,7 +382,7 @@ void gmx::LegacySimulator::do_mimic() if (MASTER(cr)) { - fprintf(stderr, "starting MiMiC MD run '%s'\n\n", *(top_global->name)); + fprintf(stderr, "starting MiMiC MD run '%s'\n\n", *(top_global.name)); if (mdrunOptions.verbose) { fprintf(stderr, @@ -488,7 +488,7 @@ void gmx::LegacySimulator::do_mimic() bMasterState, nstglobalcomm, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -662,7 +662,7 @@ void gmx::LegacySimulator::do_mimic() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -670,7 +670,7 @@ void gmx::LegacySimulator::do_mimic() } { - gmx::HostVector fglobal(top_global->natoms); + gmx::HostVector fglobal(top_global.natoms); gmx::ArrayRef ftemp; gmx::ArrayRef flocal = f.view().force(); if (DOMAINDECOMP(cr)) diff --git a/src/gromacs/mdrun/minimize.cpp b/src/gromacs/mdrun/minimize.cpp index 71ea473d50..33b067bde1 100644 --- a/src/gromacs/mdrun/minimize.cpp +++ b/src/gromacs/mdrun/minimize.cpp @@ -370,7 +370,7 @@ static void init_em(FILE* fplog, gmx::ImdSession* imdSession, pull_t* pull_work, t_state* state_global, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, em_state_t* ems, gmx_localtop_t* top, t_nrnb* nrnb, @@ -434,7 +434,7 @@ static void init_em(FILE* fplog, TRUE, 1, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -458,7 +458,7 @@ static void init_em(FILE* fplog, state_change_natoms(&ems->s, ems->s.natoms); mdAlgorithmsSetupAtomData( - cr, *ir, *top_global, top, fr, &ems->f, mdAtoms, constr, vsite, shellfc ? *shellfc : nullptr); + cr, *ir, top_global, top, fr, &ems->f, mdAtoms, constr, vsite, shellfc ? *shellfc : nullptr); } update_mdatoms(mdAtoms->mdatoms(), ems->s.lambda[FreeEnergyPerturbationCouplingType::Mass]); @@ -545,7 +545,7 @@ static void write_em_traj(FILE* fplog, gmx_bool bX, gmx_bool bF, const char* confout, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const t_inputrec* ir, int64_t step, em_state_t* state, @@ -574,7 +574,7 @@ static void write_em_traj(FILE* fplog, cr, outf, mdof_flags, - top_global->natoms, + top_global.natoms, step, static_cast(step), &state->s, @@ -606,11 +606,11 @@ static void write_em_traj(FILE* fplog, if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && DOMAINDECOMP(cr)) { /* Make molecules whole only for confout writing */ - do_pbc_mtop(ir->pbcType, state->s.box, top_global, state_global->x.rvec_array()); + do_pbc_mtop(ir->pbcType, state->s.box, &top_global, state_global->x.rvec_array()); } write_sto_conf_mtop(confout, - *top_global->name, + *top_global.name, top_global, state_global->x.rvec_array(), nullptr, @@ -781,7 +781,7 @@ static void em_dd_partition_system(FILE* fplog, const gmx::MDLogger& mdlog, int step, const t_commrec* cr, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const t_inputrec* ir, gmx::ImdSession* imdSession, pull_t* pull_work, @@ -802,7 +802,7 @@ static void em_dd_partition_system(FILE* fplog, FALSE, 1, nullptr, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -855,7 +855,7 @@ public: //! Coordinates multi-simulations. const gmx_multisim_t* ms; //! Holds the simulation topology. - const gmx_mtop_t* top_global; + const gmx_mtop_t& top_global; //! Holds the domain topology. gmx_localtop_t* top; //! User input options. @@ -1050,7 +1050,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres, //! Parallel utility summing energies and forces static double reorder_partsum(const t_commrec* cr, const t_grpopts* opts, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const em_state_t* s_min, const em_state_t* s_b) { @@ -1066,7 +1066,7 @@ static double reorder_partsum(const t_commrec* cr, * This conflicts with the spirit of domain decomposition, * but to fully optimize this a much more complicated algorithm is required. */ - const int natoms = top_global->natoms; + const int natoms = top_global.natoms; rvec* fmg; snew(fmg, natoms); @@ -1077,7 +1077,7 @@ static double reorder_partsum(const t_commrec* cr, copy_rvec(fm[i], fmg[a]); i++; } - gmx_sum(top_global->natoms * 3, fmg[0], cr); + gmx_sum(top_global.natoms * 3, fmg[0], cr); /* Now we will determine the part of the sum for the cgs in state s_b */ gmx::ArrayRef indicesB = s_b->s.cg_gl; @@ -1086,7 +1086,7 @@ static double reorder_partsum(const t_commrec* cr, i = 0; int gf = 0; gmx::ArrayRef grpnrFREEZE = - top_global->groups.groupNumbers[SimulationAtomGroupType::Freeze]; + top_global.groups.groupNumbers[SimulationAtomGroupType::Freeze]; for (int a : indicesB) { if (!grpnrFREEZE.empty()) @@ -1112,7 +1112,7 @@ static double reorder_partsum(const t_commrec* cr, static real pr_beta(const t_commrec* cr, const t_grpopts* opts, t_mdatoms* mdatoms, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const em_state_t* s_min, const em_state_t* s_b) { @@ -1168,7 +1168,7 @@ void LegacySimulator::do_cg() { const char* CG = "Polak-Ribiere Conjugate Gradients"; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); gmx_global_stat_t gstat; double tmp, minstep; real stepsize; @@ -1250,7 +1250,7 @@ void LegacySimulator::do_cg() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *inputrec, pull_work, nullptr, @@ -1415,7 +1415,7 @@ void LegacySimulator::do_cg() gmx_sumd(1, &minstep, cr); } - minstep = GMX_REAL_EPS / sqrt(minstep / (3 * top_global->natoms)); + minstep = GMX_REAL_EPS / sqrt(minstep / (3 * top_global.natoms)); if (stepsize < minstep) { @@ -1870,7 +1870,7 @@ void LegacySimulator::do_lbfgs() { static const char* LBFGS = "Low-Memory BFGS Minimizer"; em_state_t ems; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); gmx_global_stat_t gstat; int ncorr, nmaxcorr, point, cp, neval, nminstep; double stepsize, step_taken, gpa, gpb, gpc, tmp, minstep; @@ -1967,7 +1967,7 @@ void LegacySimulator::do_lbfgs() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *inputrec, pull_work, nullptr, @@ -2142,7 +2142,7 @@ void LegacySimulator::do_lbfgs() cr, outf, mdof_flags, - top_global->natoms, + top_global.natoms, step, static_cast(step), &ems.s, @@ -2675,7 +2675,7 @@ void LegacySimulator::do_lbfgs() void LegacySimulator::do_steep() { const char* SD = "Steepest Descents"; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); gmx_global_stat_t gstat; real stepsize; real ustep; @@ -2735,7 +2735,7 @@ void LegacySimulator::do_steep() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *inputrec, pull_work, nullptr, @@ -2992,7 +2992,7 @@ void LegacySimulator::do_nm() { const char* NM = "Normal Mode Analysis"; int nnodes; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); gmx_global_stat_t gstat; tensor vir, pres; rvec mu_tot = { 0 }; @@ -3132,7 +3132,7 @@ void LegacySimulator::do_nm() { fprintf(stderr, "starting normal mode calculation '%s'\n%" PRId64 " steps.\n\n", - *(top_global->name), + *(top_global.name), inputrec->nsteps); } diff --git a/src/gromacs/mdrun/rerun.cpp b/src/gromacs/mdrun/rerun.cpp index a73f407dc7..8b11f9630e 100644 --- a/src/gromacs/mdrun/rerun.cpp +++ b/src/gromacs/mdrun/rerun.cpp @@ -181,7 +181,7 @@ void gmx::LegacySimulator::do_rerun() t_trxstatus* status = nullptr; rvec mu_tot; t_trxframe rerun_fr; - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); ForceBuffers f; gmx_global_stat_t gstat; gmx_shellfc_t* shellfc; @@ -276,11 +276,11 @@ void gmx::LegacySimulator::do_rerun() int nstglobalcomm = 1; const bool bNS = true; - const SimulationGroups* groups = &top_global->groups; + const SimulationGroups* groups = &top_global.groups; if (ir->eI == IntegrationAlgorithm::Mimic) { - auto nonConstGlobalTopology = const_cast(top_global); - nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(*top_global); + auto nonConstGlobalTopology = const_cast(&top_global); + nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(top_global); } int* fep_state = MASTER(cr) ? &state_global->fep_state : nullptr; gmx::ArrayRef lambda = MASTER(cr) ? state_global->lambda : gmx::ArrayRef(); @@ -301,7 +301,7 @@ void gmx::LegacySimulator::do_rerun() simulationsShareState, ms); gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), - *top_global, + top_global, *ir, pull_work, mdoutf_get_fp_dhdl(outf), @@ -321,7 +321,7 @@ void gmx::LegacySimulator::do_rerun() runScheduleWork->simulationWork.useGpuPme); { - double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1); + double io = compute_io(ir, top_global.natoms, *groups, energyOutput.numEnergyTerms(), 1); if ((io > 2000) && MASTER(cr)) { fprintf(stderr, "\nWARNING: This run will generate roughly %.0f Mb of data\n\n", io); @@ -346,7 +346,7 @@ void gmx::LegacySimulator::do_rerun() TRUE, 1, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -368,7 +368,7 @@ void gmx::LegacySimulator::do_rerun() /* Copy the pointer to the global state */ state = state_global; - mdAlgorithmsSetupAtomData(cr, *ir, *top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); + mdAlgorithmsSetupAtomData(cr, *ir, top_global, &top, fr, &f, mdAtoms, constr, vsite, shellfc); } auto mdatoms = mdAtoms->mdatoms(); @@ -418,7 +418,7 @@ void gmx::LegacySimulator::do_rerun() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, @@ -429,7 +429,7 @@ void gmx::LegacySimulator::do_rerun() fprintf(stderr, "starting md rerun '%s', reading coordinates from" " input trajectory '%s'\n\n", - *(top_global->name), + *(top_global.name), opt2fn("-rerun", nfile, fnm)); if (mdrunOptions.verbose) { @@ -462,13 +462,13 @@ void gmx::LegacySimulator::do_rerun() if (MASTER(cr)) { isLastStep = !read_first_frame(oenv, &status, opt2fn("-rerun", nfile, fnm), &rerun_fr, TRX_NEED_X); - if (rerun_fr.natoms != top_global->natoms) + if (rerun_fr.natoms != top_global.natoms) { gmx_fatal(FARGS, "Number of atoms in trajectory (%d) does not match the " "run input file (%d)\n", rerun_fr.natoms, - top_global->natoms); + top_global.natoms); } if (ir->pbcType != PbcType::No) @@ -598,7 +598,7 @@ void gmx::LegacySimulator::do_rerun() bMasterState, nstglobalcomm, state_global, - *top_global, + top_global, *ir, imdSession, pull_work, @@ -772,7 +772,7 @@ void gmx::LegacySimulator::do_rerun() checkNumberOfBondedInteractions(mdlog, cr, totalNumberOfBondedInteractions, - *top_global, + top_global, &top, makeConstArrayRef(state->x), state->box, diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 8202effc13..681acd27b2 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -413,7 +413,7 @@ static void prepare_verlet_scheme(FILE* fplog, t_commrec* cr, t_inputrec* ir, int nstlist_cmdline, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const matrix box, bool makeGpuPairList, const gmx::CpuInfo& cpuinfo) @@ -445,7 +445,7 @@ static void prepare_verlet_scheme(FILE* fplog, VerletbufListSetup listSetup = verletbufGetSafeListSetup(listType); const real rlist_new = - calcVerletBufferSize(*mtop, det(box), *ir, ir->nstlist, ir->nstlist - 1, -1, listSetup); + calcVerletBufferSize(mtop, det(box), *ir, ir->nstlist, ir->nstlist - 1, -1, listSetup); if (rlist_new != ir->rlist) { @@ -472,7 +472,7 @@ static void prepare_verlet_scheme(FILE* fplog, if (EI_DYNAMICS(ir->eI)) { /* Set or try nstlist values */ - increaseNstlist(fplog, cr, ir, nstlist_cmdline, mtop, box, makeGpuPairList, cpuinfo); + increaseNstlist(fplog, cr, ir, nstlist_cmdline, &mtop, box, makeGpuPairList, cpuinfo); } } @@ -866,7 +866,7 @@ int Mdrunner::mdrunner() useGpuForNonbonded, useGpuForPme, inputrec.get(), - &mtop, + mtop, mdlog, membedHolder.doMembed()); @@ -1132,7 +1132,7 @@ int Mdrunner::mdrunner() t_disresdata* disresdata; snew(disresdata, 1); init_disres(fplog, - &mtop, + mtop, inputrec.get(), DisResRunMode::MDRun, MASTER(cr) ? DDRole::Master : DDRole::Agent, @@ -1145,7 +1145,7 @@ int Mdrunner::mdrunner() t_oriresdata* oriresdata; snew(oriresdata, 1); - init_orires(fplog, &mtop, inputrec.get(), cr, ms, globalState.get(), oriresdata); + init_orires(fplog, mtop, inputrec.get(), cr, ms, globalState.get(), oriresdata); auto deform = prepareBoxDeformation(globalState != nullptr ? globalState->box : box, MASTER(cr) ? DDRole::Master : DDRole::Agent, @@ -1263,7 +1263,7 @@ int Mdrunner::mdrunner() cr, inputrec.get(), nstlist_cmdline, - &mtop, + mtop, box, useGpuForNonbonded || (emulateGpuNonbonded == EmulateGpuNonbonded::Yes), *hwinfo_->cpuInfo); @@ -1806,7 +1806,7 @@ int Mdrunner::mdrunner() pull_work = init_pull(fplog, inputrec->pull.get(), inputrec.get(), - &mtop, + mtop, cr, &atomSets, inputrec->fepvals->init_lambda); @@ -1831,7 +1831,7 @@ int Mdrunner::mdrunner() cr, &atomSets, globalState.get(), - &mtop, + mtop, oenv, mdrunOptions, startingBehavior); @@ -1844,7 +1844,7 @@ int Mdrunner::mdrunner() swap = init_swapcoords(fplog, inputrec.get(), opt2fn_master("-swap", filenames.size(), filenames.data(), cr), - &mtop, + mtop, globalState.get(), &observablesHistory, cr, @@ -1877,7 +1877,7 @@ int Mdrunner::mdrunner() wcycle, &enerd, ms, - &mtop, + mtop, mdlog, MASTER(cr) ? globalState->x.rvec_array() : nullptr, filenames.size(), @@ -1952,7 +1952,7 @@ int Mdrunner::mdrunner() simulatorBuilder.add(CenterOfMassPulling(pull_work)); // Todo move to an MDModule simulatorBuilder.add(IonSwapping(swap)); - simulatorBuilder.add(TopologyData(&mtop, mdAtoms.get())); + simulatorBuilder.add(TopologyData(mtop, mdAtoms.get())); simulatorBuilder.add(BoxDeformationHandle(deform.get())); simulatorBuilder.add(std::move(modularSimulatorCheckpointData)); diff --git a/src/gromacs/mdrun/shellfc.cpp b/src/gromacs/mdrun/shellfc.cpp index dfd8df643c..73c14ac3b5 100644 --- a/src/gromacs/mdrun/shellfc.cpp +++ b/src/gromacs/mdrun/shellfc.cpp @@ -153,20 +153,17 @@ static void pr_shell(FILE* fplog, ArrayRef shells) * started, but even when called, the prediction was always * over-written by a subsequent call in the MD loop, so has been * removed. */ -static void predict_shells(FILE* fplog, - ArrayRef x, - ArrayRef v, - real dt, - ArrayRef shells, - const real mass[], - gmx_mtop_t* mtop, - gmx_bool bInit) +static void predict_shells(FILE* fplog, + ArrayRef x, + ArrayRef v, + real dt, + ArrayRef shells, + gmx::ArrayRef mass, + gmx_bool bInit) { int m, n1, n2, n3; real dt_1, fudge, tm, m1, m2, m3; - GMX_RELEASE_ASSERT(mass || mtop, "Must have masses or a way to look them up"); - /* We introduce a fudge factor for performance reasons: with this choice * the initial force on the shells is about a factor of two lower than * without @@ -189,7 +186,6 @@ static void predict_shells(FILE* fplog, dt_1 = fudge * dt; } - int molb = 0; for (const t_shell& shell : shells) { const int s1 = shell.shellIndex; @@ -209,17 +205,8 @@ static void predict_shells(FILE* fplog, case 2: n1 = shell.nucl1; n2 = shell.nucl2; - if (mass) - { - m1 = mass[n1]; - m2 = mass[n2]; - } - else - { - /* Not the correct masses with FE, but it is just a prediction... */ - m1 = mtopGetAtomMass(mtop, n1, &molb); - m2 = mtopGetAtomMass(mtop, n2, &molb); - } + m1 = mass[n1]; + m2 = mass[n2]; tm = dt_1 / (m1 + m2); for (m = 0; (m < DIM); m++) { @@ -230,19 +217,9 @@ static void predict_shells(FILE* fplog, n1 = shell.nucl1; n2 = shell.nucl2; n3 = shell.nucl3; - if (mass) - { - m1 = mass[n1]; - m2 = mass[n2]; - m3 = mass[n3]; - } - else - { - /* Not the correct masses with FE, but it is just a prediction... */ - m1 = mtopGetAtomMass(mtop, n1, &molb); - m2 = mtopGetAtomMass(mtop, n2, &molb); - m3 = mtopGetAtomMass(mtop, n3, &molb); - } + m1 = mass[n1]; + m2 = mass[n2]; + m3 = mass[n3]; tm = dt_1 / (m1 + m2 + m3); for (m = 0; (m < DIM); m++) { @@ -255,7 +232,7 @@ static void predict_shells(FILE* fplog, } gmx_shellfc_t* init_shell_flexcon(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, int nflexcon, int nstcalcenergy, bool usingDomainDecomposition, @@ -271,7 +248,7 @@ gmx_shellfc_t* init_shell_flexcon(FILE* fplog, #define NBT asize(bondtypes) const gmx_ffparams_t* ffparams; - const gmx::EnumerationArray numParticles = gmx_mtop_particletype_count(*mtop); + const gmx::EnumerationArray numParticles = gmx_mtop_particletype_count(mtop); if (fplog) { /* Print the number of each particle type */ @@ -321,10 +298,10 @@ gmx_shellfc_t* init_shell_flexcon(FILE* fplog, /* We have shells: fill the shell data structure */ /* Global system sized array, this should be avoided */ - std::vector shell_index(mtop->natoms); + std::vector shell_index(mtop.natoms); nshell = 0; - for (const AtomProxy atomP : AtomRange(*mtop)) + for (const AtomProxy atomP : AtomRange(mtop)) { const t_atom& local = atomP.atom(); int i = atomP.globalAtomNumber(); @@ -336,25 +313,25 @@ gmx_shellfc_t* init_shell_flexcon(FILE* fplog, std::vector shell(nshell); - ffparams = &mtop->ffparams; + ffparams = &mtop.ffparams; /* Now fill the structures */ /* TODO: See if we can use update groups that cover shell constructions */ shfc->bInterCG = FALSE; ns = 0; a_offset = 0; - for (size_t mb = 0; mb < mtop->molblock.size(); mb++) + for (size_t mb = 0; mb < mtop.molblock.size(); mb++) { - const gmx_molblock_t* molb = &mtop->molblock[mb]; - const gmx_moltype_t* molt = &mtop->moltype[molb->type]; + const gmx_molblock_t& molb = mtop.molblock[mb]; + const gmx_moltype_t& molt = mtop.moltype[molb.type]; - const t_atom* atom = molt->atoms.atom; - for (mol = 0; mol < molb->nmol; mol++) + const t_atom* atom = molt.atoms.atom; + for (mol = 0; mol < molb.nmol; mol++) { for (j = 0; (j < NBT); j++) { - const int* ia = molt->ilist[bondtypes[j]].iatoms.data(); - for (i = 0; (i < molt->ilist[bondtypes[j]].size());) + const int* ia = molt.ilist[bondtypes[j]].iatoms.data(); + for (i = 0; (i < molt.ilist[bondtypes[j]].size());) { type = ia[0]; ftype = ffparams->functype[type]; @@ -483,7 +460,7 @@ gmx_shellfc_t* init_shell_flexcon(FILE* fplog, i += nra + 1; } } - a_offset += molt->atoms.nr; + a_offset += molt.atoms.nr; } /* Done with this molecule type */ } @@ -1070,7 +1047,8 @@ void relax_shell_flexcon(FILE* fplog, */ if (shfc->predictShells && !bCont && (EI_STATE_VELOCITY(inputrec->eI) || bInit)) { - predict_shells(fplog, x, v, inputrec->delta_t, shells, md->massT, nullptr, bInit); + predict_shells( + fplog, x, v, inputrec->delta_t, shells, gmx::arrayRefFromArray(md->massT, md->homenr), bInit); } /* Calculate the forces first time around */ diff --git a/src/gromacs/mdrun/shellfc.h b/src/gromacs/mdrun/shellfc.h index 61bf701ff5..76722cd33f 100644 --- a/src/gromacs/mdrun/shellfc.h +++ b/src/gromacs/mdrun/shellfc.h @@ -85,7 +85,7 @@ class VirtualSitesHandler; * \returns a pointer to an initialized \c shellfc object. */ gmx_shellfc_t* init_shell_flexcon(FILE* fplog, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, int nflexcon, int nstcalcenergy, bool usingDomainDecomposition, diff --git a/src/gromacs/mdrun/simulatorbuilder.h b/src/gromacs/mdrun/simulatorbuilder.h index 761d3af220..3bd22bb769 100644 --- a/src/gromacs/mdrun/simulatorbuilder.h +++ b/src/gromacs/mdrun/simulatorbuilder.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019-2020, by the GROMACS development team, led by + * Copyright (c) 2019-2020,2021, 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. @@ -305,14 +305,14 @@ class TopologyData { public: //! Build collection from simulation data. - TopologyData(gmx_mtop_t* globalTopology, MDAtoms* mdAtoms) : + TopologyData(const gmx_mtop_t& globalTopology, MDAtoms* mdAtoms) : top_global(globalTopology), mdAtoms(mdAtoms) { } //! Handle to global simulation topology. - gmx_mtop_t* top_global; + const gmx_mtop_t& top_global; //! Handle to information about MDAtoms. MDAtoms* mdAtoms; }; diff --git a/src/gromacs/mdrun/tpi.cpp b/src/gromacs/mdrun/tpi.cpp index f392cadfdc..819532068e 100644 --- a/src/gromacs/mdrun/tpi.cpp +++ b/src/gromacs/mdrun/tpi.cpp @@ -165,7 +165,7 @@ void LegacySimulator::do_tpi() { GMX_RELEASE_ASSERT(gmx_omp_nthreads_get(emntDefault) == 1, "TPI does not support OpenMP"); - gmx_localtop_t top(top_global->ffparams); + gmx_localtop_t top(top_global.ffparams); gmx::ForceBuffers f; real lambda, t, temp, beta, drmax, epot; double embU, sum_embU, *sum_UgembU, V, V_all, VembU_all; @@ -221,9 +221,9 @@ void LegacySimulator::do_tpi() nnodes = cr->nnodes; - gmx_mtop_generate_local_top(*top_global, &top, inputrec->efep != FreeEnergyPerturbationType::No); + gmx_mtop_generate_local_top(top_global, &top, inputrec->efep != FreeEnergyPerturbationType::No); - const SimulationGroups* groups = &top_global->groups; + const SimulationGroups* groups = &top_global.groups; bCavity = (inputrec->eI == IntegrationAlgorithm::TPIC); if (bCavity) @@ -298,10 +298,10 @@ void LegacySimulator::do_tpi() sscanf(dump_pdb, "%20lf", &dump_ener); } - atoms2md(*top_global, *inputrec, -1, {}, top_global->natoms, mdAtoms); + atoms2md(top_global, *inputrec, -1, {}, top_global.natoms, mdAtoms); update_mdatoms(mdatoms, inputrec->fepvals->init_lambda); - f.resize(top_global->natoms); + f.resize(top_global.natoms); /* Print to log file */ walltime_accounting_start_time(walltime_accounting); @@ -309,9 +309,9 @@ void LegacySimulator::do_tpi() print_start(fplog, cr, walltime_accounting, "Test Particle Insertion"); /* The last charge group is the group to be inserted */ - const t_atoms& atomsToInsert = top_global->moltype[top_global->molblock.back().type].atoms; - a_tp0 = top_global->natoms - atomsToInsert.nr; - a_tp1 = top_global->natoms; + const t_atoms& atomsToInsert = top_global.moltype[top_global.molblock.back().type].atoms; + a_tp0 = top_global.natoms - atomsToInsert.nr; + a_tp1 = top_global.natoms; if (debug) { fprintf(debug, "TPI atoms %d-%d\n", a_tp0, a_tp1); diff --git a/src/gromacs/modularsimulator/computeglobalselement.cpp b/src/gromacs/modularsimulator/computeglobalselement.cpp index f5f4e67470..3f7ce609ad 100644 --- a/src/gromacs/modularsimulator/computeglobalselement.cpp +++ b/src/gromacs/modularsimulator/computeglobalselement.cpp @@ -79,7 +79,7 @@ ComputeGlobalsElement::ComputeGlobalsElement(StatePropagatorData* sta t_nrnb* nrnb, gmx_wallcycle* wcycle, t_forcerec* fr, - const gmx_mtop_t* global_top, + const gmx_mtop_t& global_top, Constraints* constr) : energyReductionStep_(-1), virialReductionStep_(-1), @@ -96,7 +96,7 @@ ComputeGlobalsElement::ComputeGlobalsElement(StatePropagatorData* sta energyData_(energyData), localTopology_(nullptr), freeEnergyPerturbationData_(freeEnergyPerturbationData), - vcm_(global_top->groups, *inputrec), + vcm_(global_top.groups, *inputrec), signals_(signals), fplog_(fplog), mdlog_(mdlog), @@ -309,7 +309,7 @@ void ComputeGlobalsElement::compute(gmx::Step step, energyData_->needToSumEkinhOld(), flags | (shouldCheckNumberOfBondedInteractions_ ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0)); checkNumberOfBondedInteractions( - mdlog_, cr_, totalNumberOfBondedInteractions_, *top_global_, localTopology_, x, box, &shouldCheckNumberOfBondedInteractions_); + mdlog_, cr_, totalNumberOfBondedInteractions_, top_global_, localTopology_, x, box, &shouldCheckNumberOfBondedInteractions_); if (flags & CGLO_STOPCM && !isInit) { process_and_stopcm_grp(fplog_, &vcm_, *mdAtoms_->mdatoms(), x, v); diff --git a/src/gromacs/modularsimulator/computeglobalselement.h b/src/gromacs/modularsimulator/computeglobalselement.h index b949145703..2ae60fa096 100644 --- a/src/gromacs/modularsimulator/computeglobalselement.h +++ b/src/gromacs/modularsimulator/computeglobalselement.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -118,7 +118,7 @@ public: t_nrnb* nrnb, gmx_wallcycle* wcycle, t_forcerec* fr, - const gmx_mtop_t* global_top, + const gmx_mtop_t& global_top, Constraints* constr); //! Destructor @@ -252,7 +252,7 @@ private: //! Contains user input mdp options. const t_inputrec* inputrec_; //! Full system topology - only needed for checkNumberOfBondedInteractions. - const gmx_mtop_t* top_global_; + const gmx_mtop_t& top_global_; //! Atom parameters for this domain. const MDAtoms* mdAtoms_; //! Handles constraints. diff --git a/src/gromacs/modularsimulator/energydata.cpp b/src/gromacs/modularsimulator/energydata.cpp index 83e02e92f6..30d55811d5 100644 --- a/src/gromacs/modularsimulator/energydata.cpp +++ b/src/gromacs/modularsimulator/energydata.cpp @@ -80,7 +80,7 @@ class Awh; EnergyData::EnergyData(StatePropagatorData* statePropagatorData, FreeEnergyPerturbationData* freeEnergyPerturbationData, - const gmx_mtop_t* globalTopology, + const gmx_mtop_t& globalTopology, const t_inputrec* inputrec, const MDAtoms* mdAtoms, gmx_enerdata_t* enerd, @@ -115,7 +115,7 @@ EnergyData::EnergyData(StatePropagatorData* statePropagatorData, fplog_(fplog), fcd_(fcd), mdModulesNotifier_(mdModulesNotifier), - groups_(&globalTopology->groups), + groups_(&globalTopology.groups), observablesHistory_(observablesHistory), simulationsShareState_(simulationsShareState) { @@ -168,7 +168,7 @@ void EnergyData::setup(gmx_mdoutf* outf) { pull_t* pull_work = nullptr; energyOutput_ = std::make_unique(mdoutf_get_fp_ene(outf), - *top_global_, + top_global_, *inputrec_, pull_work, mdoutf_get_fp_dhdl(outf), @@ -187,7 +187,7 @@ void EnergyData::setup(gmx_mdoutf* outf) // TODO: This probably doesn't really belong here... // but we have all we need in this element, // so we'll leave it here for now! - double io = compute_io(inputrec_, top_global_->natoms, *groups_, energyOutput_->numEnergyTerms(), 1); + double io = compute_io(inputrec_, top_global_.natoms, *groups_, energyOutput_->numEnergyTerms(), 1); if ((io > 2000) && isMasterRank_) { fprintf(stderr, "\nWARNING: This run will generate roughly %.0f Mb of data\n\n", io); diff --git a/src/gromacs/modularsimulator/energydata.h b/src/gromacs/modularsimulator/energydata.h index 29e2a0d28f..bc0c55dc30 100644 --- a/src/gromacs/modularsimulator/energydata.h +++ b/src/gromacs/modularsimulator/energydata.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -96,7 +96,7 @@ public: //! Constructor EnergyData(StatePropagatorData* statePropagatorData, FreeEnergyPerturbationData* freeEnergyPerturbationData, - const gmx_mtop_t* globalTopology, + const gmx_mtop_t& globalTopology, const t_inputrec* inputrec, const MDAtoms* mdAtoms, gmx_enerdata_t* enerd, @@ -297,7 +297,7 @@ private: //! Contains user input mdp options. const t_inputrec* inputrec_; //! Full system topology. - const gmx_mtop_t* top_global_; + const gmx_mtop_t& top_global_; //! Atom parameters for this domain. const MDAtoms* mdAtoms_; //! Energy data structure diff --git a/src/gromacs/modularsimulator/forceelement.cpp b/src/gromacs/modularsimulator/forceelement.cpp index cce364f9fc..48fa24754d 100644 --- a/src/gromacs/modularsimulator/forceelement.cpp +++ b/src/gromacs/modularsimulator/forceelement.cpp @@ -88,7 +88,7 @@ ForceElement::ForceElement(StatePropagatorData* statePropagatorData, ImdSession* imdSession, pull_t* pull_work, Constraints* constr, - const gmx_mtop_t* globalTopology, + const gmx_mtop_t& globalTopology, gmx_enfrot* enforcedRotation) : shellfc_(init_shell_flexcon(fplog, globalTopology, diff --git a/src/gromacs/modularsimulator/forceelement.h b/src/gromacs/modularsimulator/forceelement.h index 3e5318a282..27ba90a665 100644 --- a/src/gromacs/modularsimulator/forceelement.h +++ b/src/gromacs/modularsimulator/forceelement.h @@ -109,7 +109,7 @@ public: ImdSession* imdSession, pull_t* pull_work, Constraints* constr, - const gmx_mtop_t* globalTopology, + const gmx_mtop_t& globalTopology, gmx_enfrot* enforcedRotation); /*! \brief Register force calculation for step / time diff --git a/src/gromacs/modularsimulator/modularsimulator.cpp b/src/gromacs/modularsimulator/modularsimulator.cpp index b285fc054c..5bb98e9afa 100644 --- a/src/gromacs/modularsimulator/modularsimulator.cpp +++ b/src/gromacs/modularsimulator/modularsimulator.cpp @@ -382,7 +382,7 @@ void ModularSimulator::checkInputForDisabledFunctionality() isInputCompatible(true, legacySimulatorData_->inputrec, legacySimulatorData_->mdrunOptions.rerun, - *legacySimulatorData_->top_global, + legacySimulatorData_->top_global, legacySimulatorData_->ms, legacySimulatorData_->replExParams, legacySimulatorData_->fr->fcdata.get(), diff --git a/src/gromacs/modularsimulator/simulatoralgorithm.cpp b/src/gromacs/modularsimulator/simulatoralgorithm.cpp index 29e24c013f..df60829889 100644 --- a/src/gromacs/modularsimulator/simulatoralgorithm.cpp +++ b/src/gromacs/modularsimulator/simulatoralgorithm.cpp @@ -411,7 +411,7 @@ ModularSimulatorAlgorithmBuilder::ModularSimulatorAlgorithmBuilder( } statePropagatorData_ = std::make_unique( - legacySimulatorData->top_global->natoms, + legacySimulatorData->top_global.natoms, legacySimulatorData->fplog, legacySimulatorData->cr, legacySimulatorData->state_global, @@ -468,7 +468,7 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::build() } } - ModularSimulatorAlgorithm algorithm(*(legacySimulatorData_->top_global->name), + ModularSimulatorAlgorithm algorithm(*(legacySimulatorData_->top_global.name), legacySimulatorData_->fplog, legacySimulatorData_->cr, legacySimulatorData_->mdlog, @@ -518,7 +518,7 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::build() legacySimulatorData_->walltime_accounting); // Build topology holder - algorithm.topologyHolder_ = topologyHolderBuilder_.build(*legacySimulatorData_->top_global, + algorithm.topologyHolder_ = topologyHolderBuilder_.build(legacySimulatorData_->top_global, legacySimulatorData_->cr, legacySimulatorData_->inputrec, legacySimulatorData_->fr, diff --git a/src/gromacs/modularsimulator/statepropagatordata.cpp b/src/gromacs/modularsimulator/statepropagatordata.cpp index 7baae2123f..cbafcfb871 100644 --- a/src/gromacs/modularsimulator/statepropagatordata.cpp +++ b/src/gromacs/modularsimulator/statepropagatordata.cpp @@ -83,7 +83,7 @@ StatePropagatorData::StatePropagatorData(int numAtoms, const std::string& finalConfigurationFilename, const t_inputrec* inputrec, const t_mdatoms* mdatoms, - const gmx_mtop_t* globalTop) : + const gmx_mtop_t& globalTop) : totalNumAtoms_(numAtoms), localNAtoms_(0), box_{ { 0 } }, @@ -657,11 +657,11 @@ void StatePropagatorData::Element::trajectoryWriterTeardown(gmx_mdoutf* gmx_unus // Make molecules whole only for confout writing do_pbc_mtop(pbcType_, localStateBackup_->box, - top_global_, + &top_global_, statePropagatorData_->globalState_->x.rvec_array()); } write_sto_conf_mtop(finalConfigurationFilename_.c_str(), - *top_global_->name, + *top_global_.name, top_global_, statePropagatorData_->globalState_->x.rvec_array(), statePropagatorData_->globalState_->v.rvec_array(), @@ -690,7 +690,7 @@ StatePropagatorData::Element::Element(StatePropagatorData* statePropagatorData, bool writeFinalConfiguration, std::string finalConfigurationFilename, const t_inputrec* inputrec, - const gmx_mtop_t* globalTop) : + const gmx_mtop_t& globalTop) : statePropagatorData_(statePropagatorData), nstxout_(nstxout), nstvout_(nstvout), diff --git a/src/gromacs/modularsimulator/statepropagatordata.h b/src/gromacs/modularsimulator/statepropagatordata.h index fe27720061..3994d8b624 100644 --- a/src/gromacs/modularsimulator/statepropagatordata.h +++ b/src/gromacs/modularsimulator/statepropagatordata.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -110,7 +110,7 @@ public: const std::string& finalConfigurationFilename, const t_inputrec* inputrec, const t_mdatoms* mdatoms, - const gmx_mtop_t* globalTop); + const gmx_mtop_t& globalTop); // Allow access to state //! Get write access to position vector @@ -274,7 +274,7 @@ public: bool writeFinalConfiguration, std::string finalConfigurationFilename, const t_inputrec* inputrec, - const gmx_mtop_t* globalTop); + const gmx_mtop_t& globalTop); /*! \brief Register run function for step / time * @@ -399,7 +399,7 @@ private: //! Handles communication. const t_commrec* cr_; //! Full system topology. - const gmx_mtop_t* top_global_; + const gmx_mtop_t& top_global_; }; } // namespace gmx diff --git a/src/gromacs/modularsimulator/trajectoryelement.cpp b/src/gromacs/modularsimulator/trajectoryelement.cpp index 5a4b55cbab..69ff938357 100644 --- a/src/gromacs/modularsimulator/trajectoryelement.cpp +++ b/src/gromacs/modularsimulator/trajectoryelement.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -58,7 +58,7 @@ TrajectoryElement::TrajectoryElement(std::vector write gmx::IMDOutputProvider* outputProvider, const MdModulesNotifier& mdModulesNotifier, const t_inputrec* inputrec, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const gmx_output_env_t* oenv, gmx_wallcycle* wcycle, StartingBehavior startingBehavior, diff --git a/src/gromacs/modularsimulator/trajectoryelement.h b/src/gromacs/modularsimulator/trajectoryelement.h index 5b3d600019..8c93b5a881 100644 --- a/src/gromacs/modularsimulator/trajectoryelement.h +++ b/src/gromacs/modularsimulator/trajectoryelement.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -137,7 +137,7 @@ private: IMDOutputProvider* outputProvider, const MdModulesNotifier& mdModulesNotifier, const t_inputrec* inputrec, - const gmx_mtop_t* top_global, + const gmx_mtop_t& top_global, const gmx_output_env_t* oenv, gmx_wallcycle* wcycle, StartingBehavior startingBehavior, diff --git a/src/gromacs/pulling/pull.cpp b/src/gromacs/pulling/pull.cpp index b0da21552c..ae29d66801 100644 --- a/src/gromacs/pulling/pull.cpp +++ b/src/gromacs/pulling/pull.cpp @@ -1829,7 +1829,7 @@ static void init_pull_group_index(FILE* fplog, pull_group_work_t* pg, gmx_bool bConstraint, const ivec pulldim_con, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_inputrec* ir, real lambda) { @@ -1843,7 +1843,7 @@ static void init_pull_group_index(FILE* fplog, /* In parallel, store we need to extract localWeights from weights at DD time */ std::vector& weights = ((cr && PAR(cr)) ? pg->globalWeights : pg->localWeights); - const SimulationGroups& groups = mtop->groups; + const SimulationGroups& groups = mtop.groups; /* Count frozen dimensions and (weighted) mass */ int nfrozen = 0; @@ -1982,7 +1982,7 @@ static void init_pull_group_index(FILE* fplog, struct pull_t* init_pull(FILE* fplog, const pull_params_t* pull_params, const t_inputrec* ir, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_commrec* cr, gmx::LocalAtomSetManager* atomSets, real lambda) diff --git a/src/gromacs/pulling/pull.h b/src/gromacs/pulling/pull.h index 2f87228ecb..a91784cf83 100644 --- a/src/gromacs/pulling/pull.h +++ b/src/gromacs/pulling/pull.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -242,7 +242,7 @@ void dd_make_local_pull_groups(const t_commrec* cr, struct pull_t* pull); struct pull_t* init_pull(FILE* fplog, const pull_params_t* pull_params, const t_inputrec* ir, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_commrec* cr, gmx::LocalAtomSetManager* atomSets, real lambda); diff --git a/src/gromacs/pulling/pull_rotation.cpp b/src/gromacs/pulling/pull_rotation.cpp index 20abd248b9..ab10a7a8a8 100644 --- a/src/gromacs/pulling/pull_rotation.cpp +++ b/src/gromacs/pulling/pull_rotation.cpp @@ -3437,16 +3437,16 @@ static inline void copy_correct_pbc_image(const rvec xcurr, /* copy vector xcurr } -static void init_rot_group(FILE* fplog, - const t_commrec* cr, - gmx_enfrotgrp* erg, - rvec* x, - gmx_mtop_t* mtop, - gmx_bool bVerbose, - FILE* out_slabs, - const matrix box, - t_inputrec* ir, - gmx_bool bOutputCenters) +static void init_rot_group(FILE* fplog, + const t_commrec* cr, + gmx_enfrotgrp* erg, + rvec* x, + const gmx_mtop_t& mtop, + gmx_bool bVerbose, + FILE* out_slabs, + const matrix box, + t_inputrec* ir, + gmx_bool bOutputCenters) { rvec coord, xref, *xdum; gmx_bool bFlex, bColl; @@ -3688,7 +3688,7 @@ std::unique_ptr init_rot(FILE* fplo const t_commrec* cr, gmx::LocalAtomSetManager* atomSets, const t_state* globalState, - gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const gmx_output_env_t* oenv, const gmx::MdrunOptions& mdrunOptions, const gmx::StartingBehavior startingBehavior) @@ -3741,9 +3741,9 @@ std::unique_ptr init_rot(FILE* fplo { /* Remove pbc, make molecule whole. * When ir->bContinuation=TRUE this has already been done, but ok. */ - snew(x_pbc, mtop->natoms); - copy_rvecn(globalState->x.rvec_array(), x_pbc, 0, mtop->natoms); - do_pbc_first_mtop(nullptr, ir->pbcType, globalState->box, mtop, x_pbc); + snew(x_pbc, mtop.natoms); + copy_rvecn(globalState->x.rvec_array(), x_pbc, 0, mtop.natoms); + do_pbc_first_mtop(nullptr, ir->pbcType, globalState->box, &mtop, x_pbc); /* All molecules will be whole now, but not necessarily in the home box. * Additionally, if a rotation group consists of more than one molecule * (e.g. two strands of DNA), each one of them can end up in a different diff --git a/src/gromacs/pulling/pull_rotation.h b/src/gromacs/pulling/pull_rotation.h index 56cb190755..de5f1388a0 100644 --- a/src/gromacs/pulling/pull_rotation.h +++ b/src/gromacs/pulling/pull_rotation.h @@ -119,7 +119,7 @@ std::unique_ptr init_rot(FILE* fplog, const t_commrec* cr, gmx::LocalAtomSetManager* atomSets, const t_state* globalState, - gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const gmx_output_env_t* oenv, const gmx::MdrunOptions& mdrunOptions, gmx::StartingBehavior startingBehavior); diff --git a/src/gromacs/selection/centerofmass.cpp b/src/gromacs/selection/centerofmass.cpp index 356482ccd1..f76ecbd6e0 100644 --- a/src/gromacs/selection/centerofmass.cpp +++ b/src/gromacs/selection/centerofmass.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2009-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2021, 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. @@ -86,7 +86,7 @@ void gmx_calc_com(const gmx_mtop_t* top, rvec x[], int nrefat, const int index[] for (int m = 0; m < nrefat; ++m) { const int ai = index[m]; - const real mass = mtopGetAtomMass(top, ai, &molb); + const real mass = mtopGetAtomMass(*top, ai, &molb); for (int j = 0; j < DIM; ++j) { xout[j] += mass * x[ai][j]; @@ -113,7 +113,7 @@ void gmx_calc_cog_f(const gmx_mtop_t* top, rvec f[], int nrefat, const int index for (int m = 0; m < nrefat; ++m) { const int ai = index[m]; - const real mass = mtopGetAtomMass(top, ai, &molb); + const real mass = mtopGetAtomMass(*top, ai, &molb); for (int j = 0; j < DIM; ++j) { fout[j] += f[ai][j] / mass; @@ -257,7 +257,7 @@ void gmx_calc_com_pbc(const gmx_mtop_t* top, rvec x[], const t_pbc* pbc, int nre for (int m = 0; m < nrefat; ++m) { const int ai = index[m]; - const real mass = mtopGetAtomMass(top, ai, &molb); + const real mass = mtopGetAtomMass(*top, ai, &molb); for (int j = 0; j < DIM; ++j) { xout[j] += mass * x[ai][j]; @@ -278,7 +278,7 @@ void gmx_calc_com_pbc(const gmx_mtop_t* top, rvec x[], const t_pbc* pbc, int nre { rvec dx, xtest; const int ai = index[m]; - const real mass = mtopGetAtomMass(top, ai, &molb) / mtot; + const real mass = mtopGetAtomMass(*top, ai, &molb) / mtot; pbc_dx(pbc, x[ai], xout, dx); rvec_add(xout, dx, xtest); for (int j = 0; j < DIM; ++j) @@ -363,7 +363,7 @@ void gmx_calc_com_block(const gmx_mtop_t* top, rvec x[], const t_block* block, c for (int i = block->index[b]; i < block->index[b + 1]; ++i) { const int ai = index[i]; - const real mass = mtopGetAtomMass(top, ai, &molb); + const real mass = mtopGetAtomMass(*top, ai, &molb); for (int d = 0; d < DIM; ++d) { xb[d] += mass * x[ai][d]; @@ -394,7 +394,7 @@ void gmx_calc_cog_f_block(const gmx_mtop_t* top, rvec f[], const t_block* block, for (int i = block->index[b]; i < block->index[b + 1]; ++i) { const int ai = index[i]; - const real mass = mtopGetAtomMass(top, ai, &molb); + const real mass = mtopGetAtomMass(*top, ai, &molb); for (int d = 0; d < DIM; ++d) { fb[d] += f[ai][d] / mass; diff --git a/src/gromacs/selection/indexutil.cpp b/src/gromacs/selection/indexutil.cpp index 160676281c..af168f6242 100644 --- a/src/gromacs/selection/indexutil.cpp +++ b/src/gromacs/selection/indexutil.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team. * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -165,7 +165,7 @@ void gmx_ana_indexgrps_init(gmx_ana_indexgrps_t** g, gmx_mtop_t* top, const char { block = new_blocka(); // TODO: Propagate mtop further. - t_atoms atoms = gmx_mtop_global_atoms(top); + t_atoms atoms = gmx_mtop_global_atoms(*top); analyse(&atoms, block, &names, FALSE, FALSE); done_atom(&atoms); } @@ -770,14 +770,14 @@ static bool next_group_index(int atomIndex, const gmx_mtop_t* top, e_index_t typ case INDEX_RES: { int resind, molb = 0; - mtopGetAtomAndResidueName(top, atomIndex, &molb, nullptr, nullptr, nullptr, &resind); + mtopGetAtomAndResidueName(*top, atomIndex, &molb, nullptr, nullptr, nullptr, &resind); *id = resind; break; } case INDEX_MOL: { int molb = 0; - *id = mtopGetMoleculeIndex(top, atomIndex, &molb); + *id = mtopGetMoleculeIndex(*top, atomIndex, &molb); break; } case INDEX_UNKNOWN: @@ -888,7 +888,7 @@ void gmx_ana_index_make_block(t_blocka* t, const gmx_mtop_t* top, gmx_ana_index_ case INDEX_RES: { int molnr, atnr_mol; - mtopGetMolblockIndex(top, ai, &molb, &molnr, &atnr_mol); + mtopGetMolblockIndex(*top, ai, &molb, &molnr, &atnr_mol); const t_atoms& mol_atoms = top->moltype[top->molblock[molb].type].atoms; int last_atom = atnr_mol + 1; const int currentResid = mol_atoms.atom[atnr_mol].resind; @@ -915,7 +915,7 @@ void gmx_ana_index_make_block(t_blocka* t, const gmx_mtop_t* top, gmx_ana_index_ case INDEX_MOL: { int molnr, atnr_mol; - mtopGetMolblockIndex(top, ai, &molb, &molnr, &atnr_mol); + mtopGetMolblockIndex(*top, ai, &molb, &molnr, &atnr_mol); const MoleculeBlockIndices& blockIndices = top->moleculeBlockIndices[molb]; const int atomStart = blockIndices.globalAtomStart + (id - blockIndices.moleculeIndexStart) @@ -1038,9 +1038,9 @@ bool gmx_ana_index_has_full_ablocks(gmx_ana_index_t* g, t_blocka* b) * \param[in,out] molb The molecule block of atom a * \returns true if atoms \p a and \p a + 1 are in different residues, false otherwise. */ -static bool is_at_residue_boundary(const gmx_mtop_t* top, int a, int* molb) +static bool is_at_residue_boundary(const gmx_mtop_t& top, int a, int* molb) { - if (a == -1 || a + 1 == top->natoms) + if (a == -1 || a + 1 == top.natoms) { return true; } @@ -1089,11 +1089,11 @@ bool gmx_ana_index_has_complete_elems(gmx_ana_index_t* g, e_index_t type, const // Check if a is consecutive or on a residue boundary if (a != aPrev + 1) { - if (!is_at_residue_boundary(top, aPrev, &molb)) + if (!is_at_residue_boundary(*top, aPrev, &molb)) { return false; } - if (!is_at_residue_boundary(top, a - 1, &molb)) + if (!is_at_residue_boundary(*top, a - 1, &molb)) { return false; } @@ -1102,7 +1102,7 @@ bool gmx_ana_index_has_complete_elems(gmx_ana_index_t* g, e_index_t type, const } GMX_ASSERT(g->isize > 0, "We return above when isize=0"); const int a = g->index[g->isize - 1]; - if (!is_at_residue_boundary(top, a, &molb)) + if (!is_at_residue_boundary(*top, a, &molb)) { return false; } diff --git a/src/gromacs/selection/selection.cpp b/src/gromacs/selection/selection.cpp index b3cadb741d..34fbee5973 100644 --- a/src/gromacs/selection/selection.cpp +++ b/src/gromacs/selection/selection.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team. * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -179,7 +179,7 @@ void computeMassesAndCharges(const gmx_mtop_t* top, for (int i = pos.m.mapb.index[b]; i < pos.m.mapb.index[b + 1]; ++i) { const int index = pos.m.mapb.a[i]; - const t_atom& atom = mtopGetAtomParameters(top, index, &molb); + const t_atom& atom = mtopGetAtomParameters(*top, index, &molb); mass += atom.m; charge += atom.q; } diff --git a/src/gromacs/selection/sm_simple.cpp b/src/gromacs/selection/sm_simple.cpp index 2083f12033..1dbc4f0faf 100644 --- a/src/gromacs/selection/sm_simple.cpp +++ b/src/gromacs/selection/sm_simple.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team. * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, 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. @@ -470,7 +470,7 @@ static void evaluate_resnr(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - mtopGetAtomAndResidueName(context.top, g->index[i], &molb, nullptr, &out->u.i[i], nullptr, nullptr); + mtopGetAtomAndResidueName(*context.top, g->index[i], &molb, nullptr, &out->u.i[i], nullptr, nullptr); } } @@ -490,7 +490,7 @@ static void evaluate_resindex(const gmx::SelMethodEvalContext& context, for (int i = 0; i < g->isize; ++i) { int resind; - mtopGetAtomAndResidueName(context.top, g->index[i], &molb, nullptr, nullptr, nullptr, &resind); + mtopGetAtomAndResidueName(*context.top, g->index[i], &molb, nullptr, nullptr, nullptr, &resind); out->u.i[i] = resind + 1; } } @@ -521,7 +521,7 @@ static void evaluate_molindex(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.i[i] = mtopGetMoleculeIndex(context.top, g->index[i], &molb) + 1; + out->u.i[i] = mtopGetMoleculeIndex(*context.top, g->index[i], &molb) + 1; } } @@ -541,7 +541,7 @@ static void evaluate_atomname(const gmx::SelMethodEvalContext& context, for (int i = 0; i < g->isize; ++i) { const char* atom_name; - mtopGetAtomAndResidueName(context.top, g->index[i], &molb, &atom_name, nullptr, nullptr, nullptr); + mtopGetAtomAndResidueName(*context.top, g->index[i], &molb, &atom_name, nullptr, nullptr, nullptr); out->u.s[i] = const_cast(atom_name); } } @@ -561,7 +561,7 @@ static void evaluate_pdbatomname(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - const char* s = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).atomnm; + const char* s = mtopGetAtomPdbInfo(*context.top, g->index[i], &molb).atomnm; while (std::isspace(*s)) { ++s; @@ -595,7 +595,7 @@ static void evaluate_atomtype(const gmx::SelMethodEvalContext& context, for (int i = 0; i < g->isize; ++i) { int atomIndexInMolecule; - mtopGetMolblockIndex(context.top, g->index[i], &molb, nullptr, &atomIndexInMolecule); + mtopGetMolblockIndex(*context.top, g->index[i], &molb, nullptr, &atomIndexInMolecule); const gmx_moltype_t& moltype = context.top->moltype[context.top->molblock[molb].type]; out->u.s[i] = *moltype.atoms.atomtype[atomIndexInMolecule]; } @@ -616,7 +616,7 @@ static void evaluate_resname(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.s[i] = *mtopGetResidueInfo(context.top, g->index[i], &molb).name; + out->u.s[i] = *mtopGetResidueInfo(*context.top, g->index[i], &molb).name; } } @@ -635,7 +635,7 @@ static void evaluate_insertcode(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.s[i][0] = mtopGetResidueInfo(context.top, g->index[i], &molb).ic; + out->u.s[i][0] = mtopGetResidueInfo(*context.top, g->index[i], &molb).ic; } } @@ -654,7 +654,7 @@ static void evaluate_chain(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.s[i][0] = mtopGetResidueInfo(context.top, g->index[i], &molb).chainid; + out->u.s[i][0] = mtopGetResidueInfo(*context.top, g->index[i], &molb).chainid; } } @@ -674,7 +674,7 @@ static void evaluate_mass(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.r[i] = mtopGetAtomMass(context.top, g->index[i], &molb); + out->u.r[i] = mtopGetAtomMass(*context.top, g->index[i], &molb); } } @@ -702,7 +702,7 @@ static void evaluate_charge(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.r[i] = mtopGetAtomParameters(context.top, g->index[i], &molb).q; + out->u.r[i] = mtopGetAtomParameters(*context.top, g->index[i], &molb).q; } } @@ -729,7 +729,7 @@ static void evaluate_altloc(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.s[i][0] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).altloc; + out->u.s[i][0] = mtopGetAtomPdbInfo(*context.top, g->index[i], &molb).altloc; } } @@ -749,7 +749,7 @@ static void evaluate_occupancy(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.r[i] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).occup; + out->u.r[i] = mtopGetAtomPdbInfo(*context.top, g->index[i], &molb).occup; } } @@ -769,7 +769,7 @@ static void evaluate_betafactor(const gmx::SelMethodEvalContext& context, int molb = 0; for (int i = 0; i < g->isize; ++i) { - out->u.r[i] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).bfac; + out->u.r[i] = mtopGetAtomPdbInfo(*context.top, g->index[i], &molb).bfac; } } diff --git a/src/gromacs/swap/swapcoords.cpp b/src/gromacs/swap/swapcoords.cpp index 2880c81e33..102f863d0e 100644 --- a/src/gromacs/swap/swapcoords.cpp +++ b/src/gromacs/swap/swapcoords.cpp @@ -1047,7 +1047,7 @@ static void check_swap_groups(t_swap* s, int nat, gmx_bool bVerbose) * * Also ensure that all the molecules in this group have this number of atoms. */ -static int get_group_apm_check(int igroup, t_swap* s, gmx_bool bVerbose, gmx_mtop_t* mtop) +static int get_group_apm_check(int igroup, t_swap* s, gmx_bool bVerbose, const gmx_mtop_t& mtop) { t_swapgrp* g = &s->group[igroup]; const int* ind = s->group[igroup].atomset.globalIndex().data(); @@ -1057,7 +1057,7 @@ static int get_group_apm_check(int igroup, t_swap* s, gmx_bool bVerbose, gmx_mto * first solvent atom: */ int molb = 0; mtopGetMolblockIndex(mtop, ind[0], &molb, nullptr, nullptr); - int apm = mtop->moleculeBlockIndices[molb].numAtomsPerMolecule; + int apm = mtop.moleculeBlockIndices[molb].numAtomsPerMolecule; if (bVerbose) { @@ -1073,7 +1073,7 @@ static int get_group_apm_check(int igroup, t_swap* s, gmx_bool bVerbose, gmx_mto for (int i = 1; i < nat; i++) { mtopGetMolblockIndex(mtop, ind[i], &molb, nullptr, nullptr); - if (apm != mtop->moleculeBlockIndices[molb].numAtomsPerMolecule) + if (apm != mtop.moleculeBlockIndices[molb].numAtomsPerMolecule) { gmx_fatal(FARGS, "Not all molecules of swap group %d consist of %d atoms.", igroup, apm); } @@ -1276,7 +1276,7 @@ static void detect_flux_per_channel_init(t_swap* s, swaphistory_t* swapstate, co * If this is not correct, the ion counts per channel will be very likely * wrong. */ -static void outputStartStructureIfWanted(gmx_mtop_t* mtop, rvec* x, PbcType pbcType, const matrix box) +static void outputStartStructureIfWanted(const gmx_mtop_t& mtop, rvec* x, PbcType pbcType, const matrix box) { char* env = getenv("GMX_COMPELDUMP"); @@ -1291,7 +1291,7 @@ static void outputStartStructureIfWanted(gmx_mtop_t* mtop, rvec* x, PbcType pbcT SwSEmpty); write_sto_conf_mtop( - "CompELAssumedWholeConfiguration.pdb", *mtop->name, mtop, x, nullptr, pbcType, box); + "CompELAssumedWholeConfiguration.pdb", *mtop.name, mtop, x, nullptr, pbcType, box); } } @@ -1309,7 +1309,7 @@ static void outputStartStructureIfWanted(gmx_mtop_t* mtop, rvec* x, PbcType pbcT static void init_swapstate(swaphistory_t* swapstate, t_swapcoords* sc, t_swap* s, - gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const rvec* x, /* the initial positions */ const matrix box, const t_inputrec* ir) @@ -1353,11 +1353,11 @@ static void init_swapstate(swaphistory_t* swapstate, /* Extract the initial split group positions. */ /* Remove pbc, make molecule whole. */ - snew(x_pbc, mtop->natoms); - copy_rvecn(x, x_pbc, 0, mtop->natoms); + snew(x_pbc, mtop.natoms); + copy_rvecn(x, x_pbc, 0, mtop.natoms); /* This can only make individual molecules whole, not multimers */ - do_pbc_mtop(ir->pbcType, box, mtop, x_pbc); + do_pbc_mtop(ir->pbcType, box, &mtop, x_pbc); /* Output the starting structure? */ outputStartStructureIfWanted(mtop, x_pbc, ir->pbcType, box); @@ -1471,7 +1471,7 @@ static void copyIndicesToGroup(const int* indIons, int nIons, t_swapGroup* g, t_ * #4 cations - empty before conversion * */ -static void convertOldToNewGroupFormat(t_swapcoords* sc, gmx_mtop_t* mtop, gmx_bool bVerbose, t_commrec* cr) +static void convertOldToNewGroupFormat(t_swapcoords* sc, const gmx_mtop_t& mtop, gmx_bool bVerbose, t_commrec* cr) { t_swapGroup* g = &sc->grp[3]; @@ -1536,7 +1536,7 @@ static gmx_bool bConvertFromOldTpr(t_swapcoords* sc) t_swap* init_swapcoords(FILE* fplog, const t_inputrec* ir, const char* fn, - gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_state* globalState, ObservablesHistory* oh, t_commrec* cr, @@ -1605,7 +1605,7 @@ t_swap* init_swapcoords(FILE* fplog, } /* Check for overlapping atoms */ - check_swap_groups(s, mtop->natoms, bVerbose && MASTER(cr)); + check_swap_groups(s, mtop.natoms, bVerbose && MASTER(cr)); /* Allocate space for the collective arrays for all groups */ /* For the collective position array */ diff --git a/src/gromacs/swap/swapcoords.h b/src/gromacs/swap/swapcoords.h index cafddc68c2..ec8fdd540d 100644 --- a/src/gromacs/swap/swapcoords.h +++ b/src/gromacs/swap/swapcoords.h @@ -107,7 +107,7 @@ std::unique_ptr createSwapCoordinatesModule(); t_swap* init_swapcoords(FILE* fplog, const t_inputrec* ir, const char* fn, - gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const t_state* globalState, ObservablesHistory* oh, t_commrec* cr, diff --git a/src/gromacs/taskassignment/resourcedivision.cpp b/src/gromacs/taskassignment/resourcedivision.cpp index 03c80d89e6..388406bf79 100644 --- a/src/gromacs/taskassignment/resourcedivision.cpp +++ b/src/gromacs/taskassignment/resourcedivision.cpp @@ -346,7 +346,7 @@ int get_nthreads_mpi(const gmx_hw_info_t* hwinfo, bool nonbondedOnGpu, bool pmeOnGpu, const t_inputrec* inputrec, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const gmx::MDLogger& mdlog, bool doMembed) { @@ -459,13 +459,13 @@ int get_nthreads_mpi(const gmx_hw_info_t* hwinfo, } } - if (mtop->natoms / nrank < min_atoms_per_mpi_rank) + if (mtop.natoms / nrank < min_atoms_per_mpi_rank) { int nrank_new; /* the rank number was chosen automatically, but there are too few atoms per rank, so we need to reduce the rank count */ - nrank_new = std::max(1, mtop->natoms / min_atoms_per_mpi_rank); + nrank_new = std::max(1, mtop.natoms / min_atoms_per_mpi_rank); /* Avoid partial use of Hyper-Threading */ if (gmxSmtIsEnabled(hwTop) && nrank_new > nthreads_hw / 2 && nrank_new < nthreads_hw) diff --git a/src/gromacs/taskassignment/resourcedivision.h b/src/gromacs/taskassignment/resourcedivision.h index c45ed95493..f9e7151186 100644 --- a/src/gromacs/taskassignment/resourcedivision.h +++ b/src/gromacs/taskassignment/resourcedivision.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, 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. @@ -79,7 +79,7 @@ int get_nthreads_mpi(const gmx_hw_info_t* hwinfo, bool nonbondedOnGpu, bool pmeOnGpu, const t_inputrec* inputrec, - const gmx_mtop_t* mtop, + const gmx_mtop_t& mtop, const gmx::MDLogger& mdlog, bool doMembed); diff --git a/src/gromacs/tools/convert_tpr.cpp b/src/gromacs/tools/convert_tpr.cpp index 66922ac5c6..3aaaf35f9e 100644 --- a/src/gromacs/tools/convert_tpr.cpp +++ b/src/gromacs/tools/convert_tpr.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -235,7 +235,7 @@ static void reduce_topology_x(int gnx, int index[], gmx_mtop_t* mtop, rvec x[], { gmx_localtop_t top(mtop->ffparams); gmx_mtop_generate_local_top(*mtop, &top, false); - t_atoms atoms = gmx_mtop_global_atoms(mtop); + t_atoms atoms = gmx_mtop_global_atoms(*mtop); const std::vector bKeep = bKeepIt(gnx, atoms.nr, index); const std::vector invindex = invind(gnx, atoms.nr, index); @@ -444,7 +444,7 @@ int ConvertTpr::run() if (haveReadIndexFile_ || !(maxStepsIsSet_ || extendTimeIsSet_ || runToMaxTimeIsSet_)) { - atoms = gmx_mtop_global_atoms(&mtop); + atoms = gmx_mtop_global_atoms(mtop); int gnx = 0; int* index = nullptr; char* grpname = nullptr; @@ -495,7 +495,7 @@ int ConvertTpr::run() " time %10.3f and length %10.3f ps\n", stateTime, ir->nsteps * ir->delta_t); - write_tpx_state(outputTprFileName_.c_str(), ir, &state, &mtop); + write_tpx_state(outputTprFileName_.c_str(), ir, &state, mtop); } else { diff --git a/src/gromacs/tools/make_ndx.cpp b/src/gromacs/tools/make_ndx.cpp index 34ecf81798..3f8dbe2aad 100644 --- a/src/gromacs/tools/make_ndx.cpp +++ b/src/gromacs/tools/make_ndx.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team. - * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020,2021, 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. @@ -1565,7 +1565,7 @@ int gmx_make_ndx(int argc, char* argv[]) bool haveFullTopology = false; fprintf(stderr, "\nReading structure file\n"); readConfAndTopology(stxfile, &haveFullTopology, &mtop, &pbcType, &x, &v, box); - atoms = gmx_mtop_global_atoms(&mtop); + atoms = gmx_mtop_global_atoms(mtop); if (atoms.pdbinfo == nullptr) { snew(atoms.pdbinfo, atoms.nr); diff --git a/src/gromacs/tools/pme_error.cpp b/src/gromacs/tools/pme_error.cpp index 15ce914844..2ada54a747 100644 --- a/src/gromacs/tools/pme_error.cpp +++ b/src/gromacs/tools/pme_error.cpp @@ -1211,7 +1211,7 @@ int gmx_pme_error(int argc, char* argv[]) if (opt2bSet("-so", NFILE, fnm) || bTUNE) { ir.ewald_rtol = info.ewald_rtol[0]; - write_tpx_state(opt2fn("-so", NFILE, fnm), &ir, &state, &mtop); + write_tpx_state(opt2fn("-so", NFILE, fnm), &ir, &state, mtop); } please_cite(fp, "Wang2010"); fclose(fp); diff --git a/src/gromacs/tools/report_methods.cpp b/src/gromacs/tools/report_methods.cpp index af45b6005e..eb8fd2eb06 100644 --- a/src/gromacs/tools/report_methods.cpp +++ b/src/gromacs/tools/report_methods.cpp @@ -76,7 +76,7 @@ void writeSystemInformation(TextWriter* writer, const gmx_mtop_t& top, bool writ const t_atom* atom; writeHeader(writer, "Simulation system", "subsection", writeFormattedText); - aloop = gmx_mtop_atomloop_block_init(&top); + aloop = gmx_mtop_atomloop_block_init(top); while (gmx_mtop_atomloop_block_next(aloop, &atom, &nmol)) { if (atom->ptype == ParticleType::VSite) diff --git a/src/gromacs/tools/tune_pme.cpp b/src/gromacs/tools/tune_pme.cpp index 216fb0cf3e..3c8e9857c8 100644 --- a/src/gromacs/tools/tune_pme.cpp +++ b/src/gromacs/tools/tune_pme.cpp @@ -887,7 +887,7 @@ static void modify_PMEsettings(int64_t simsteps, /* Set this value as num sprintf(buf, "Writing optimized simulation file %s with nsteps=%s.\n", fn_sim_tpr, "%" PRId64); fprintf(stdout, buf, ir->nsteps); fflush(stdout); - write_tpx_state(fn_sim_tpr, ir, &state, &mtop); + write_tpx_state(fn_sim_tpr, ir, &state, mtop); } static gmx_bool can_scale_rvdw(VanDerWaalsType vdwtype) @@ -1155,7 +1155,7 @@ static void make_benchmark_tprs(const char* fn_sim_tpr, /* READ : User-provided fprintf(stdout, ", unmodified settings\n"); } - write_tpx_state(fn_bench_tprs[j], ir, &state, &mtop); + write_tpx_state(fn_bench_tprs[j], ir, &state, mtop); /* Write information about modified tpr settings to log file */ fprintf(fp, "%4d%10f%10f", j, fac, ir->rcoulomb); diff --git a/src/gromacs/topology/mtop_lookup.h b/src/gromacs/topology/mtop_lookup.h index f0395eb75e..8b9c4befee 100644 --- a/src/gromacs/topology/mtop_lookup.h +++ b/src/gromacs/topology/mtop_lookup.h @@ -69,34 +69,34 @@ struct t_atom; * \param[out] moleculeIndex The index of the molecule in the block, can be NULL * \param[out] atomIndexInMolecule The atom index in the molecule, can be NULL */ -static inline void mtopGetMolblockIndex(const gmx_mtop_t* mtop, +static inline void mtopGetMolblockIndex(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock, int* moleculeIndex, int* atomIndexInMolecule) { GMX_ASSERT(globalAtomIndex >= 0, "The atom index to look up should not be negative"); - GMX_ASSERT(globalAtomIndex < mtop->natoms, "The atom index to look up should be within range"); + GMX_ASSERT(globalAtomIndex < mtop.natoms, "The atom index to look up should be within range"); GMX_ASSERT(moleculeBlock != nullptr, "molBlock can not be NULL"); - GMX_ASSERT(!mtop->moleculeBlockIndices.empty(), "The moleculeBlockIndices should not be empty"); + GMX_ASSERT(!mtop.moleculeBlockIndices.empty(), "The moleculeBlockIndices should not be empty"); GMX_ASSERT(*moleculeBlock >= 0, "The starting molecule block index for the search should not be negative"); - GMX_ASSERT(*moleculeBlock < gmx::ssize(mtop->moleculeBlockIndices), + GMX_ASSERT(*moleculeBlock < gmx::ssize(mtop.moleculeBlockIndices), "The starting molecule block index for the search should be within range"); /* Search the molecule block index using bisection */ int molBlock0 = -1; - int molBlock1 = mtop->molblock.size(); + int molBlock1 = mtop.molblock.size(); int globalAtomStart = 0; while (TRUE) { - globalAtomStart = mtop->moleculeBlockIndices[*moleculeBlock].globalAtomStart; + globalAtomStart = mtop.moleculeBlockIndices[*moleculeBlock].globalAtomStart; if (globalAtomIndex < globalAtomStart) { molBlock1 = *moleculeBlock; } - else if (globalAtomIndex >= mtop->moleculeBlockIndices[*moleculeBlock].globalAtomEnd) + else if (globalAtomIndex >= mtop.moleculeBlockIndices[*moleculeBlock].globalAtomEnd) { molBlock0 = *moleculeBlock; } @@ -108,7 +108,7 @@ static inline void mtopGetMolblockIndex(const gmx_mtop_t* mtop, } int molIndex = (globalAtomIndex - globalAtomStart) - / mtop->moleculeBlockIndices[*moleculeBlock].numAtomsPerMolecule; + / mtop.moleculeBlockIndices[*moleculeBlock].numAtomsPerMolecule; if (moleculeIndex != nullptr) { *moleculeIndex = molIndex; @@ -116,7 +116,7 @@ static inline void mtopGetMolblockIndex(const gmx_mtop_t* mtop, if (atomIndexInMolecule != nullptr) { *atomIndexInMolecule = globalAtomIndex - globalAtomStart - - molIndex * mtop->moleculeBlockIndices[*moleculeBlock].numAtomsPerMolecule; + - molIndex * mtop.moleculeBlockIndices[*moleculeBlock].numAtomsPerMolecule; } } @@ -132,12 +132,12 @@ static inline void mtopGetMolblockIndex(const gmx_mtop_t* mtop, * \param[in] globalAtomIndex The global atom index to look up * \param[in,out] moleculeBlock The molecule block index in \p mtop */ -static inline int mtopGetMoleculeIndex(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock) +static inline int mtopGetMoleculeIndex(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock) { int localMoleculeIndex = 0; mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, &localMoleculeIndex, nullptr); - return mtop->moleculeBlockIndices[*moleculeBlock].moleculeIndexStart + localMoleculeIndex; + return mtop.moleculeBlockIndices[*moleculeBlock].moleculeIndexStart + localMoleculeIndex; } /*! \brief Returns the atom data for an atom based on global atom index @@ -152,11 +152,11 @@ static inline int mtopGetMoleculeIndex(const gmx_mtop_t* mtop, int globalAtomInd * \param[in] globalAtomIndex The global atom index to look up * \param[in,out] moleculeBlock The molecule block index in \p mtop */ -static inline const t_atom& mtopGetAtomParameters(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock) +static inline const t_atom& mtopGetAtomParameters(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock) { int atomIndexInMolecule = 0; mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule); - const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type]; + const gmx_moltype_t& moltype = mtop.moltype[mtop.molblock[*moleculeBlock].type]; return moltype.atoms.atom[atomIndexInMolecule]; } @@ -173,7 +173,7 @@ static inline const t_atom& mtopGetAtomParameters(const gmx_mtop_t* mtop, int gl * \param[in] globalAtomIndex The global atom index to look up * \param[in,out] moleculeBlock The molecule block index in \p mtop */ -static inline real mtopGetAtomMass(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock) +static inline real mtopGetAtomMass(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock) { const t_atom& atom = mtopGetAtomParameters(mtop, globalAtomIndex, moleculeBlock); return atom.m; @@ -198,7 +198,7 @@ static inline real mtopGetAtomMass(const gmx_mtop_t* mtop, int globalAtomIndex, * \param[out] residueName The residue name, input can be NULL * \param[out] globalResidueIndex The gobal residue index, input can be NULL */ -static inline void mtopGetAtomAndResidueName(const gmx_mtop_t* mtop, +static inline void mtopGetAtomAndResidueName(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock, const char** atomName, @@ -210,16 +210,16 @@ static inline void mtopGetAtomAndResidueName(const gmx_mtop_t* mtop, int atomIndexInMolecule = 0; mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, &moleculeIndex, &atomIndexInMolecule); - const gmx_molblock_t& molb = mtop->molblock[*moleculeBlock]; - const t_atoms& atoms = mtop->moltype[molb.type].atoms; - const MoleculeBlockIndices& indices = mtop->moleculeBlockIndices[*moleculeBlock]; + const gmx_molblock_t& molb = mtop.molblock[*moleculeBlock]; + const t_atoms& atoms = mtop.moltype[molb.type].atoms; + const MoleculeBlockIndices& indices = mtop.moleculeBlockIndices[*moleculeBlock]; if (atomName != nullptr) { *atomName = *(atoms.atomname[atomIndexInMolecule]); } if (residueNumber != nullptr) { - if (atoms.nres > mtop->maxResiduesPerMoleculeToTriggerRenumber()) + if (atoms.nres > mtop.maxResiduesPerMoleculeToTriggerRenumber()) { *residueNumber = atoms.resinfo[atoms.atom[atomIndexInMolecule].resind].nr; } @@ -241,19 +241,6 @@ static inline void mtopGetAtomAndResidueName(const gmx_mtop_t* mtop, } } -//! \copydoc mtopGetAtomAndResidueName() -static inline void mtopGetAtomAndResidueName(const gmx_mtop_t& mtop, - int globalAtomIndex, - int* moleculeBlock, - const char** atomName, - int* residueNumber, - const char** residueName, - int* globalResidueIndex) -{ - mtopGetAtomAndResidueName( - &mtop, globalAtomIndex, moleculeBlock, atomName, residueNumber, residueName, globalResidueIndex); -} - /*! \brief Returns residue information for an atom based on global atom index * * The atom index has to be in range: 0 <= \p globalAtomIndex < \p mtop->natoms. @@ -266,11 +253,11 @@ static inline void mtopGetAtomAndResidueName(const gmx_mtop_t& mtop, * \param[in] globalAtomIndex The global atom index to look up * \param[in,out] moleculeBlock The molecule block index in \p mtop */ -static inline const t_resinfo& mtopGetResidueInfo(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock) +static inline const t_resinfo& mtopGetResidueInfo(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock) { int atomIndexInMolecule = 0; mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule); - const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type]; + const gmx_moltype_t& moltype = mtop.moltype[mtop.molblock[*moleculeBlock].type]; const int resind = moltype.atoms.atom[atomIndexInMolecule].resind; return moltype.atoms.resinfo[resind]; } @@ -287,11 +274,11 @@ static inline const t_resinfo& mtopGetResidueInfo(const gmx_mtop_t* mtop, int gl * \param[in] globalAtomIndex The global atom index to look up * \param[in,out] moleculeBlock The molecule block index in \p mtop */ -static inline const t_pdbinfo& mtopGetAtomPdbInfo(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock) +static inline const t_pdbinfo& mtopGetAtomPdbInfo(const gmx_mtop_t& mtop, int globalAtomIndex, int* moleculeBlock) { int atomIndexInMolecule = 0; mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule); - const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type]; + const gmx_moltype_t& moltype = mtop.moltype[mtop.molblock[*moleculeBlock].type]; GMX_ASSERT(moltype.atoms.havePdbInfo, "PDB information not present when requested"); return moltype.atoms.pdbinfo[atomIndexInMolecule]; } diff --git a/src/gromacs/topology/mtop_util.cpp b/src/gromacs/topology/mtop_util.cpp index add097ca32..59e9e13356 100644 --- a/src/gromacs/topology/mtop_util.cpp +++ b/src/gromacs/topology/mtop_util.cpp @@ -57,15 +57,15 @@ #include "gromacs/utility/real.h" #include "gromacs/utility/smalloc.h" -void gmx_mtop_count_atomtypes(const gmx_mtop_t* mtop, int state, int typecount[]) +void gmx_mtop_count_atomtypes(const gmx_mtop_t& mtop, int state, int typecount[]) { - for (int i = 0; i < mtop->ffparams.atnr; ++i) + for (int i = 0; i < mtop.ffparams.atnr; ++i) { typecount[i] = 0; } - for (const gmx_molblock_t& molb : mtop->molblock) + for (const gmx_molblock_t& molb : mtop.molblock) { - const t_atoms& atoms = mtop->moltype[molb.type].atoms; + const t_atoms& atoms = mtop.moltype[molb.type].atoms; for (int i = 0; i < atoms.nr; ++i) { const int tpi = (state == 0) ? atoms.atom[i].type : atoms.atom[i].typeB; @@ -84,12 +84,12 @@ int gmx_mtop_num_molecules(const gmx_mtop_t& mtop) return numMolecules; } -int gmx_mtop_nres(const gmx_mtop_t* mtop) +int gmx_mtop_nres(const gmx_mtop_t& mtop) { int nres = 0; - for (const gmx_molblock_t& molb : mtop->molblock) + for (const gmx_molblock_t& molb : mtop.molblock) { - nres += molb.nmol * mtop->moltype[molb.type].atoms.nres; + nres += molb.nmol * mtop.moltype[molb.type].atoms.nres; } return nres; } @@ -184,23 +184,23 @@ int AtomProxy::atomNumberInMol() const return it_->localAtomNumber_; } -typedef struct gmx_mtop_atomloop_block +struct gmx_mtop_atomloop_block { const gmx_mtop_t* mtop; size_t mblock; const t_atoms* atoms; int at_local; -} t_gmx_mtop_atomloop_block; +}; -gmx_mtop_atomloop_block_t gmx_mtop_atomloop_block_init(const gmx_mtop_t* mtop) +gmx_mtop_atomloop_block_t gmx_mtop_atomloop_block_init(const gmx_mtop_t& mtop) { struct gmx_mtop_atomloop_block* aloop = nullptr; snew(aloop, 1); - aloop->mtop = mtop; + aloop->mtop = &mtop; aloop->mblock = 0; - aloop->atoms = &mtop->moltype[mtop->molblock[aloop->mblock].type].atoms; + aloop->atoms = &mtop.moltype[mtop.molblock[aloop->mblock].type].atoms; aloop->at_local = -1; return aloop; @@ -244,23 +244,18 @@ typedef struct gmx_mtop_ilistloop int mblock; } t_gmx_mtop_ilist; -gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t* mtop) +gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t& mtop) { struct gmx_mtop_ilistloop* iloop = nullptr; snew(iloop, 1); - iloop->mtop = mtop; + iloop->mtop = &mtop; iloop->mblock = -1; return iloop; } -gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t& mtop) -{ - return gmx_mtop_ilistloop_init(&mtop); -} - static void gmx_mtop_ilistloop_destroy(gmx_mtop_ilistloop_t iloop) { sfree(iloop); @@ -298,7 +293,7 @@ typedef struct gmx_mtop_ilistloop_all int a_offset; } t_gmx_mtop_ilist_all; -int gmx_mtop_ftype_count(const gmx_mtop_t* mtop, int ftype) +int gmx_mtop_ftype_count(const gmx_mtop_t& mtop, int ftype) { int nmol = 0; int n = 0; @@ -309,19 +304,14 @@ int gmx_mtop_ftype_count(const gmx_mtop_t* mtop, int ftype) n += nmol * (*il)[ftype].size() / (1 + NRAL(ftype)); } - if (mtop->bIntermolecularInteractions) + if (mtop.bIntermolecularInteractions) { - n += (*mtop->intermolecular_ilist)[ftype].size() / (1 + NRAL(ftype)); + n += (*mtop.intermolecular_ilist)[ftype].size() / (1 + NRAL(ftype)); } return n; } -int gmx_mtop_ftype_count(const gmx_mtop_t& mtop, int ftype) -{ - return gmx_mtop_ftype_count(&mtop, ftype); -} - int gmx_mtop_interaction_count(const gmx_mtop_t& mtop, const int unsigned if_flags) { int n = 0; @@ -478,19 +468,19 @@ static void atomcat(t_atoms* dest, const t_atoms* src, int copies, int maxres_re dest->nr += copies * src->nr; } -t_atoms gmx_mtop_global_atoms(const gmx_mtop_t* mtop) +t_atoms gmx_mtop_global_atoms(const gmx_mtop_t& mtop) { t_atoms atoms; init_t_atoms(&atoms, 0, FALSE); - int maxresnr = mtop->maxResNumberNotRenumbered(); - for (const gmx_molblock_t& molb : mtop->molblock) + int maxresnr = mtop.maxResNumberNotRenumbered(); + for (const gmx_molblock_t& molb : mtop.molblock) { atomcat(&atoms, - &mtop->moltype[molb.type].atoms, + &mtop.moltype[molb.type].atoms, molb.nmol, - mtop->maxResiduesPerMoleculeToTriggerRenumber(), + mtop.maxResiduesPerMoleculeToTriggerRenumber(), &maxresnr); } @@ -974,7 +964,7 @@ static void gen_t_topology(const gmx_mtop_t& mtop, bool bMergeConstr, t_topology copyIListsFromMtop(mtop, &top->idef, bMergeConstr); top->name = mtop.name; - top->atoms = gmx_mtop_global_atoms(&mtop); + top->atoms = gmx_mtop_global_atoms(mtop); top->mols = gmx_mtop_molecules_t_block(mtop); top->bIntermolecularInteractions = mtop.bIntermolecularInteractions; top->symtab = mtop.symtab; @@ -996,11 +986,11 @@ t_topology gmx_mtop_t_to_t_topology(gmx_mtop_t* mtop, bool freeMTop) return top; } -std::vector get_atom_index(const gmx_mtop_t* mtop) +std::vector get_atom_index(const gmx_mtop_t& mtop) { std::vector atom_index; - for (const AtomProxy atomP : AtomRange(*mtop)) + for (const AtomProxy atomP : AtomRange(mtop)) { const t_atom& local = atomP.atom(); int index = atomP.globalAtomNumber(); diff --git a/src/gromacs/topology/mtop_util.h b/src/gromacs/topology/mtop_util.h index 91683733e2..9d7330226a 100644 --- a/src/gromacs/topology/mtop_util.h +++ b/src/gromacs/topology/mtop_util.h @@ -63,7 +63,7 @@ struct t_symtab; * state A and 1 for state B types. typecount should have at * least mtop->ffparams.atnr elements. */ -void gmx_mtop_count_atomtypes(const gmx_mtop_t* mtop, int state, int typecount[]); +void gmx_mtop_count_atomtypes(const gmx_mtop_t& mtop, int state, int typecount[]); /*!\brief Returns the total number of molecules in mtop * @@ -72,7 +72,7 @@ void gmx_mtop_count_atomtypes(const gmx_mtop_t* mtop, int state, int typecount[] int gmx_mtop_num_molecules(const gmx_mtop_t& mtop); /* Returns the total number of residues in mtop. */ -int gmx_mtop_nres(const gmx_mtop_t* mtop); +int gmx_mtop_nres(const gmx_mtop_t& mtop); class AtomIterator; @@ -163,7 +163,7 @@ typedef struct gmx_mtop_atomloop_block* gmx_mtop_atomloop_block_t; /* Initialize an atom loop over atoms in all molecule blocks the system. */ -gmx_mtop_atomloop_block_t gmx_mtop_atomloop_block_init(const gmx_mtop_t* mtop); +gmx_mtop_atomloop_block_t gmx_mtop_atomloop_block_init(const gmx_mtop_t& mtop); /* Loop to the next atom. * When not at the end: @@ -184,9 +184,6 @@ gmx_bool gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop, const t_a /* Abstract type for ilist loop over all ilists */ typedef struct gmx_mtop_ilistloop* gmx_mtop_ilistloop_t; -/* Initialize an ilist loop over all molecule types in the system. */ -gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t* mtop); - /* Initialize an ilist loop over all molecule types in the system. */ gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t& mtop); @@ -198,9 +195,6 @@ gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t& mtop); */ const InteractionLists* gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop, int* nmol); -/* Returns the total number of interactions in the system of type ftype */ -int gmx_mtop_ftype_count(const gmx_mtop_t* mtop, int ftype); - /* Returns the total number of interactions in the system of type ftype */ int gmx_mtop_ftype_count(const gmx_mtop_t& mtop, int ftype); @@ -211,7 +205,7 @@ int gmx_mtop_interaction_count(const gmx_mtop_t& mtop, int unsigned if_flags); gmx::EnumerationArray gmx_mtop_particletype_count(const gmx_mtop_t& mtop); /* Returns a single t_atoms struct for the whole system */ -t_atoms gmx_mtop_global_atoms(const gmx_mtop_t* mtop); +t_atoms gmx_mtop_global_atoms(const gmx_mtop_t& mtop); /*! \brief @@ -264,7 +258,7 @@ t_topology gmx_mtop_t_to_t_topology(gmx_mtop_t* mtop, bool freeMTop); * \param[in] mtop Molecular topology * \returns Vector that will be filled with the atom indices */ -std::vector get_atom_index(const gmx_mtop_t* mtop); +std::vector get_atom_index(const gmx_mtop_t& mtop); /*! \brief Converts a t_atoms struct to an mtop struct * diff --git a/src/gromacs/trajectoryanalysis/topologyinformation.cpp b/src/gromacs/trajectoryanalysis/topologyinformation.cpp index 9ce030f5f7..d387e8b9dc 100644 --- a/src/gromacs/trajectoryanalysis/topologyinformation.cpp +++ b/src/gromacs/trajectoryanalysis/topologyinformation.cpp @@ -121,7 +121,7 @@ AtomsDataPtr makeAtoms(const TopologyInformation& top_) AtomsDataPtr atoms(new t_atoms); if (top_.hasTopology()) { - *atoms = gmx_mtop_global_atoms(top_.mtop()); + *atoms = gmx_mtop_global_atoms(*top_.mtop()); } else { -- 2.22.0