From 60914e936983ee5e132188be3c77a5b4f5540064 Mon Sep 17 00:00:00 2001 From: Joe Jordan Date: Tue, 16 Feb 2021 13:43:14 +0000 Subject: [PATCH] Use const ref to inputrec in do_force 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. --- src/gromacs/essentialdynamics/edsam.cpp | 4 +- src/gromacs/essentialdynamics/edsam.h | 2 +- src/gromacs/ewald/ewald.cpp | 18 +-- src/gromacs/ewald/ewald.h | 6 +- src/gromacs/mdlib/force.cpp | 8 +- src/gromacs/mdlib/force.h | 4 +- src/gromacs/mdlib/forcerec.cpp | 138 +++++++++--------- src/gromacs/mdlib/forcerec.h | 2 +- src/gromacs/mdlib/sim_util.cpp | 52 +++---- src/gromacs/mdlib/wall.cpp | 12 +- src/gromacs/mdlib/wall.h | 4 +- src/gromacs/mdrun/md.cpp | 2 +- src/gromacs/mdrun/mimic.cpp | 2 +- src/gromacs/mdrun/minimize.cpp | 2 +- src/gromacs/mdrun/rerun.cpp | 2 +- src/gromacs/mdrun/runner.cpp | 2 +- src/gromacs/mdrun/shellfc.cpp | 4 +- src/gromacs/mdrun/tpi.cpp | 2 +- src/gromacs/modularsimulator/forceelement.cpp | 4 +- 19 files changed, 134 insertions(+), 136 deletions(-) diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index 4861086a57..d6e48099d6 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -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) diff --git a/src/gromacs/essentialdynamics/edsam.h b/src/gromacs/essentialdynamics/edsam.h index e5d03a3f96..f9bf692469 100644 --- a/src/gromacs/essentialdynamics/edsam.h +++ b/src/gromacs/essentialdynamics/edsam.h @@ -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, diff --git a/src/gromacs/ewald/ewald.cpp b/src/gromacs/ewald/ewald.cpp index 6e089c2b99..81e6bb4709 100644 --- a/src/gromacs/ewald/ewald.cpp +++ b/src/gromacs/ewald/ewald.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team. - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -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); diff --git a/src/gromacs/ewald/ewald.h b/src/gromacs/ewald/ewald.h index 77fc79b3fa..7fc31df1e8 100644 --- a/src/gromacs/ewald/ewald.h +++ b/src/gromacs/ewald/ewald.h @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,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[], diff --git a/src/gromacs/mdlib/force.cpp b/src/gromacs/mdlib/force.cpp index 6b9996def9..a17b332848 100644 --- a/src/gromacs/mdlib/force.cpp +++ b/src/gromacs/mdlib/force.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -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), diff --git a/src/gromacs/mdlib/force.h b/src/gromacs/mdlib/force.h index 608849357f..6f795d0205 100644 --- a/src/gromacs/mdlib/force.h +++ b/src/gromacs/mdlib/force.h @@ -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, diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index 780ecda83e..b1f0df0900 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -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(); /* 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(*ir->fepvals); + GMX_RELEASE_ASSERT(ir.fepvals, "ir.fepvals should be set wth free-energy"); + ic->softCoreParameters = std::make_unique(*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(*mtop, ir->pbcType); + std::make_unique(*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( - *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); } diff --git a/src/gromacs/mdlib/forcerec.h b/src/gromacs/mdlib/forcerec.h index 5455a0504a..c3e14ec82d 100644 --- a/src/gromacs/mdlib/forcerec.h +++ b/src/gromacs/mdlib/forcerec.h @@ -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, diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 0ed4399e70..c48caa83ed 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -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 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); } } diff --git a/src/gromacs/mdlib/wall.cpp b/src/gromacs/mdlib/wall.cpp index ecc1f44ba6..d26a50313b 100644 --- a/src/gromacs/mdlib/wall.cpp +++ b/src/gromacs/mdlib/wall.cpp @@ -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 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, diff --git a/src/gromacs/mdlib/wall.h b/src/gromacs/mdlib/wall.h index 8a63165834..7beff73de3 100644 --- a/src/gromacs/mdlib/wall.h +++ b/src/gromacs/mdlib/wall.h @@ -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); diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index 793dfc37c2..eb7fa31abf 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -1165,7 +1165,7 @@ void gmx::LegacySimulator::do_md() do_force(fplog, cr, ms, - ir, + *ir, awh.get(), enforcedRotation, imdSession, diff --git a/src/gromacs/mdrun/mimic.cpp b/src/gromacs/mdrun/mimic.cpp index bae23f3d25..5e996d769b 100644 --- a/src/gromacs/mdrun/mimic.cpp +++ b/src/gromacs/mdrun/mimic.cpp @@ -567,7 +567,7 @@ void gmx::LegacySimulator::do_mimic() do_force(fplog, cr, ms, - ir, + *ir, awh, enforcedRotation, imdSession, diff --git a/src/gromacs/mdrun/minimize.cpp b/src/gromacs/mdrun/minimize.cpp index 63aeb8b168..07a9a4c5f6 100644 --- a/src/gromacs/mdrun/minimize.cpp +++ b/src/gromacs/mdrun/minimize.cpp @@ -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, diff --git a/src/gromacs/mdrun/rerun.cpp b/src/gromacs/mdrun/rerun.cpp index d80761bc95..710e64c1bf 100644 --- a/src/gromacs/mdrun/rerun.cpp +++ b/src/gromacs/mdrun/rerun.cpp @@ -679,7 +679,7 @@ void gmx::LegacySimulator::do_rerun() do_force(fplog, cr, ms, - ir, + *ir, awh, enforcedRotation, imdSession, diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 9d509473f9..a92901406c 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1580,7 +1580,7 @@ int Mdrunner::mdrunner() init_forcerec(fplog, mdlog, fr, - inputrec.get(), + *inputrec, &mtop, cr, box, diff --git a/src/gromacs/mdrun/shellfc.cpp b/src/gromacs/mdrun/shellfc.cpp index 38b68d157a..37522931b0 100644 --- a/src/gromacs/mdrun/shellfc.cpp +++ b/src/gromacs/mdrun/shellfc.cpp @@ -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, diff --git a/src/gromacs/mdrun/tpi.cpp b/src/gromacs/mdrun/tpi.cpp index f468251ef9..7a41750ed4 100644 --- a/src/gromacs/mdrun/tpi.cpp +++ b/src/gromacs/mdrun/tpi.cpp @@ -770,7 +770,7 @@ void LegacySimulator::do_tpi() do_force(fplog, cr, ms, - inputrec, + *inputrec, nullptr, nullptr, imdSession, diff --git a/src/gromacs/modularsimulator/forceelement.cpp b/src/gromacs/modularsimulator/forceelement.cpp index fb1978578c..9b4fb32536 100644 --- a/src/gromacs/modularsimulator/forceelement.cpp +++ b/src/gromacs/modularsimulator/forceelement.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019,2020, by the GROMACS development team, led by + * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -237,7 +237,7 @@ void ForceElement::run(Step step, Time time, unsigned int flags) do_force(fplog_, cr_, ms, - inputrec_, + *inputrec_, awh, enforcedRotation_, imdSession_, -- 2.22.0