Bulk change to const ref for mtop
authorPaul Bauer <paul.bauer.q@gmail.com>
Fri, 19 Mar 2021 11:45:06 +0000 (12:45 +0100)
committerJoe Jordan <ejjordan12@gmail.com>
Fri, 19 Mar 2021 14:01:24 +0000 (14:01 +0000)
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.

83 files changed:
api/gmxapi/cpp/tpr.cpp
api/legacy/include/gromacs/fileio/confio.h
api/legacy/include/gromacs/fileio/tpxio.h
api/legacy/include/gromacs/fileio/trxio.h
src/gromacs/coordinateio/coordinatefile.cpp
src/gromacs/domdec/domdec_constraints.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/fileio/confio.cpp
src/gromacs/fileio/groio.cpp
src/gromacs/fileio/groio.h
src/gromacs/fileio/tpxio.cpp
src/gromacs/gmxana/gmx_clustsize.cpp
src/gromacs/gmxana/gmx_disre.cpp
src/gromacs/gmxana/gmx_nmeig.cpp
src/gromacs/gmxana/gmx_nmr.cpp
src/gromacs/gmxpreprocess/genconf.cpp
src/gromacs/gmxpreprocess/genrestr.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/insert_molecules.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/readir.h
src/gromacs/gmxpreprocess/readpull.cpp
src/gromacs/gmxpreprocess/solvate.cpp
src/gromacs/imd/imd.cpp
src/gromacs/imd/imd.h
src/gromacs/listed_forces/disre.cpp
src/gromacs/listed_forces/disre.h
src/gromacs/listed_forces/orires.cpp
src/gromacs/listed_forces/orires.h
src/gromacs/mdlib/dispersioncorrection.cpp
src/gromacs/mdlib/mdatoms.cpp
src/gromacs/mdlib/mdoutf.cpp
src/gromacs/mdlib/mdoutf.h
src/gromacs/mdlib/membed.cpp
src/gromacs/mdlib/trajectory_writing.cpp
src/gromacs/mdlib/trajectory_writing.h
src/gromacs/mdlib/update_vv.cpp
src/gromacs/mdlib/update_vv.h
src/gromacs/mdlib/updategroupscog.cpp
src/gromacs/mdlib/vsite.cpp
src/gromacs/mdrun/isimulator.h
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/shellfc.cpp
src/gromacs/mdrun/shellfc.h
src/gromacs/mdrun/simulatorbuilder.h
src/gromacs/mdrun/tpi.cpp
src/gromacs/modularsimulator/computeglobalselement.cpp
src/gromacs/modularsimulator/computeglobalselement.h
src/gromacs/modularsimulator/energydata.cpp
src/gromacs/modularsimulator/energydata.h
src/gromacs/modularsimulator/forceelement.cpp
src/gromacs/modularsimulator/forceelement.h
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/modularsimulator/simulatoralgorithm.cpp
src/gromacs/modularsimulator/statepropagatordata.cpp
src/gromacs/modularsimulator/statepropagatordata.h
src/gromacs/modularsimulator/trajectoryelement.cpp
src/gromacs/modularsimulator/trajectoryelement.h
src/gromacs/pulling/pull.cpp
src/gromacs/pulling/pull.h
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/pulling/pull_rotation.h
src/gromacs/selection/centerofmass.cpp
src/gromacs/selection/indexutil.cpp
src/gromacs/selection/selection.cpp
src/gromacs/selection/sm_simple.cpp
src/gromacs/swap/swapcoords.cpp
src/gromacs/swap/swapcoords.h
src/gromacs/taskassignment/resourcedivision.cpp
src/gromacs/taskassignment/resourcedivision.h
src/gromacs/tools/convert_tpr.cpp
src/gromacs/tools/make_ndx.cpp
src/gromacs/tools/pme_error.cpp
src/gromacs/tools/report_methods.cpp
src/gromacs/tools/tune_pme.cpp
src/gromacs/topology/mtop_lookup.h
src/gromacs/topology/mtop_util.cpp
src/gromacs/topology/mtop_util.h
src/gromacs/trajectoryanalysis/topologyinformation.cpp

index 2ea116e36283d8927bf447251fb891d2d52e2d11..b59f7f971e8d405250dc202371ea485beaf7edfe 100644 (file)
@@ -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;
index 08af69c205ef465e727c040d8a9b9fa2e8bcaa8c..bd69125d2efc884dc358ae3920cb252e5b05d630 100644 (file)
@@ -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,
index 08229c62a4bcb7866b3c3d91352a41267850330b..96ff4f6ca532bcdf004ee6b85583b3cd3c34ccce 100644 (file)
@@ -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.
  */
 
index ae1660c99ac33d13a573fa019f278b227183fba3..9e9bedf421750bf06218830f929759a0f0a88f64 100644 (file)
@@ -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<const int> index,
                                               const char*              index_group_name);
 
index 2899ed0db8313c1cd65ca89b550aba50b219571c..549e37693e5547f67a3053df764c271e0b7a6d26 100644 (file)
@@ -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");
     }
 }
index 8afb7c9bf7096cdb1280f84ebc18081d8ca78d47..9bc5a5378d87ff00ea18bca7cf274492b3cdd988 100644 (file)
@@ -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];
 
index d4c9de8e34599f0980ff97637a46a4d1f06979e9..fa612d238d880bbffe15e6013c87dd036aa32475 100644 (file)
@@ -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]);
index fe71e265d94bd9548a44677dd7339cb1098df446..6af30e2a01c4814fa835719a87072e2db7a7aa72 100644 (file)
@@ -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);
 
index fdc1ebcb41d0bb92202b4e801da1a18fa6a2aced..4852b720b8b8127c24954ecbb96cb37d86463758 100644 (file)
@@ -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();
index 3361893f9a93a5bf877699cc4a5b85098283f538..c310cf6ef699e2aed9253b2d3542b2a7fefcd723 100644 (file)
@@ -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,
index bcaaca2b8885eb0c01bdd48b78757a5a0e75b6ec..3d1dbb3c68bc5981c03fdc8b96ad7bb557ab2ff9 100644 (file)
@@ -2536,7 +2536,7 @@ static void set_disres_npair(gmx_mtop_t* mtop)
 
     gmx::ArrayRef<t_iparams> 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<t_state*>(state),
                 nullptr,
                 nullptr,
-                const_cast<gmx_mtop_t*>(mtop));
+                const_cast<gmx_mtop_t*>(&mtop));
 
     std::vector<char> tprBody = tprBodySerializer.finishAndGetBuffer();
     tpx.sizeOfTprBody         = tprBody.size();
index 44ec18ba8c880e2e82dc8e352de484f2334b4688..154728d519c9ad3584ca564297e4543b9f019b06 100644 (file)
@@ -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++)
index 5f32405b245bf9ab134edf680966acfd041b46c2..54865bc6129c00c604296a9ad916ce85c2e46e88 100644 (file)
@@ -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,
index 7f308a16f054ae9e753f0512b9e357fff7f86653..8d31e789275ed3ec1be783e741e4c9417afbdd23 100644 (file)
@@ -545,7 +545,7 @@ int gmx_nmeig(int argc, char* argv[])
     {
         nharm = get_nharm(&mtop);
     }
-    std::vector<int> atom_index = get_atom_index(&mtop);
+    std::vector<int> atom_index = get_atom_index(mtop);
 
     top = gmx_mtop_t_to_t_topology(&mtop, true);
 
index 7a6ac17faa8a0b1dd770332dd7215fce827b9d71..d98f5fc236b5f2f2f5c7813ff28962eaf55cbb2e 100644 (file)
@@ -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,
index 8f80c794af3abc7f95e5c6e59a412e41c9db102e..d660eb37fad512c241bd7fe58e59d0a41e572573 100644 (file)
@@ -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 */
index 2670ae994b1b83ddd026b14d3813ee2a13719e5e..8a4c60c746ad5ad91bf14a36ecb7f6a746280059 100644 (file)
@@ -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);
index 9bd9996437ca01dc38c42c3342692fb6502ca3c8..11a7d0c551bcd4c01b436179b75c5472125941b2 100644 (file)
@@ -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]);
index 6cc985536a6b9d60d0720ba8d3e66daffbffb0f5..5667dcb9657ef2132c6f1552f30e32f033f417f5 100644 (file)
@@ -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 */
index fba69a3e466320fb97fb17e2ec3eb81c7b497b1b..6eac6098c84539f2e801768ee4aebd68cf1fc61a 100644 (file)
@@ -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)
index a936ef43d5c9263179043cd7d45664fad55cd8d3..dfec8859a6c1a117c9ff012113afce84b286627b 100644 (file)
@@ -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<const t_pull_group> pullGroups,
                      gmx::ArrayRef<const t_pull_coord> 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()
index 60f515da09a3006129917afedbf7d34ba11a025b..f89ff7986eb80f2daa6f75895cdfdc4a7fe495a2 100644 (file)
@@ -549,7 +549,7 @@ void checkPullCoords(gmx::ArrayRef<const t_pull_group> 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<gmx::RVec*>(x), mtop->natoms),
+                gmx::arrayRefFromArray(reinterpret_cast<gmx::RVec*>(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<gmx::RVec*>(x), mtop->natoms),
+                    gmx::arrayRefFromArray(reinterpret_cast<gmx::RVec*>(x), mtop.natoms),
                     pbc,
                     g,
                     c_pullGroupPbcMargin);
index 62ab86c576b55f2f43fc933429ef86dc621555f8..b0a9c09a57a4f70a0692ca148fc6de4431f5c2da 100644 (file)
@@ -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)
index aaec29e3ad02766cc8c3111462814e4182f05f86..edc6a2fed9196013da8c9034c92fa01442916e5a 100644 (file)
@@ -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<ImdSession> 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<ImdSession> 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 */
index 2b0ea596060b97ffb51c24874c516dd52853b164..6c6517717c0c2f85a10c3818a7c49813669c9974 100644 (file)
@@ -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<ImdSession> 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,
index b5630b4aeb1cd49782dd0eb8c6af80fb7244fb0c..8a901875c78e4742b3d72dbdfb5863f8f08479d4 100644 (file)
@@ -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);
index 7d885ab944d7ae810ec9fed17a9cd059f1600221..34aaba06b7690af53cfeb70b520aa92f713fc174 100644 (file)
@@ -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,
index be62d1139b3b5bff96fec672073f000a521977e8..26de7b7725fa9b8e32e80604b37c5d70894eb4b3 100644 (file)
@@ -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;
index bff4c3102fc9606513c0e42cc1b27e0c115d3d86..981cbed67e7b7f9fba31788f4267247a55d53b5b 100644 (file)
@@ -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,
index 2c8976f89ab78ef2c84783d4f631f24a87801f13..4494d09f68c457081a3943ca58d5bea02f7a3ffb 100644 (file)
@@ -150,7 +150,7 @@ DispersionCorrection::TopologyParams::TopologyParams(const gmx_mtop_t&         m
 
             /* Count the types so we avoid natoms^2 operations */
             std::vector<int> 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++)
             {
index 22c1094e9c80632d827f3d7228a5f6db9d711243..025634b9d8ec829fc5d01f8ed10924da2bf0a6b1 100644 (file)
@@ -147,7 +147,7 @@ std::unique_ptr<MDAtoms> 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<MDAtoms> 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)
             {
index 89b70e0f1b54735272011348387e720db3136a74..ee2335ddf7618fd1a11e87c9f9cd4c365f294475 100644 (file)
@@ -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);
         }
     }
 
index 88ef9068bf4457ca672759cae6ed4cbf16fef290..d727d89474859da9c277b2b3072ede37b171957f 100644 (file)
@@ -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,
index 61e676c338dd6874386634a4175b1266df8ae66d..1456ae6c9c567eb80e8f4df3eb9d15794223705e 100644 (file)
@@ -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<gmx_molblock_t>& 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)
index 405174ef7fc228d57602f36bf86c8a390bc5fba4..a7787ea97d5430c1a65ab376a11aeb4070411464 100644 (file)
@@ -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(),
index bb2da643831c590d5ccfb75edf6103c18c13c600..5d60396834b271ae15a046eb58498368ff4cc002 100644 (file)
@@ -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,
index b1d3b76c69c15417d6b21559b379aed919e195f3..aec700bce9900081e3499fda8fd85e49b8543839 100644 (file)
@@ -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,
index 9c56cf4927169b7af1b80f442c4836b2fae14b69..71beb39db58d743e482d2da21e7abd76c6281495 100644 (file)
@@ -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,
index 2739a398bce31f0ca5e9d5bce6bf5cd267f3d473..58cfb7d8ae89a1b88f6127ced7ae2e4d5b22aebf 100644 (file)
@@ -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<const int>       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_
index 44c57af64486253c286ea41fd829da5adc0289d8..adcf0ea8d6f4808d507eb916930e0c5e5bc744ff 100644 (file)
@@ -2587,7 +2587,7 @@ std::unique_ptr<VirtualSitesHandler> 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
         {
index e6957b97fbb3128958a28a3da991727e01964ff5..6e9c6c614992b83188cb27f71bc49c6dd365153e 100644 (file)
@@ -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.
index cb086641f40f40091c9d853af21f4ec3f9c30c2c..6f1409031cfbbfc0823253ee12bb6eba4eedb958 100644 (file)
@@ -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<EssentialDynamics> 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<t_state> 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<UpdateConstrainGpu>(
                 *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,
index a55cb245d1c6dbe5d5f1af6a8c29e7e18aa12816..f64a8c3e5dfc89f9436cf753048410ed44bf4a11 100644 (file)
@@ -218,7 +218,7 @@ void gmx::LegacySimulator::do_mimic()
     if (MASTER(cr))
     {
         MimicCommunicator::init();
-        auto nonConstGlobalTopology = const_cast<gmx_mtop_t*>(top_global);
+        auto nonConstGlobalTopology = const_cast<gmx_mtop_t*>(&top_global);
         MimicCommunicator::sendInitData(nonConstGlobalTopology, state_global->x);
         // TODO: Avoid changing inputrec (#3854)
         auto* nonConstInputrec   = const_cast<t_inputrec*>(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<gmx_mtop_t*>(top_global);
-        nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(*top_global);
+        auto nonConstGlobalTopology                          = const_cast<gmx_mtop_t*>(&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<t_state> 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<gmx::RVec>     fglobal(top_global->natoms);
+            gmx::HostVector<gmx::RVec>     fglobal(top_global.natoms);
             gmx::ArrayRef<gmx::RVec>       ftemp;
             gmx::ArrayRef<const gmx::RVec> flocal = f.view().force();
             if (DOMAINDECOMP(cr))
index 71ea473d500390c3208bcf36a0e762021ff8f85b..33b067bde18f2a084cdd8dcccfc46d584f7b57ef 100644 (file)
@@ -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<double>(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<const int> 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<const unsigned char> 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<real>(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);
     }
 
index a73f407dc72cacded5bba8bdef175c02ec7c15e9..8b11f9630e8464228e297c9bfa2fb78b0d151367 100644 (file)
@@ -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<gmx_mtop_t*>(top_global);
-        nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(*top_global);
+        auto nonConstGlobalTopology                          = const_cast<gmx_mtop_t*>(&top_global);
+        nonConstGlobalTopology->intermolecularExclusionGroup = genQmmmIndices(top_global);
     }
     int*                fep_state = MASTER(cr) ? &state_global->fep_state : nullptr;
     gmx::ArrayRef<real> lambda    = MASTER(cr) ? state_global->lambda : gmx::ArrayRef<real>();
@@ -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,
index 8202effc13b78408d5340807e8a4d20905d3f252..681acd27b272af89f9cd7b427051232dd99b069e 100644 (file)
@@ -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));
 
index dfd8df643c78625686a9ee7b51f0e3f49402cfa3..73c14ac3b5453c08d824dd5b0b2a1f83a69e2505 100644 (file)
@@ -153,20 +153,17 @@ static void pr_shell(FILE* fplog, ArrayRef<const t_shell> 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<RVec>          x,
-                           ArrayRef<RVec>          v,
-                           real                    dt,
-                           ArrayRef<const t_shell> shells,
-                           const real              mass[],
-                           gmx_mtop_t*             mtop,
-                           gmx_bool                bInit)
+static void predict_shells(FILE*                     fplog,
+                           ArrayRef<RVec>            x,
+                           ArrayRef<RVec>            v,
+                           real                      dt,
+                           ArrayRef<const t_shell>   shells,
+                           gmx::ArrayRef<const real> 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<ParticleType, int> numParticles = gmx_mtop_particletype_count(*mtop);
+    const gmx::EnumerationArray<ParticleType, int> 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<int> shell_index(mtop->natoms);
+    std::vector<int> 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<t_shell> 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 */
index 61bf701ff5f378c8278e5e0af5951b8f64572a3e..76722cd33f85b086b6ee0827fa3604af4e5dc6b8 100644 (file)
@@ -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,
index 761d3af220ebee7aff52ec1f26d14837a992eefb..3bd22bb769686a6d232899fdbf21e9036c8a7659 100644 (file)
@@ -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;
 };
index f392cadfdc189e4f2da7ee8c23589dfeebcaf59b..819532068e54db33e48d006295fb29b4b3d72f83 100644 (file)
@@ -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);
index f5f4e674704be0e06de2c6b698cd6e9e6de52bea..3f7ce609ad7f41b19ae7f6bc46642130c39632e4 100644 (file)
@@ -79,7 +79,7 @@ ComputeGlobalsElement<algorithm>::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<algorithm>::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<algorithm>::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);
index b949145703a85b7f42c6030d6a3014dad1367e6e..2ae60fa09605a4ce935e21d477b793340904c975 100644 (file)
@@ -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.
index 83e02e92f608518e66857dbe02b237d155023067..30d55811d566ae7c3cd1bc510f5f92102406e90f 100644 (file)
@@ -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<EnergyOutput>(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);
index 29e2a0d28f4829f98e86ece3842c54b6deb72905..bc0c55dc3081cf32c004721217ee7d9ee1a2b507 100644 (file)
@@ -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
index cce364f9fce21b65ab50d89633cf3802397b9109..48fa24754d18f97871a9de6f0335f1e1abbabf6c 100644 (file)
@@ -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,
index 3e5318a28257ff4a8f8a17ef8440442f7e9262e0..27ba90a665d07590c3701ec5b17106d87923a8c1 100644 (file)
@@ -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
index b285fc054c5819f8825e5aea0f2b74cdbc248d4b..5bb98e9afa0da9e49858fe53554bdb80e5c039c9 100644 (file)
@@ -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(),
index 29e24c013f03c41647e583967faebb1f3cb072b4..df6082988927e7dce9406ae69f74f2442fc35631 100644 (file)
@@ -411,7 +411,7 @@ ModularSimulatorAlgorithmBuilder::ModularSimulatorAlgorithmBuilder(
     }
 
     statePropagatorData_ = std::make_unique<StatePropagatorData>(
-            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,
index 7baae2123f3e16c69fe7116f780f832ce0146f8a..cbafcfb871cd27f6e195b1db57b7b6ae248f5b64 100644 (file)
@@ -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),
index fe277200617671a5cdbf863b6123a240db7869e7..3994d8b62486857714168dffad3f77fe7141cbb6 100644 (file)
@@ -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
index 5a4b55cbabf164a515d282bca1642c5c52cb8272..69ff93835720dc8aa1342000672b04bf17df0a20 100644 (file)
@@ -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<ITrajectoryWriterClient*> 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,
index 5b3d60001948fda0823b66bcf714070214f003a0..8c93b5a881116516f6813ad4326c6cb6064cedf0 100644 (file)
@@ -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,
index b0da21552c140cb42325a6e3cd2f253f089bafa7..ae29d66801edcef995d39581182a6325b24fc219 100644 (file)
@@ -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<real>& 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)
index 2f87228ecb929a2edfe1c7d9827cabb7c9f6d4bc..a91784cf835d8e96915e2d18b1460afc7b8b57fa 100644 (file)
@@ -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);
index 20abd248b9b24a4610f5c71493df2dafbf167b54..ab10a7a8a8740def7f291adfd2688b6b4afd2916 100644 (file)
@@ -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<gmx::EnforcedRotation> 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<gmx::EnforcedRotation> 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
index 56cb1907556045954555aafd1f041b4123c0992b..de5f1388a06590ab7fcfa205c01c57cc72320350 100644 (file)
@@ -119,7 +119,7 @@ std::unique_ptr<gmx::EnforcedRotation> 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);
index 356482ccd1a0163c7f1aa2fad097d45ec3b23686..f76ecbd6e0c5e1b045c23cdf845f16b13a32a66c 100644 (file)
@@ -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;
index 160676281c78f60f3987e1103b67c8a5e7f64e64..af168f624213487debb70d978916042bdd72da92 100644 (file)
@@ -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;
             }
index b3cadb741db840685eb8e0778f617d6cf9bc1a11..34fbee597329e6b8bd5647bd02f1ed4e81b51a8b 100644 (file)
@@ -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;
         }
index 2083f1203302decf93cb9f99661731200426c55f..1dbc4f0fafa857086fd99ea6aeb93ece5960e269 100644 (file)
@@ -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<char*>(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;
     }
 }
 
index 2880c81e338cfbbe662842599f9fef6b9817373b..102f863d0e31aee637462db4260ce330927153e7 100644 (file)
@@ -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 */
index cafddc68c2255cf9fdaa78b6c9dd1be4fade9bee..ec8fdd540d56605e0faa26df1688ae8effd4380d 100644 (file)
@@ -107,7 +107,7 @@ std::unique_ptr<IMDModule> 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,
index 03c80d89e69ef8a6cb9e1afdbe945c6be8060861..388406bf792450ba4c017ac14231931d33bd88b8 100644 (file)
@@ -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)
index c45ed954939848314a45f63525b9bc8043ae7e67..f9e7151186a63c39fece0bae03ae09b871f6c311 100644 (file)
@@ -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);
 
index 66922ac5c6b77fbfede924016b4f247d1035bbd0..3aaaf35f9eb543f071807a1033c4e61107f1bde4 100644 (file)
@@ -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<bool> bKeep    = bKeepIt(gnx, atoms.nr, index);
     const std::vector<int>  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
     {
index 34ecf8179847b002e30cef56fc4f7724f5753521..3f8dbe2aad8234783c3824b80e090acd81b61847 100644 (file)
@@ -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);
index 15ce914844092ece10d6960e3b0d54562b4971c9..2ada54a7476d84fdea6500f5110eed3bc89b470d 100644 (file)
@@ -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);
index af45b6005ee57dfc2a3625ce32b6bd1d1f6d4a0e..eb8fd2eb068fec7529e45bd585fc1f9833f56202 100644 (file)
@@ -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)
index 216fb0cf3e990fd43c8212af0c1a87f1f77cbae2..3c8e9857c870fa1b14ac24c9bba56cef924e33cc 100644 (file)
@@ -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);
index f0395eb75e113c5f4be5fffa638ec1308b1973c5..8b9c4befee492a51a3e4658a3904c110f8554357 100644 (file)
@@ -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];
 }
index add097ca32eaab29a21a5a44a30299f4e8fba9f2..59e9e133569b5d8f2d8e84c5d986c3bce5125e7b 100644 (file)
 #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<int> get_atom_index(const gmx_mtop_t* mtop)
+std::vector<int> get_atom_index(const gmx_mtop_t& mtop)
 {
 
     std::vector<int> atom_index;
-    for (const AtomProxy atomP : AtomRange(*mtop))
+    for (const AtomProxy atomP : AtomRange(mtop))
     {
         const t_atom& local = atomP.atom();
         int           index = atomP.globalAtomNumber();
index 91683733e2101dd06332a4cd9a456c62cd23e83c..9d7330226a07cb119c9cc6c85f39b6cfbe18c580 100644 (file)
@@ -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<ParticleType, int> 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<int> get_atom_index(const gmx_mtop_t* mtop);
+std::vector<int> get_atom_index(const gmx_mtop_t& mtop);
 
 /*! \brief Converts a t_atoms struct to an mtop struct
  *
index 9ce030f5f77c9ce0aef6c5e9ccf371c8c5f7f1d0..d387e8b9dc941b5c6e4f980f107a038acd5ff26d 100644 (file)
@@ -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
     {