Use const ref to inputrec in do_force
authorJoe Jordan <ejjordan12@gmail.com>
Tue, 16 Feb 2021 13:43:14 +0000 (13:43 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 16 Feb 2021 13:43:14 +0000 (13:43 +0000)
Inputrec can be const at the level of do_force and below. This
will make subsequent refactorings in, e.g. setup code called
within do_force, easier.

19 files changed:
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/essentialdynamics/edsam.h
src/gromacs/ewald/ewald.cpp
src/gromacs/ewald/ewald.h
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/force.h
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/forcerec.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/wall.cpp
src/gromacs/mdlib/wall.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/tpi.cpp
src/gromacs/modularsimulator/forceelement.cpp

index 4861086a578c846d96284b5bdbee8acb9696047d..d6e48099d6d05c346749b93ba45e8b62dc38b10c 100644 (file)
@@ -1028,7 +1028,7 @@ static void do_single_flood(FILE*            edo,
 
 /* Main flooding routine, called from do_force */
 extern void do_flood(const t_commrec*  cr,
-                     const t_inputrec* ir,
+                     const t_inputrec& ir,
                      const rvec        x[],
                      rvec              force[],
                      gmx_edsam*        ed,
@@ -1040,7 +1040,7 @@ extern void do_flood(const t_commrec*  cr,
      * it in the output file for ED constraints. */
     if (MASTER(cr) && do_per_step(step, ed->edpar.begin()->outfrq))
     {
-        fprintf(ed->edo, "\n%12f", ir->init_t + step * ir->delta_t);
+        fprintf(ed->edo, "\n%12f", ir.init_t + step * ir.delta_t);
     }
 
     if (ed->eEDtype != EssentialDynamicsType::Flooding)
index e5d03a3f960d699453c5f2f15a1c62dd9cc8c26e..f9bf69246927a6134b30f186f34cea901458251a 100644 (file)
@@ -161,7 +161,7 @@ void dd_make_local_ed_indices(gmx_domdec_t* dd, gmx_edsam* ed);
  * \param bNS               Are we in a neighbor searching step?
  */
 void do_flood(const t_commrec*  cr,
-              const t_inputrec* ir,
+              const t_inputrec& ir,
               const rvec        x[],
               rvec              force[],
               gmx_edsam*        ed,
index 6e089c2b99c511867ac4f7fa33c608667d4e5c00..81e6bb4709ca51ff9429dc04085691d276032e90 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.
@@ -78,7 +78,7 @@ struct gmx_ewald_tab_t
     t_complex *tab_xy, *tab_qxyz;
 };
 
-void init_ewald_tab(struct gmx_ewald_tab_t** et, const t_inputrec* ir, FILE* fp)
+void init_ewald_tab(struct gmx_ewald_tab_t** et, const t_inputrec& ir, FILE* fp)
 {
     snew(*et, 1);
     if (fp)
@@ -86,9 +86,9 @@ void init_ewald_tab(struct gmx_ewald_tab_t** et, const t_inputrec* ir, FILE* fp)
         fprintf(fp, "Will do ordinary reciprocal space Ewald sum.\n");
     }
 
-    (*et)->nx       = ir->nkx + 1;
-    (*et)->ny       = ir->nky + 1;
-    (*et)->nz       = ir->nkz + 1;
+    (*et)->nx       = ir.nkx + 1;
+    (*et)->ny       = ir.nky + 1;
+    (*et)->nz       = ir.nkz + 1;
     (*et)->kmax     = std::max((*et)->nx, std::max((*et)->ny, (*et)->nz));
     (*et)->eir      = nullptr;
     (*et)->tab_xy   = nullptr;
@@ -137,7 +137,7 @@ static void tabulateStructureFactors(int natom, const rvec x[], int kmax, cvec**
     }
 }
 
-real do_ewald(const t_inputrec* ir,
+real do_ewald(const t_inputrec& ir,
               const rvec        x[],
               rvec              f[],
               const real        chargeA[],
@@ -169,7 +169,7 @@ real do_ewald(const t_inputrec* ir,
 
     /* Scale box with Ewald wall factor */
     matrix          scaledBox;
-    EwaldBoxZScaler boxScaler(*ir);
+    EwaldBoxZScaler boxScaler(ir);
     boxScaler.scaleBox(box, scaledBox);
 
     rvec boxDiag;
@@ -179,7 +179,7 @@ real do_ewald(const t_inputrec* ir,
     }
 
     /* 1/(Vol*e0) */
-    real scaleRecip = 4.0 * M_PI / (boxDiag[XX] * boxDiag[YY] * boxDiag[ZZ]) * ONE_4PI_EPS0 / ir->epsilon_r;
+    real scaleRecip = 4.0 * M_PI / (boxDiag[XX] * boxDiag[YY] * boxDiag[ZZ]) * ONE_4PI_EPS0 / ir.epsilon_r;
 
     if (!et->eir) /* allocate if we need to */
     {
@@ -192,7 +192,7 @@ real do_ewald(const t_inputrec* ir,
         snew(et->tab_qxyz, natoms);
     }
 
-    bFreeEnergy = (ir->efep != efepNO);
+    bFreeEnergy = (ir.efep != efepNO);
 
     clear_mat(lrvir);
 
index 77fc79b3fa16b066e4ffd752bb59f0acfe4253bd..7fc31df1e869c996ee9597473d2ad054e500a621 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.
@@ -79,10 +79,10 @@ struct t_inputrec;
 struct gmx_ewald_tab_t;
 
 /*! \brief Initialize the tables used in the Ewald long-ranged part */
-void init_ewald_tab(struct gmx_ewald_tab_t** et, const t_inputrec* ir, FILE* fp);
+void init_ewald_tab(struct gmx_ewald_tab_t** et, const t_inputrec& ir, FILE* fp);
 
 /*! \brief Do the long-ranged part of an Ewald calculation */
-real do_ewald(const t_inputrec* ir,
+real do_ewald(const t_inputrec& ir,
               const rvec        x[],
               rvec              f[],
               const real        chargeA[],
index 6b9996def91ad2acd7f115f60b897377eb33fabe..a17b332848d4411e3f41b24884b2bd38d672a778 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.
@@ -99,7 +99,7 @@ static void reduceEwaldThreadOuput(int nthreads, ewald_corr_thread_t* ewc_t)
 }
 
 void calculateLongRangeNonbondeds(t_forcerec*                   fr,
-                                  const t_inputrec*             ir,
+                                  const t_inputrec&             ir,
                                   const t_commrec*              cr,
                                   t_nrnb*                       nrnb,
                                   gmx_wallcycle_t               wcycle,
@@ -117,7 +117,7 @@ void calculateLongRangeNonbondeds(t_forcerec*                   fr,
                                  && thisRankHasDuty(cr, DUTY_PME)
                                  && (pme_run_mode(fr->pmedata) == PmeRunMode::CPU);
 
-    const bool haveEwaldSurfaceTerm = haveEwaldSurfaceContribution(*ir);
+    const bool haveEwaldSurfaceTerm = haveEwaldSurfaceContribution(ir);
 
     /* Do long-range electrostatics and/or LJ-PME
      * and compute PME surface terms when necessary.
@@ -164,7 +164,7 @@ void calculateLongRangeNonbondeds(t_forcerec*                   fr,
                                            nthreads,
                                            t,
                                            *fr,
-                                           *ir,
+                                           ir,
                                            md->chargeA,
                                            md->chargeB,
                                            (md->nChargePerturbed != 0),
index 608849357fc6deeee04f72dedb5993b6584100ee..6f795d020597775ceb92fd2b157bd98378a4897f 100644 (file)
@@ -92,7 +92,7 @@ class VirtualSitesHandler;
 void do_force(FILE*                               log,
               const t_commrec*                    cr,
               const gmx_multisim_t*               ms,
-              const t_inputrec*                   inputrec,
+              const t_inputrec&                   inputrec,
               gmx::Awh*                           awh,
               gmx_enfrot*                         enforcedRotation,
               gmx::ImdSession*                    imdSession,
@@ -134,7 +134,7 @@ void do_force(FILE*                               log,
  * on whether the PME-mesh contribution is computed on a separate PME rank or on a GPU.
  */
 void calculateLongRangeNonbondeds(t_forcerec*                    fr,
-                                  const t_inputrec*              ir,
+                                  const t_inputrec&              ir,
                                   const t_commrec*               cr,
                                   t_nrnb*                        nrnb,
                                   gmx_wallcycle*                 wcycle,
index 780ecda83e6dd42b5f8789d5210f3f7d941b30a8..b1f0df090084400bd192e56485db27e7eecadc5e 100644 (file)
@@ -636,11 +636,11 @@ static real cutoff_inf(real cutoff)
 
 /*! \brief Print Coulomb Ewald citations and set ewald coefficients */
 static void initCoulombEwaldParameters(FILE*                fp,
-                                       const t_inputrec*    ir,
+                                       const t_inputrec&    ir,
                                        bool                 systemHasNetCharge,
                                        interaction_const_t* ic)
 {
-    if (!EEL_PME_EWALD(ir->coulombtype))
+    if (!EEL_PME_EWALD(ir.coulombtype))
     {
         return;
     }
@@ -649,7 +649,7 @@ static void initCoulombEwaldParameters(FILE*                fp,
     {
         fprintf(fp, "Will do PME sum in reciprocal space for electrostatic interactions.\n");
 
-        if (ir->coulombtype == eelP3M_AD)
+        if (ir.coulombtype == eelP3M_AD)
         {
             please_cite(fp, "Hockney1988");
             please_cite(fp, "Ballenegger2012");
@@ -659,7 +659,7 @@ static void initCoulombEwaldParameters(FILE*                fp,
             please_cite(fp, "Essmann95a");
         }
 
-        if (ir->ewald_geometry == eewg3DC)
+        if (ir.ewald_geometry == eewg3DC)
         {
             if (fp)
             {
@@ -675,7 +675,7 @@ static void initCoulombEwaldParameters(FILE*                fp,
         }
     }
 
-    ic->ewaldcoeff_q = calc_ewaldcoeff_q(ir->rcoulomb, ir->ewald_rtol);
+    ic->ewaldcoeff_q = calc_ewaldcoeff_q(ir.rcoulomb, ir.ewald_rtol);
     if (fp)
     {
         fprintf(fp, "Using a Gaussian width (1/beta) of %g nm for Ewald\n", 1 / ic->ewaldcoeff_q);
@@ -693,9 +693,9 @@ static void initCoulombEwaldParameters(FILE*                fp,
 }
 
 /*! \brief Print Van der Waals Ewald citations and set ewald coefficients */
-static void initVdwEwaldParameters(FILE* fp, const t_inputrec* ir, interaction_const_t* ic)
+static void initVdwEwaldParameters(FILE* fp, const t_inputrec& ir, interaction_const_t* ic)
 {
-    if (!EVDW_PME(ir->vdwtype))
+    if (!EVDW_PME(ir.vdwtype))
     {
         return;
     }
@@ -705,7 +705,7 @@ static void initVdwEwaldParameters(FILE* fp, const t_inputrec* ir, interaction_c
         fprintf(fp, "Will do PME sum in reciprocal space for LJ dispersion interactions.\n");
         please_cite(fp, "Essmann95a");
     }
-    ic->ewaldcoeff_lj = calc_ewaldcoeff_lj(ir->rvdw, ir->ewald_rtol_lj);
+    ic->ewaldcoeff_lj = calc_ewaldcoeff_lj(ir.rvdw, ir.ewald_rtol_lj);
     if (fp)
     {
         fprintf(fp, "Using a Gaussian width (1/beta) of %g nm for LJ Ewald\n", 1 / ic->ewaldcoeff_lj);
@@ -831,7 +831,7 @@ static void potential_switch_constants(real rsw, real rc, switch_consts_t* sc)
  */
 static void init_interaction_const(FILE*                 fp,
                                    interaction_const_t** interaction_const,
-                                   const t_inputrec*     ir,
+                                   const t_inputrec&     ir,
                                    const gmx_mtop_t*     mtop,
                                    bool                  systemHasNetCharge)
 {
@@ -841,12 +841,12 @@ static void init_interaction_const(FILE*                 fp,
     ic->vdwEwaldTables     = std::make_unique<EwaldCorrectionTables>();
 
     /* Lennard-Jones */
-    ic->vdwtype         = ir->vdwtype;
-    ic->vdw_modifier    = ir->vdw_modifier;
+    ic->vdwtype         = ir.vdwtype;
+    ic->vdw_modifier    = ir.vdw_modifier;
     ic->reppow          = mtop->ffparams.reppow;
-    ic->rvdw            = cutoff_inf(ir->rvdw);
-    ic->rvdw_switch     = ir->rvdw_switch;
-    ic->ljpme_comb_rule = ir->ljpme_combination_rule;
+    ic->rvdw            = cutoff_inf(ir.rvdw);
+    ic->rvdw_switch     = ir.rvdw_switch;
+    ic->ljpme_comb_rule = ir.ljpme_combination_rule;
     ic->useBuckingham   = (mtop->ffparams.functype[0] == F_BHAM);
     if (ic->useBuckingham)
     {
@@ -882,11 +882,11 @@ static void init_interaction_const(FILE*                 fp,
     }
 
     /* Electrostatics */
-    ic->eeltype          = ir->coulombtype;
-    ic->coulomb_modifier = ir->coulomb_modifier;
-    ic->rcoulomb         = cutoff_inf(ir->rcoulomb);
-    ic->rcoulomb_switch  = ir->rcoulomb_switch;
-    ic->epsilon_r        = ir->epsilon_r;
+    ic->eeltype          = ir.coulombtype;
+    ic->coulomb_modifier = ir.coulomb_modifier;
+    ic->rcoulomb         = cutoff_inf(ir.rcoulomb);
+    ic->rcoulomb_switch  = ir.rcoulomb_switch;
+    ic->epsilon_r        = ir.epsilon_r;
 
     /* Set the Coulomb energy conversion factor */
     if (ic->epsilon_r != 0)
@@ -903,7 +903,7 @@ static void init_interaction_const(FILE*                 fp,
     if (EEL_RF(ic->eeltype))
     {
         GMX_RELEASE_ASSERT(ic->eeltype != eelGRF_NOTUSED, "GRF is no longer supported");
-        ic->epsilon_rf = ir->epsilon_rf;
+        ic->epsilon_rf = ir.epsilon_rf;
 
         calc_rffac(fp, ic->epsilon_r, ic->epsilon_rf, ic->rcoulomb, &ic->k_rf, &ic->c_rf);
     }
@@ -912,7 +912,7 @@ static void init_interaction_const(FILE*                 fp,
         /* For plain cut-off we might use the reaction-field kernels */
         ic->epsilon_rf = ic->epsilon_r;
         ic->k_rf       = 0;
-        if (ir->coulomb_modifier == eintmodPOTSHIFT)
+        if (ir.coulomb_modifier == eintmodPOTSHIFT)
         {
             ic->c_rf = 1 / ic->rcoulomb;
         }
@@ -946,10 +946,10 @@ static void init_interaction_const(FILE*                 fp,
         fprintf(fp, "\n");
     }
 
-    if (ir->efep != efepNO)
+    if (ir.efep != efepNO)
     {
-        GMX_RELEASE_ASSERT(ir->fepvals, "ir->fepvals should be set wth free-energy");
-        ic->softCoreParameters = std::make_unique<interaction_const_t::SoftCoreParameters>(*ir->fepvals);
+        GMX_RELEASE_ASSERT(ir.fepvals, "ir.fepvals should be set wth free-energy");
+        ic->softCoreParameters = std::make_unique<interaction_const_t::SoftCoreParameters>(*ir.fepvals);
     }
 
     *interaction_const = ic;
@@ -958,7 +958,7 @@ static void init_interaction_const(FILE*                 fp,
 void init_forcerec(FILE*                            fp,
                    const gmx::MDLogger&             mdlog,
                    t_forcerec*                      fr,
-                   const t_inputrec*                ir,
+                   const t_inputrec&                ir,
                    const gmx_mtop_t*                mtop,
                    const t_commrec*                 cr,
                    matrix                           box,
@@ -970,13 +970,13 @@ void init_forcerec(FILE*                            fp,
     /* The CMake default turns SIMD kernels on, but it might be turned off further down... */
     fr->use_simd_kernels = GMX_USE_SIMD_KERNELS;
 
-    if (check_box(ir->pbcType, box))
+    if (check_box(ir.pbcType, box))
     {
-        gmx_fatal(FARGS, "%s", check_box(ir->pbcType, box));
+        gmx_fatal(FARGS, "%s", check_box(ir.pbcType, box));
     }
 
     /* Test particle insertion ? */
-    if (EI_TPI(ir->eI))
+    if (EI_TPI(ir.eI))
     {
         /* Set to the size of the molecule to be inserted (the last one) */
         gmx::RangePartitioning molecules = gmx_mtop_molecules(*mtop);
@@ -987,34 +987,34 @@ void init_forcerec(FILE*                            fp,
         fr->n_tpi = 0;
     }
 
-    if (ir->coulombtype == eelRF_NEC_UNSUPPORTED || ir->coulombtype == eelGRF_NOTUSED)
+    if (ir.coulombtype == eelRF_NEC_UNSUPPORTED || ir.coulombtype == eelGRF_NOTUSED)
     {
-        gmx_fatal(FARGS, "%s electrostatics is no longer supported", eel_names[ir->coulombtype]);
+        gmx_fatal(FARGS, "%s electrostatics is no longer supported", eel_names[ir.coulombtype]);
     }
 
-    if (ir->bAdress)
+    if (ir.bAdress)
     {
         gmx_fatal(FARGS, "AdResS simulations are no longer supported");
     }
-    if (ir->useTwinRange)
+    if (ir.useTwinRange)
     {
         gmx_fatal(FARGS, "Twin-range simulations are no longer supported");
     }
     /* Copy the user determined parameters */
-    fr->userint1  = ir->userint1;
-    fr->userint2  = ir->userint2;
-    fr->userint3  = ir->userint3;
-    fr->userint4  = ir->userint4;
-    fr->userreal1 = ir->userreal1;
-    fr->userreal2 = ir->userreal2;
-    fr->userreal3 = ir->userreal3;
-    fr->userreal4 = ir->userreal4;
+    fr->userint1  = ir.userint1;
+    fr->userint2  = ir.userint2;
+    fr->userint3  = ir.userint3;
+    fr->userint4  = ir.userint4;
+    fr->userreal1 = ir.userreal1;
+    fr->userreal2 = ir.userreal2;
+    fr->userreal3 = ir.userreal3;
+    fr->userreal4 = ir.userreal4;
 
     /* Shell stuff */
-    fr->fc_stepsize = ir->fc_stepsize;
+    fr->fc_stepsize = ir.fc_stepsize;
 
     /* Free energy */
-    fr->efep = ir->efep;
+    fr->efep = ir.efep;
 
     if ((getenv("GMX_DISABLE_SIMD_KERNELS") != nullptr) || (getenv("GMX_NOOPTIMIZEDKERNELS") != nullptr))
     {
@@ -1031,7 +1031,7 @@ void init_forcerec(FILE*                            fp,
     fr->bBHAM = (mtop->ffparams.functype[0] == F_BHAM);
 
     /* Neighbour searching stuff */
-    fr->pbcType = ir->pbcType;
+    fr->pbcType = ir.pbcType;
 
     /* Determine if we will do PBC for distances in bonded interactions */
     if (fr->pbcType == PbcType::No)
@@ -1040,8 +1040,7 @@ void init_forcerec(FILE*                            fp,
     }
     else
     {
-        const bool useEwaldSurfaceCorrection =
-                (EEL_PME_EWALD(ir->coulombtype) && ir->epsilon_surface != 0);
+        const bool useEwaldSurfaceCorrection = (EEL_PME_EWALD(ir.coulombtype) && ir.epsilon_surface != 0);
         const bool haveOrientationRestraints = (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0);
         if (!DOMAINDECOMP(cr))
         {
@@ -1050,7 +1049,7 @@ void init_forcerec(FILE*                            fp,
             if (useEwaldSurfaceCorrection || haveOrientationRestraints)
             {
                 fr->wholeMoleculeTransform =
-                        std::make_unique<gmx::WholeMoleculeTransform>(*mtop, ir->pbcType);
+                        std::make_unique<gmx::WholeMoleculeTransform>(*mtop, ir.pbcType);
             }
         }
         else
@@ -1078,23 +1077,23 @@ void init_forcerec(FILE*                            fp,
         }
     }
 
-    fr->rc_scaling = ir->refcoord_scaling;
-    copy_rvec(ir->posres_com, fr->posres_com);
-    copy_rvec(ir->posres_comB, fr->posres_comB);
-    fr->rlist                  = cutoff_inf(ir->rlist);
-    fr->ljpme_combination_rule = ir->ljpme_combination_rule;
+    fr->rc_scaling = ir.refcoord_scaling;
+    copy_rvec(ir.posres_com, fr->posres_com);
+    copy_rvec(ir.posres_comB, fr->posres_comB);
+    fr->rlist                  = cutoff_inf(ir.rlist);
+    fr->ljpme_combination_rule = ir.ljpme_combination_rule;
 
     /* This now calculates sum for q and c6*/
     bool systemHasNetCharge = set_chargesum(fp, fr, mtop);
 
     /* fr->ic is used both by verlet and group kernels (to some extent) now */
     init_interaction_const(fp, &fr->ic, ir, mtop, systemHasNetCharge);
-    init_interaction_const_tables(fp, fr->ic, fr->rlist, ir->tabext);
+    init_interaction_const_tables(fp, fr->ic, fr->rlist, ir.tabext);
 
     const interaction_const_t* ic = fr->ic;
 
     /* TODO: Replace this Ewald table or move it into interaction_const_t */
-    if (ir->coulombtype == eelEWALD)
+    if (ir.coulombtype == eelEWALD)
     {
         init_ewald_tab(&(fr->ewald_table), ir, fp);
     }
@@ -1157,7 +1156,7 @@ void init_forcerec(FILE*                            fp,
      */
     if (EEL_USER(fr->ic->eeltype))
     {
-        gmx_fatal(FARGS, "Electrostatics type %s is currently not supported", eel_names[ir->coulombtype]);
+        gmx_fatal(FARGS, "Electrostatics type %s is currently not supported", eel_names[ir.coulombtype]);
     }
 
     fr->bvdwtab  = FALSE;
@@ -1167,18 +1166,17 @@ void init_forcerec(FILE*                            fp,
     fr->fudgeQQ = mtop->ffparams.fudgeQQ;
 
     // Multiple time stepping
-    fr->useMts = ir->useMts;
+    fr->useMts = ir.useMts;
 
     if (fr->useMts)
     {
-        GMX_ASSERT(gmx::checkMtsRequirements(*ir).empty(),
-                   "All MTS requirements should be met here");
+        GMX_ASSERT(gmx::checkMtsRequirements(ir).empty(), "All MTS requirements should be met here");
     }
 
-    const bool haveDirectVirialContributionsFast =
-            fr->forceProviders->hasForceProvider() || gmx_mtop_ftype_count(mtop, F_POSRES) > 0
-            || gmx_mtop_ftype_count(mtop, F_FBPOSRES) > 0 || ir->nwall > 0 || ir->bPull || ir->bRot
-            || ir->bIMD;
+    const bool haveDirectVirialContributionsFast = fr->forceProviders->hasForceProvider()
+                                                   || gmx_mtop_ftype_count(mtop, F_POSRES) > 0
+                                                   || gmx_mtop_ftype_count(mtop, F_FBPOSRES) > 0
+                                                   || ir.nwall > 0 || ir.bPull || ir.bRot || ir.bIMD;
     const bool haveDirectVirialContributionsSlow = EEL_FULL(ic->eeltype) || EVDW_PME(ic->vdwtype);
     for (int i = 0; i < (fr->useMts ? 2 : 1); i++)
     {
@@ -1204,7 +1202,7 @@ void init_forcerec(FILE*                            fp,
     }
 
     /* Copy the energy group exclusions */
-    fr->egp_flags = ir->opts.egp_flags;
+    fr->egp_flags = ir.opts.egp_flags;
 
     /* Van der Waals stuff */
     if ((ic->vdwtype != evdwCUT) && (ic->vdwtype != evdwUSER) && !fr->bBHAM)
@@ -1238,7 +1236,7 @@ void init_forcerec(FILE*                            fp,
         gmx_fatal(FARGS, "The Verlet cutoff-scheme does not (yet) support Buckingham");
     }
 
-    if (ir->implicit_solvent)
+    if (ir.implicit_solvent)
     {
         gmx_fatal(FARGS, "Implict solvation is no longer supported.");
     }
@@ -1248,7 +1246,7 @@ void init_forcerec(FILE*                            fp,
      * in that case grompp should already have checked that we do not need
      * normal tables and we only generate tables for 1-4 interactions.
      */
-    real rtab = ir->rlist + ir->tabext;
+    real rtab = ir.rlist + ir.tabext;
 
     /* We want to use unmodified tables for 1-4 coulombic
      * interactions, so we must in general have an extra set of
@@ -1260,8 +1258,8 @@ void init_forcerec(FILE*                            fp,
     }
 
     /* Wall stuff */
-    fr->nwall = ir->nwall;
-    if (ir->nwall && ir->wall_type == ewtTABLE)
+    fr->nwall = ir.nwall;
+    if (ir.nwall && ir.wall_type == ewtTABLE)
     {
         make_wall_tables(fp, ir, tabfn, &mtop->groups, fr);
     }
@@ -1297,7 +1295,7 @@ void init_forcerec(FILE*                            fp,
     {
         // Add one ListedForces object for each MTS level
         bool isFirstLevel = true;
-        for (const auto& mtsLevel : ir->mtsLevels)
+        for (const auto& mtsLevel : ir.mtsLevels)
         {
             ListedForces::InteractionSelection interactionSelection;
             const auto&                        forceGroups = mtsLevel.forceGroups;
@@ -1336,7 +1334,7 @@ void init_forcerec(FILE*                            fp,
     }
 
     // QM/MM initialization if requested
-    if (ir->bQMMM)
+    if (ir.bQMMM)
     {
         gmx_incons("QM/MM was requested, but is no longer available in GROMACS");
     }
@@ -1358,10 +1356,10 @@ void init_forcerec(FILE*                            fp,
     fr->nthread_ewc = gmx_omp_nthreads_get(emntBonded);
     snew(fr->ewc_t, fr->nthread_ewc);
 
-    if (ir->eDispCorr != edispcNO)
+    if (ir.eDispCorr != edispcNO)
     {
         fr->dispersionCorrection = std::make_unique<DispersionCorrection>(
-                *mtop, *ir, fr->bBHAM, fr->ntype, fr->nbfp, *fr->ic, tabfn);
+                *mtop, ir, fr->bBHAM, fr->ntype, fr->nbfp, *fr->ic, tabfn);
         fr->dispersionCorrection->print(mdlog);
     }
 
index 5455a0504a1ef76d8cfb988f2cc7da780cd45d77..c3e14ec82d7205a9193c2efe021c64d81c5641d2 100644 (file)
@@ -121,7 +121,7 @@ void init_interaction_const_tables(FILE* fp, interaction_const_t* ic, real rlist
 void init_forcerec(FILE*                            fplog,
                    const gmx::MDLogger&             mdlog,
                    t_forcerec*                      fr,
-                   const t_inputrec*                ir,
+                   const t_inputrec&                ir,
                    const gmx_mtop_t*                mtop,
                    const t_commrec*                 cr,
                    matrix                           box,
index 0ed4399e70ec720d0ab6f14fd5f3484f68a3faf4..c48caa83ed4705e0e26509272049b4dac7427d85 100644 (file)
@@ -183,7 +183,7 @@ static void calc_virial(int                              start,
 }
 
 static void pull_potential_wrapper(const t_commrec*               cr,
-                                   const t_inputrec*              ir,
+                                   const t_inputrec&              ir,
                                    const matrix                   box,
                                    gmx::ArrayRef<const gmx::RVec> x,
                                    gmx::ForceWithVirial*          force,
@@ -201,7 +201,7 @@ static void pull_potential_wrapper(const t_commrec*               cr,
      * which is why pull_potential is called close to other communication.
      */
     wallcycle_start(wcycle, ewcPULLPOT);
-    set_pbc(&pbc, ir->pbcType, box);
+    set_pbc(&pbc, ir.pbcType, box);
     dvdl = 0;
     enerd->term[F_COM_PULL] += pull_potential(
             pull_work, mdatoms->massT, &pbc, cr, t, lambda[efptRESTRAINT], as_rvec_array(x.data()), force, &dvdl);
@@ -608,7 +608,7 @@ static bool haveSpecialForces(const t_inputrec&          inputrec,
  */
 static void computeSpecialForces(FILE*                          fplog,
                                  const t_commrec*               cr,
-                                 const t_inputrec*              inputrec,
+                                 const t_inputrec&              inputrec,
                                  gmx::Awh*                      awh,
                                  gmx_enfrot*                    enforcedRotation,
                                  gmx::ImdSession*               imdSession,
@@ -640,9 +640,9 @@ static void computeSpecialForces(FILE*                          fplog,
         forceProviders->calculateForces(forceProviderInput, &forceProviderOutput);
     }
 
-    if (inputrec->bPull && pull_have_potential(*pull_work))
+    if (inputrec.bPull && pull_have_potential(*pull_work))
     {
-        const int mtsLevel = forceGroupMtsLevel(inputrec->mtsLevels, gmx::MtsForceGroups::Pull);
+        const int mtsLevel = forceGroupMtsLevel(inputrec.mtsLevels, gmx::MtsForceGroups::Pull);
         if (mtsLevel == 0 || stepWork.computeSlowForces)
         {
             auto& forceWithVirial = (mtsLevel == 0) ? forceWithVirialMtsLevel0 : forceWithVirialMtsLevel1;
@@ -652,7 +652,7 @@ static void computeSpecialForces(FILE*                          fplog,
     }
     if (awh)
     {
-        const int mtsLevel = forceGroupMtsLevel(inputrec->mtsLevels, gmx::MtsForceGroups::Pull);
+        const int mtsLevel = forceGroupMtsLevel(inputrec.mtsLevels, gmx::MtsForceGroups::Pull);
         if (mtsLevel == 0 || stepWork.computeSlowForces)
         {
             const bool needForeignEnergyDifferences = awh->needForeignEnergyDifferences(step);
@@ -660,12 +660,12 @@ static void computeSpecialForces(FILE*                          fplog,
             if (needForeignEnergyDifferences)
             {
                 enerd->foreignLambdaTerms.finalizePotentialContributions(
-                        enerd->dvdl_lin, lambda, *inputrec->fepvals);
+                        enerd->dvdl_lin, lambda, *inputrec.fepvals);
                 std::tie(foreignLambdaDeltaH, foreignLambdaDhDl) = enerd->foreignLambdaTerms.getTerms(cr);
             }
 
             auto& forceWithVirial = (mtsLevel == 0) ? forceWithVirialMtsLevel0 : forceWithVirialMtsLevel1;
-            enerd->term[F_COM_PULL] += awh->applyBiasForcesAndUpdateBias(inputrec->pbcType,
+            enerd->term[F_COM_PULL] += awh->applyBiasForcesAndUpdateBias(inputrec.pbcType,
                                                                          mdatoms->massT,
                                                                          foreignLambdaDeltaH,
                                                                          foreignLambdaDhDl,
@@ -681,7 +681,7 @@ static void computeSpecialForces(FILE*                          fplog,
     rvec* f = as_rvec_array(forceWithVirialMtsLevel0->force_.data());
 
     /* Add the forces from enforced rotation potentials (if any) */
-    if (inputrec->bRot)
+    if (inputrec.bRot)
     {
         wallcycle_start(wcycle, ewcROTadd);
         enerd->term[F_COM_PULL] += add_rot_forces(enforcedRotation, f, cr, step, t);
@@ -699,7 +699,7 @@ static void computeSpecialForces(FILE*                          fplog,
     }
 
     /* Add forces from interactive molecular dynamics (IMD), if any */
-    if (inputrec->bIMD && stepWork.computeForces)
+    if (inputrec.bIMD && stepWork.computeForces)
     {
         imdSession->applyForces(f);
     }
@@ -1157,7 +1157,7 @@ static void setupGpuForceReductions(gmx::MdrunScheduleWorkload* runScheduleWork,
 void do_force(FILE*                               fplog,
               const t_commrec*                    cr,
               const gmx_multisim_t*               ms,
-              const t_inputrec*                   inputrec,
+              const t_inputrec&                   inputrec,
               gmx::Awh*                           awh,
               gmx_enfrot*                         enforcedRotation,
               gmx::ImdSession*                    imdSession,
@@ -1196,7 +1196,7 @@ void do_force(FILE*                               fplog,
     const SimulationWorkload& simulationWork = runScheduleWork->simulationWork;
 
     runScheduleWork->stepWork = setupStepWorkload(
-            legacyFlags, inputrec->mtsLevels, step, simulationWork, thisRankHasDuty(cr, DUTY_PME));
+            legacyFlags, inputrec.mtsLevels, step, simulationWork, thisRankHasDuty(cr, DUTY_PME));
     const StepWorkload& stepWork = runScheduleWork->stepWork;
 
     const bool useGpuPmeOnThisRank =
@@ -1432,7 +1432,7 @@ void do_force(FILE*                               fplog,
         // Need to run after the GPU-offload bonded interaction lists
         // are set up to be able to determine whether there is bonded work.
         runScheduleWork->domainWork = setupDomainLifetimeWorkload(
-                *inputrec, *fr, pull_work, ed, *mdatoms, simulationWork, stepWork);
+                inputrec, *fr, pull_work, ed, *mdatoms, simulationWork, stepWork);
 
         wallcycle_start_nocount(wcycle, ewcNS);
         wallcycle_sub_start(wcycle, ewcsNBS_SEARCH_LOCAL);
@@ -1454,7 +1454,7 @@ void do_force(FILE*                               fplog,
             setupGpuForceReductions(runScheduleWork, cr, fr);
         }
     }
-    else if (!EI_TPI(inputrec->eI) && stepWork.computeNonbondedForces)
+    else if (!EI_TPI(inputrec.eI) && stepWork.computeNonbondedForces)
     {
         if (stepWork.useGpuXBufferOps)
         {
@@ -1673,7 +1673,7 @@ void do_force(FILE*                               fplog,
         stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
     }
 
-    if (inputrec->bRot)
+    if (inputrec.bRot)
     {
         wallcycle_start(wcycle, ewcROT);
         do_rotation(cr, enforcedRotation, box, as_rvec_array(x.unpaddedArrayRef().data()), t, step, stepWork.doNeighborSearch);
@@ -1711,7 +1711,7 @@ void do_force(FILE*                               fplog,
 
     ForceOutputs* forceOutNonbonded = nonbondedAtMtsLevel1 ? forceOutMtsLevel1 : &forceOutMtsLevel0;
 
-    if (inputrec->bPull && pull_have_constraint(*pull_work))
+    if (inputrec.bPull && pull_have_constraint(*pull_work))
     {
         clear_pull_forces(pull_work);
     }
@@ -1741,7 +1741,7 @@ void do_force(FILE*                               fplog,
                                       as_rvec_array(x.unpaddedArrayRef().data()),
                                       &forceOutNonbonded->forceWithShiftForces(),
                                       *mdatoms,
-                                      inputrec->fepvals,
+                                      inputrec.fepvals,
                                       lambda,
                                       enerd,
                                       stepWork,
@@ -1754,7 +1754,7 @@ void do_force(FILE*                               fplog,
                                           as_rvec_array(x.unpaddedArrayRef().data()),
                                           &forceOutNonbonded->forceWithShiftForces(),
                                           *mdatoms,
-                                          inputrec->fepvals,
+                                          inputrec.fepvals,
                                           lambda,
                                           enerd,
                                           stepWork,
@@ -1802,10 +1802,10 @@ void do_force(FILE*                               fplog,
 
     // Compute wall interactions, when present.
     // Note: should be moved to special forces.
-    if (inputrec->nwall && stepWork.computeNonbondedForces)
+    if (inputrec.nwall && stepWork.computeNonbondedForces)
     {
         /* foreign lambda component for walls */
-        real dvdl_walls = do_walls(*inputrec,
+        real dvdl_walls = do_walls(inputrec,
                                    *fr,
                                    box,
                                    *mdatoms,
@@ -1845,7 +1845,7 @@ void do_force(FILE*                               fplog,
             ForceOutputs& forceOut     = (mtsIndex == 0 ? forceOutMtsLevel0 : *forceOutMtsLevel1);
             listedForces.calculate(wcycle,
                                    box,
-                                   inputrec->fepvals,
+                                   inputrec.fepvals,
                                    cr,
                                    ms,
                                    x,
@@ -2013,7 +2013,7 @@ void do_force(FILE*                               fplog,
         combineMtsForces(numAtoms,
                          force.unpaddedArrayRef(),
                          forceView->forceMtsCombined(),
-                         inputrec->mtsLevels[1].stepFactor);
+                         inputrec.mtsLevels[1].stepFactor);
     }
 
     if (havePPDomainDecomposition(cr))
@@ -2257,18 +2257,18 @@ void do_force(FILE*                               fplog,
             combineMtsForces(mdatoms->homenr,
                              force.unpaddedArrayRef(),
                              forceView->forceMtsCombined(),
-                             inputrec->mtsLevels[1].stepFactor);
+                             inputrec.mtsLevels[1].stepFactor);
         }
     }
 
     if (stepWork.computeEnergy)
     {
         /* Compute the final potential energy terms */
-        accumulatePotentialEnergies(enerd, lambda, inputrec->fepvals);
+        accumulatePotentialEnergies(enerd, lambda, inputrec.fepvals);
 
-        if (!EI_TPI(inputrec->eI))
+        if (!EI_TPI(inputrec.eI))
         {
-            checkPotentialEnergyValidity(step, *enerd, *inputrec);
+            checkPotentialEnergyValidity(step, *enerd, inputrec);
         }
     }
 
index ecc1f44ba6b0bfa1d5691f69103b446e04ee9761..d26a50313b8becd76cecbdf8f02683315232294e 100644 (file)
@@ -62,7 +62,7 @@
 #include "gromacs/utility/smalloc.h"
 
 void make_wall_tables(FILE*                   fplog,
-                      const t_inputrec*       ir,
+                      const t_inputrec&       ir,
                       const char*             tabfn,
                       const SimulationGroups* groups,
                       t_forcerec*             fr)
@@ -70,22 +70,22 @@ void make_wall_tables(FILE*                   fplog,
     int  negp_pp;
     char buf[STRLEN];
 
-    negp_pp                         = ir->opts.ngener - ir->nwall;
+    negp_pp                         = ir.opts.ngener - ir.nwall;
     gmx::ArrayRef<const int> nm_ind = groups->groups[SimulationAtomGroupType::EnergyOutput];
 
     if (fplog)
     {
-        fprintf(fplog, "Reading user tables for %d energy groups with %d walls\n", negp_pp, ir->nwall);
+        fprintf(fplog, "Reading user tables for %d energy groups with %d walls\n", negp_pp, ir.nwall);
     }
 
-    fr->wall_tab.resize(ir->nwall);
-    for (int w = 0; w < ir->nwall; w++)
+    fr->wall_tab.resize(ir.nwall);
+    for (int w = 0; w < ir.nwall; w++)
     {
         fr->wall_tab[w].resize(negp_pp);
         for (int egp = 0; egp < negp_pp; egp++)
         {
             /* If the energy group pair is excluded, we don't need a table */
-            if (!(fr->egp_flags[egp * ir->opts.ngener + negp_pp + w] & EGP_EXCL))
+            if (!(fr->egp_flags[egp * ir.opts.ngener + negp_pp + w] & EGP_EXCL))
             {
                 sprintf(buf, "%s", tabfn);
                 sprintf(buf + strlen(tabfn) - strlen(ftp2ext(efXVG)) - 1,
index 8a6316583420e921c1c30874888e9f68928171cc..7beff73de3d587e5c65f94d04d392441c5496b73 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * 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.
@@ -53,7 +53,7 @@ class ForceWithVirial;
 } // namespace gmx
 
 void make_wall_tables(FILE*                   fplog,
-                      const t_inputrec*       ir,
+                      const t_inputrec&       ir,
                       const char*             tabfn,
                       const SimulationGroups* groups,
                       t_forcerec*             fr);
index 793dfc37c2055045e346f6d5f1b71b80e88afe3e..eb7fa31abf1d852163fdecc9db42a89d2f07f48f 100644 (file)
@@ -1165,7 +1165,7 @@ void gmx::LegacySimulator::do_md()
             do_force(fplog,
                      cr,
                      ms,
-                     ir,
+                     *ir,
                      awh.get(),
                      enforcedRotation,
                      imdSession,
index bae23f3d25fc59dd125229e42f0e67a5d6ac29c8..5e996d769b067297f1193eb96f1b1bd30648f3b4 100644 (file)
@@ -567,7 +567,7 @@ void gmx::LegacySimulator::do_mimic()
             do_force(fplog,
                      cr,
                      ms,
-                     ir,
+                     *ir,
                      awh,
                      enforcedRotation,
                      imdSession,
index 63aeb8b16852db18fb41117e52c4b67931bf4f02..07a9a4c5f641d3ee11ced5bac2a05eb45748d139 100644 (file)
@@ -928,7 +928,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres,
     do_force(fplog,
              cr,
              ms,
-             inputrec,
+             *inputrec,
              nullptr,
              nullptr,
              imdSession,
index d80761bc950204180bed282f6184b13259316d4e..710e64c1bfaaef66c0156cfa92c33f197bc324ad 100644 (file)
@@ -679,7 +679,7 @@ void gmx::LegacySimulator::do_rerun()
             do_force(fplog,
                      cr,
                      ms,
-                     ir,
+                     *ir,
                      awh,
                      enforcedRotation,
                      imdSession,
index 9d509473f9c7e4ef71bca79b94bedbdc6252f952..a92901406cd86a28a7b3d820939d92eba349d450 100644 (file)
@@ -1580,7 +1580,7 @@ int Mdrunner::mdrunner()
         init_forcerec(fplog,
                       mdlog,
                       fr,
-                      inputrec.get(),
+                      *inputrec,
                       &mtop,
                       cr,
                       box,
index 38b68d157ace0627e76648f2f1b7a8f7cba06352..37522931b0c85e45460bfcee2936e11fea1e3bb6 100644 (file)
@@ -1084,7 +1084,7 @@ void relax_shell_flexcon(FILE*                         fplog,
     do_force(fplog,
              cr,
              ms,
-             inputrec,
+             *inputrec,
              nullptr,
              enforcedRotation,
              imdSession,
@@ -1224,7 +1224,7 @@ void relax_shell_flexcon(FILE*                         fplog,
         do_force(fplog,
                  cr,
                  ms,
-                 inputrec,
+                 *inputrec,
                  nullptr,
                  enforcedRotation,
                  imdSession,
index f468251ef9c59baf9951f492fc21fa329f11eedc..7a41750ed420600fc377c25a3d023e9af4d710d8 100644 (file)
@@ -770,7 +770,7 @@ void LegacySimulator::do_tpi()
             do_force(fplog,
                      cr,
                      ms,
-                     inputrec,
+                     *inputrec,
                      nullptr,
                      nullptr,
                      imdSession,
index fb1978578cc9f8f9921cdd0dd7a8c98ff458eb72..9b4fb32536c74f2ba60f5b18fb54bd8eae186f4a 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.
@@ -237,7 +237,7 @@ void ForceElement::run(Step step, Time time, unsigned int flags)
         do_force(fplog_,
                  cr_,
                  ms,
-                 inputrec_,
+                 *inputrec_,
                  awh,
                  enforcedRotation_,
                  imdSession_,