From 97c751f1945702316b6342f4054da20dd5239872 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Wed, 20 Nov 2019 16:18:56 +0100 Subject: [PATCH] Make PBC type enumeration into PbcType enum class The type of periodic boundary conditions is defined by untyped enumeration and passed around as an integer, which is not type safe. This change makes the enum class that defines the type of the PBC and can be safely passed as a function argument. Change-Id: Ia1f709a90472a95ad76af92c41df570ba7c28255 --- src/gromacs/applied_forces/densityfitting.cpp | 8 +- src/gromacs/applied_forces/densityfitting.h | 4 +- .../densityfittingforceprovider.cpp | 8 +- .../densityfittingforceprovider.h | 6 +- src/gromacs/awh/awh.cpp | 6 +- src/gromacs/awh/awh.h | 7 +- src/gromacs/awh/read_params.cpp | 4 +- src/gromacs/awh/read_params.h | 5 +- src/gromacs/coordinateio/coordinatefile.cpp | 6 +- src/gromacs/domdec/box.cpp | 3 +- src/gromacs/domdec/domdec.cpp | 24 +-- src/gromacs/domdec/domdec.h | 3 +- src/gromacs/domdec/domdec_setup.cpp | 8 +- src/gromacs/domdec/domdec_topology.cpp | 28 +-- src/gromacs/domdec/dump.cpp | 6 +- src/gromacs/domdec/mdsetup.cpp | 4 +- src/gromacs/essentialdynamics/edsam.cpp | 2 +- src/gromacs/ewald/pme.cpp | 4 +- src/gromacs/ewald/pme_load_balancing.cpp | 5 +- src/gromacs/ewald/tests/pmetestcommon.cpp | 2 +- src/gromacs/fileio/confio.cpp | 56 +++--- src/gromacs/fileio/confio.h | 20 ++- src/gromacs/fileio/pdbio.cpp | 54 +++--- src/gromacs/fileio/pdbio.h | 23 ++- src/gromacs/fileio/tests/confio.cpp | 11 +- src/gromacs/fileio/tpxio.cpp | 70 ++++---- src/gromacs/fileio/tpxio.h | 27 +-- src/gromacs/fileio/trxio.cpp | 38 ++-- src/gromacs/fileio/trxio.h | 8 +- src/gromacs/gmxana/anadih.cpp | 2 +- src/gromacs/gmxana/gmx_anaeig.cpp | 16 +- src/gromacs/gmxana/gmx_bundle.cpp | 6 +- src/gromacs/gmxana/gmx_chi.cpp | 10 +- src/gromacs/gmxana/gmx_cluster.cpp | 6 +- src/gromacs/gmxana/gmx_clustsize.cpp | 8 +- src/gromacs/gmxana/gmx_confrms.cpp | 12 +- src/gromacs/gmxana/gmx_covar.cpp | 8 +- src/gromacs/gmxana/gmx_current.cpp | 16 +- src/gromacs/gmxana/gmx_density.cpp | 20 +-- src/gromacs/gmxana/gmx_densmap.cpp | 6 +- src/gromacs/gmxana/gmx_densorder.cpp | 13 +- src/gromacs/gmxana/gmx_dipoles.cpp | 16 +- src/gromacs/gmxana/gmx_disre.cpp | 14 +- src/gromacs/gmxana/gmx_do_dssp.cpp | 8 +- src/gromacs/gmxana/gmx_dos.cpp | 7 +- src/gromacs/gmxana/gmx_dyecoupl.cpp | 4 +- src/gromacs/gmxana/gmx_filter.cpp | 9 +- src/gromacs/gmxana/gmx_gyrate.cpp | 6 +- src/gromacs/gmxana/gmx_h2order.cpp | 10 +- src/gromacs/gmxana/gmx_hbond.cpp | 2 +- src/gromacs/gmxana/gmx_helix.cpp | 8 +- src/gromacs/gmxana/gmx_helixorient.cpp | 18 +- src/gromacs/gmxana/gmx_hydorder.cpp | 14 +- src/gromacs/gmxana/gmx_make_edi.cpp | 4 +- src/gromacs/gmxana/gmx_mdmat.cpp | 12 +- src/gromacs/gmxana/gmx_mindist.cpp | 41 ++--- src/gromacs/gmxana/gmx_msd.cpp | 22 +-- src/gromacs/gmxana/gmx_nmens.cpp | 4 +- src/gromacs/gmxana/gmx_nmtraj.cpp | 6 +- src/gromacs/gmxana/gmx_order.cpp | 34 ++-- src/gromacs/gmxana/gmx_polystat.cpp | 6 +- src/gromacs/gmxana/gmx_potential.cpp | 10 +- src/gromacs/gmxana/gmx_principal.cpp | 6 +- src/gromacs/gmxana/gmx_rms.cpp | 6 +- src/gromacs/gmxana/gmx_rmsdist.cpp | 18 +- src/gromacs/gmxana/gmx_rmsf.cpp | 12 +- src/gromacs/gmxana/gmx_rotacf.cpp | 6 +- src/gromacs/gmxana/gmx_rotmat.cpp | 14 +- src/gromacs/gmxana/gmx_saltbr.cpp | 6 +- src/gromacs/gmxana/gmx_sans.cpp | 9 +- src/gromacs/gmxana/gmx_sorient.cpp | 10 +- src/gromacs/gmxana/gmx_spatial.cpp | 8 +- src/gromacs/gmxana/gmx_spol.cpp | 14 +- src/gromacs/gmxana/gmx_tcaf.cpp | 4 +- src/gromacs/gmxana/gmx_traj.cpp | 20 +-- src/gromacs/gmxana/gmx_trjorder.cpp | 8 +- src/gromacs/gmxana/gmx_vanhove.cpp | 6 +- src/gromacs/gmxana/gmx_velacc.cpp | 5 +- src/gromacs/gmxana/nrama.cpp | 4 +- src/gromacs/gmxana/nrama.h | 4 +- src/gromacs/gmxana/sfactor.cpp | 4 +- src/gromacs/gmxpreprocess/editconf.cpp | 29 +-- src/gromacs/gmxpreprocess/genconf.cpp | 12 +- src/gromacs/gmxpreprocess/genion.cpp | 9 +- src/gromacs/gmxpreprocess/grompp.cpp | 21 +-- .../gmxpreprocess/insert_molecules.cpp | 30 ++-- src/gromacs/gmxpreprocess/pdb2gmx.cpp | 13 +- src/gromacs/gmxpreprocess/readir.cpp | 50 +++--- src/gromacs/gmxpreprocess/readpull.cpp | 2 +- src/gromacs/gmxpreprocess/solvate.cpp | 26 +-- src/gromacs/gmxpreprocess/x2top.cpp | 8 +- src/gromacs/imd/imd.cpp | 5 +- src/gromacs/listed_forces/gpubondedkernels.cu | 4 +- src/gromacs/listed_forces/listed_forces.cpp | 4 +- src/gromacs/listed_forces/pairs.cpp | 2 +- .../listed_forces/position_restraints.cpp | 24 +-- src/gromacs/listed_forces/tests/bonded.cpp | 18 +- src/gromacs/mdlib/constr.cpp | 8 +- src/gromacs/mdlib/coupling.cpp | 6 +- src/gromacs/mdlib/force.cpp | 2 +- src/gromacs/mdlib/forcerec.cpp | 10 +- src/gromacs/mdlib/md_support.cpp | 4 +- src/gromacs/mdlib/membed.cpp | 4 +- src/gromacs/mdlib/nsgrid.cpp | 4 +- src/gromacs/mdlib/qmmm.cpp | 2 +- src/gromacs/mdlib/settle.cpp | 2 +- src/gromacs/mdlib/sim_util.cpp | 23 +-- src/gromacs/mdlib/tests/constr.cpp | 10 +- src/gromacs/mdlib/tests/settle.cpp | 6 +- src/gromacs/mdlib/trajectory_writing.cpp | 4 +- src/gromacs/mdlib/update.h | 3 +- src/gromacs/mdlib/vcm.cpp | 3 +- src/gromacs/mdlib/vsite.cpp | 14 +- src/gromacs/mdlib/vsite.h | 20 ++- src/gromacs/mdrun/md.cpp | 10 +- src/gromacs/mdrun/mimic.cpp | 2 +- src/gromacs/mdrun/minimize.cpp | 12 +- src/gromacs/mdrun/rerun.cpp | 12 +- src/gromacs/mdrun/runner.cpp | 11 +- src/gromacs/mdrun/shellfc.cpp | 8 +- src/gromacs/mdrun/tpi.cpp | 6 +- src/gromacs/mdtypes/forcerec.h | 3 +- src/gromacs/mdtypes/inputrec.cpp | 18 +- src/gromacs/mdtypes/inputrec.h | 4 +- .../modularsimulator/statepropagatordata.cpp | 2 +- .../modularsimulator/statepropagatordata.h | 3 +- src/gromacs/nbnxm/benchmark/bench_setup.cpp | 9 +- src/gromacs/nbnxm/benchmark/bench_system.cpp | 4 +- src/gromacs/nbnxm/gridset.cpp | 10 +- src/gromacs/nbnxm/gridset.h | 9 +- src/gromacs/nbnxm/nbnxm_setup.cpp | 4 +- src/gromacs/nbnxm/pairlist.cpp | 2 +- src/gromacs/nbnxm/pairlist_tuning.cpp | 4 +- src/gromacs/nbnxm/pairsearch.cpp | 6 +- src/gromacs/nbnxm/pairsearch.h | 4 +- src/gromacs/pbcutil/mshift.cpp | 20 +-- src/gromacs/pbcutil/mshift.h | 3 +- src/gromacs/pbcutil/pbc.cpp | 166 +++++++++--------- src/gromacs/pbcutil/pbc.h | 108 +++++++----- src/gromacs/pbcutil/pbc_simd.cpp | 4 +- src/gromacs/pbcutil/pbcmethods.cpp | 26 +-- src/gromacs/pbcutil/pbcmethods.h | 15 +- src/gromacs/pbcutil/rmpbc.cpp | 42 ++--- src/gromacs/pbcutil/rmpbc.h | 7 +- src/gromacs/pulling/pull.cpp | 10 +- src/gromacs/pulling/pull_internal.h | 3 +- src/gromacs/pulling/pull_rotation.cpp | 2 +- src/gromacs/pulling/pullutil.cpp | 4 +- src/gromacs/pulling/tests/pull.cpp | 16 +- src/gromacs/restraint/restraintmdmodule.cpp | 6 +- src/gromacs/selection/nbsearch.cpp | 22 +-- src/gromacs/selection/tests/nbsearch.cpp | 18 +- src/gromacs/selection/tests/toputils.cpp | 10 +- src/gromacs/swap/swapcoords.cpp | 10 +- src/gromacs/tools/check.cpp | 12 +- src/gromacs/tools/make_ndx.cpp | 4 +- src/gromacs/tools/trjconv.cpp | 27 +-- src/gromacs/trajectory/trajectoryframe.cpp | 6 +- src/gromacs/trajectory/trajectoryframe.h | 5 +- .../trajectoryanalysis/cmdlinerunner.cpp | 4 +- .../trajectoryanalysis/modules/rdf.cpp | 2 +- .../trajectoryanalysis/modules/sasa.cpp | 10 +- .../trajectoryanalysis/runnercommon.cpp | 4 +- .../trajectoryanalysis/tests/surfacearea.cpp | 2 +- .../tests/topologyinformation.cpp | 11 +- .../topologyinformation.cpp | 9 +- .../trajectoryanalysis/topologyinformation.h | 11 +- src/gromacs/utility/mdmodulenotification.h | 5 +- src/programs/view/manager.cpp | 8 +- src/programs/view/manager.h | 7 +- src/programs/view/nmol.cpp | 8 +- src/programs/view/nmol.h | 4 +- src/programs/view/view.cpp | 10 +- 173 files changed, 1133 insertions(+), 1025 deletions(-) diff --git a/src/gromacs/applied_forces/densityfitting.cpp b/src/gromacs/applied_forces/densityfitting.cpp index 28ead0fcfa..d5d8ea90af 100644 --- a/src/gromacs/applied_forces/densityfitting.cpp +++ b/src/gromacs/applied_forces/densityfitting.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -181,11 +181,11 @@ public: */ void setPeriodicBoundaryConditionType(PeriodicBoundaryConditionType pbc) { - pbcType_ = std::make_unique(pbc.pbcType); + pbcType_ = std::make_unique(pbc.pbcType); } //! Get the periodic boundary conditions - int periodicBoundaryConditionType() + PbcType periodicBoundaryConditionType() { if (pbcType_ == nullptr) { @@ -209,7 +209,7 @@ private: //! The local atom set to act on std::unique_ptr localAtomSet_; //! The type of periodic boundary conditions in the simulation - std::unique_ptr pbcType_; + std::unique_ptr pbcType_; //! The simulation time step double simulationTimeStep_ = 1; diff --git a/src/gromacs/applied_forces/densityfitting.h b/src/gromacs/applied_forces/densityfitting.h index c453027137..389e4144c5 100644 --- a/src/gromacs/applied_forces/densityfitting.h +++ b/src/gromacs/applied_forces/densityfitting.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -38,6 +38,8 @@ #include #include +enum class PbcType : int; + namespace gmx { diff --git a/src/gromacs/applied_forces/densityfittingforceprovider.cpp b/src/gromacs/applied_forces/densityfittingforceprovider.cpp index 57f9e5a6a9..3a404fb544 100644 --- a/src/gromacs/applied_forces/densityfittingforceprovider.cpp +++ b/src/gromacs/applied_forces/densityfittingforceprovider.cpp @@ -96,7 +96,7 @@ public: basic_mdspan referenceDensity, const TranslateAndScale& transformationToDensityLattice, const LocalAtomSet& localAtomSet, - int pbcType, + PbcType pbcType, double simulationTimeStep, const DensityFittingForceProviderState& state); ~Impl(); @@ -121,7 +121,7 @@ private: DensityFittingAmplitudeLookup amplitudeLookup_; TranslateAndScale transformationToDensityLattice_; RVec referenceDensityCenter_; - int pbcType_; + PbcType pbcType_; //! Optionally scale the force according to a moving average of the similarity compat::optional expAverageSimilarity_; @@ -133,7 +133,7 @@ DensityFittingForceProvider::Impl::Impl(const DensityFittingParameters& basic_mdspan referenceDensity, const TranslateAndScale& transformationToDensityLattice, const LocalAtomSet& localAtomSet, - int pbcType, + PbcType pbcType, double simulationTimeStep, const DensityFittingForceProviderState& state) : parameters_(parameters), @@ -314,7 +314,7 @@ DensityFittingForceProvider::DensityFittingForceProvider(const DensityFittingPar basic_mdspan referenceDensity, const TranslateAndScale& transformationToDensityLattice, const LocalAtomSet& localAtomSet, - int pbcType, + PbcType pbcType, double simulationTimeStep, const DensityFittingForceProviderState& state) : impl_(new Impl(parameters, referenceDensity, transformationToDensityLattice, localAtomSet, pbcType, simulationTimeStep, state)) diff --git a/src/gromacs/applied_forces/densityfittingforceprovider.h b/src/gromacs/applied_forces/densityfittingforceprovider.h index 16a121ba34..5ceb11501d 100644 --- a/src/gromacs/applied_forces/densityfittingforceprovider.h +++ b/src/gromacs/applied_forces/densityfittingforceprovider.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -51,6 +51,8 @@ #include "gromacs/mdtypes/iforceprovider.h" #include "gromacs/utility/classhelpers.h" +enum class PbcType : int; + namespace gmx { @@ -82,7 +84,7 @@ public: basic_mdspan referenceDensity, const TranslateAndScale& transformationToDensityLattice, const LocalAtomSet& localAtomSet, - int pbcType, + PbcType pbcType, double simulationTimeStep, const DensityFittingForceProviderState& state); ~DensityFittingForceProvider(); diff --git a/src/gromacs/awh/awh.cpp b/src/gromacs/awh/awh.cpp index 76046ff09b..610f67470c 100644 --- a/src/gromacs/awh/awh.cpp +++ b/src/gromacs/awh/awh.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020, 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. @@ -207,7 +207,7 @@ bool Awh::isOutputStep(int64_t step) const return (nstout_ > 0 && step % nstout_ == 0); } -real Awh::applyBiasForcesAndUpdateBias(int ePBC, +real Awh::applyBiasForcesAndUpdateBias(PbcType pbcType, const t_mdatoms& mdatoms, const matrix box, gmx::ForceWithVirial* forceWithVirial, @@ -221,7 +221,7 @@ real Awh::applyBiasForcesAndUpdateBias(int ePBC, wallcycle_start(wallcycle, ewcAWH); t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); /* During the AWH update the potential can instantaneously jump due to either an bias update or moving the umbrella. The jumps are kept track of and diff --git a/src/gromacs/awh/awh.h b/src/gromacs/awh/awh.h index 5c57dfabe1..e7e537f4cd 100644 --- a/src/gromacs/awh/awh.h +++ b/src/gromacs/awh/awh.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020, 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. @@ -80,6 +80,7 @@ struct t_commrec; struct t_enxframe; struct t_inputrec; struct t_mdatoms; +enum class PbcType : int; namespace gmx { @@ -153,7 +154,7 @@ public: * for this). * * \param[in] mdatoms Atom properties. - * \param[in] ePBC Type of periodic boundary conditions. + * \param[in] pbcType Type of periodic boundary conditions. * \param[in] box Box vectors. * \param[in,out] forceWithVirial Force and virial buffers, should cover at least the local atoms. * \param[in] t Time. @@ -162,7 +163,7 @@ public: * \param[in,out] fplog General output file, normally md.log, can be nullptr. * \returns the potential energy for the bias. */ - real applyBiasForcesAndUpdateBias(int ePBC, + real applyBiasForcesAndUpdateBias(PbcType pbcType, const t_mdatoms& mdatoms, const matrix box, gmx::ForceWithVirial* forceWithVirial, diff --git a/src/gromacs/awh/read_params.cpp b/src/gromacs/awh/read_params.cpp index 6427b48e38..916bd7d45d 100644 --- a/src/gromacs/awh/read_params.cpp +++ b/src/gromacs/awh/read_params.cpp @@ -760,7 +760,7 @@ void setStateDependentAwhParams(AwhParams* awhParams, const pull_params_t* pull_params, pull_t* pull_work, const matrix box, - int ePBC, + PbcType pbcType, const tensor& compressibility, const t_grpopts* inputrecGroupOptions, warninp_t wi) @@ -784,7 +784,7 @@ void setStateDependentAwhParams(AwhParams* awhParams, } t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (int k = 0; k < awhParams->numBias; k++) { diff --git a/src/gromacs/awh/read_params.h b/src/gromacs/awh/read_params.h index 5cdb9000c6..9ba8e282eb 100644 --- a/src/gromacs/awh/read_params.h +++ b/src/gromacs/awh/read_params.h @@ -54,6 +54,7 @@ struct t_grpopts; struct t_inputrec; struct pull_params_t; struct pull_t; +enum class PbcType : int; namespace gmx { @@ -76,7 +77,7 @@ AwhParams* readAndCheckAwhParams(std::vector* inp, const t_inputrec* * \param[in] pull_params Pull parameters. * \param[in,out] pull_work Pull working struct to register AWH bias in. * \param[in] box Box vectors. - * \param[in] ePBC Periodic boundary conditions enum. + * \param[in] pbcType Periodic boundary conditions enum. * \param[in] compressibility Compressibility matrix for pressure coupling, pass all 0 without pressure coupling * \param[in] inputrecGroupOptions Parameters for atom groups. * \param[in,out] wi Struct for bookeeping warnings. @@ -87,7 +88,7 @@ void setStateDependentAwhParams(AwhParams* awhParams, const pull_params_t* pull_params, pull_t* pull_work, const matrix box, - int ePBC, + PbcType pbcType, const tensor& compressibility, const t_grpopts* inputrecGroupOptions, warninp_t wi); diff --git a/src/gromacs/coordinateio/coordinatefile.cpp b/src/gromacs/coordinateio/coordinatefile.cpp index 4c245b1272..8bc9224ac2 100644 --- a/src/gromacs/coordinateio/coordinatefile.cpp +++ b/src/gromacs/coordinateio/coordinatefile.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -322,8 +322,8 @@ deepCopy_t_trxframe(const t_trxframe& input, t_trxframe* copy, RVec* xvec, RVec* } } copy_mat(input.box, copy->box); - copy->bPBC = input.bPBC; - copy->ePBC = input.ePBC; + copy->bPBC = input.bPBC; + copy->pbcType = input.pbcType; } /*! \brief diff --git a/src/gromacs/domdec/box.cpp b/src/gromacs/domdec/box.cpp index 68825bbf90..03b0e9f69a 100644 --- a/src/gromacs/domdec/box.cpp +++ b/src/gromacs/domdec/box.cpp @@ -309,7 +309,8 @@ void set_ddbox_cr(const t_commrec& cr, { if (MASTER(&cr)) { - low_set_ddbox(ePBC2npbcdim(ir.ePBC), inputrec2nboundeddim(&ir), dd_nc, box, true, x, nullptr, ddbox); + low_set_ddbox(numPbcDimensions(ir.pbcType), inputrec2nboundeddim(&ir), dd_nc, box, true, x, + nullptr, ddbox); } gmx_bcast(sizeof(gmx_ddbox_t), ddbox, &cr); diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 3e8a3d87c9..49460d9493 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -1763,10 +1763,11 @@ static int dd_getenv(const gmx::MDLogger& mdlog, const char* env_var, int def) static void check_dd_restrictions(const gmx_domdec_t* dd, const t_inputrec* ir, const gmx::MDLogger& mdlog) { - if (ir->ePBC == epbcSCREW && (dd->numCells[XX] == 1 || dd->numCells[YY] > 1 || dd->numCells[ZZ] > 1)) + if (ir->pbcType == PbcType::Screw + && (dd->numCells[XX] == 1 || dd->numCells[YY] > 1 || dd->numCells[ZZ] > 1)) { gmx_fatal(FARGS, "With pbc=%s can only do domain decomposition in the x-direction", - epbc_names[ir->ePBC]); + c_pbcTypeNames[ir->pbcType].c_str()); } if (ir->nstlist == 0) @@ -1774,7 +1775,7 @@ static void check_dd_restrictions(const gmx_domdec_t* dd, const t_inputrec* ir, gmx_fatal(FARGS, "Domain decomposition does not work with nstlist=0"); } - if (ir->comm_mode == ecmANGULAR && ir->ePBC != epbcNONE) + if (ir->comm_mode == ecmANGULAR && ir->pbcType != PbcType::No) { GMX_LOG(mdlog.warning) .appendText( @@ -2001,10 +2002,10 @@ static void setupUpdateGroups(const gmx::MDLogger& mdlog, } UnitCellInfo::UnitCellInfo(const t_inputrec& ir) : - npbcdim(ePBC2npbcdim(ir.ePBC)), + npbcdim(numPbcDimensions(ir.pbcType)), numBoundedDimensions(inputrec2nboundeddim(&ir)), ddBoxIsDynamic(numBoundedDimensions < DIM || inputrecDynamicBox(&ir)), - haveScrewPBC(ir.ePBC == epbcSCREW) + haveScrewPBC(ir.pbcType == PbcType::Screw) { } @@ -2056,7 +2057,7 @@ static DDSystemInfo getSystemInfo(const gmx::MDLogger& mdlog, systemInfo.useUpdateGroups = false; if (ir.cutoff_scheme == ecutsVERLET) { - real cutoffMargin = std::sqrt(max_cutoff2(ir.ePBC, box)) - ir.rlist; + real cutoffMargin = std::sqrt(max_cutoff2(ir.pbcType, box)) - ir.rlist; setupUpdateGroups(mdlog, mtop, ir, cutoffMargin, &systemInfo); } @@ -2730,7 +2731,7 @@ static void set_cell_limits_dlb(const gmx::MDLogger& mdlog, } comm->maxpulse = 1; - comm->bVacDLBNoLimit = (ir->ePBC == epbcNONE); + comm->bVacDLBNoLimit = (ir->pbcType == PbcType::No); for (d = 0; d < dd->ndim; d++) { if (comm->ddSettings.request1DAnd1Pulse) @@ -2781,14 +2782,15 @@ bool dd_moleculesAreAlwaysWhole(const gmx_domdec_t& dd) return dd.comm->systemInfo.moleculesAreAlwaysWhole; } -gmx_bool dd_bonded_molpbc(const gmx_domdec_t* dd, int ePBC) +gmx_bool dd_bonded_molpbc(const gmx_domdec_t* dd, PbcType pbcType) { /* If each molecule is a single charge group * or we use domain decomposition for each periodic dimension, * we do not need to take pbc into account for the bonded interactions. */ - return (ePBC != epbcNONE && dd->comm->systemInfo.haveInterDomainBondeds - && !(dd->numCells[XX] > 1 && dd->numCells[YY] > 1 && (dd->numCells[ZZ] > 1 || ePBC == epbcXY))); + return (pbcType != PbcType::No && dd->comm->systemInfo.haveInterDomainBondeds + && !(dd->numCells[XX] > 1 && dd->numCells[YY] > 1 + && (dd->numCells[ZZ] > 1 || pbcType == PbcType::XY))); } /*! \brief Sets grid size limits and PP-PME setup, prints settings to log */ @@ -2832,7 +2834,7 @@ static void set_ddgrid_parameters(const gmx::MDLogger& mdlog, logSettings(mdlog, dd, mtop, ir, dlb_scale, ddbox); real vol_frac; - if (ir->ePBC == epbcNONE) + if (ir->pbcType == PbcType::No) { vol_frac = 1 - 1 / static_cast(dd->nnodes); } diff --git a/src/gromacs/domdec/domdec.h b/src/gromacs/domdec/domdec.h index 6608dc7d4e..b7d4fb56dd 100644 --- a/src/gromacs/domdec/domdec.h +++ b/src/gromacs/domdec/domdec.h @@ -82,6 +82,7 @@ struct t_inputrec; struct t_mdatoms; struct t_nrnb; struct gmx_wallcycle; +enum class PbcType : int; class t_state; namespace gmx @@ -171,7 +172,7 @@ void dd_init_bondeds(FILE* fplog, bool dd_moleculesAreAlwaysWhole(const gmx_domdec_t& dd); /*! \brief Returns if we need to do pbc for calculating bonded interactions */ -gmx_bool dd_bonded_molpbc(const gmx_domdec_t* dd, int ePBC); +gmx_bool dd_bonded_molpbc(const gmx_domdec_t* dd, PbcType pbcType); /*! \brief Change the DD non-bonded communication cut-off. * diff --git a/src/gromacs/domdec/domdec_setup.cpp b/src/gromacs/domdec/domdec_setup.cpp index ce77acd419..3889a62043 100644 --- a/src/gromacs/domdec/domdec_setup.cpp +++ b/src/gromacs/domdec/domdec_setup.cpp @@ -314,7 +314,7 @@ real comm_box_frac(const gmx::IVec& dd_nc, real cutoff, const gmx_ddbox_t& ddbox /*! \brief Return whether the DD inhomogeneous in the z direction */ static gmx_bool inhomogeneous_z(const t_inputrec& ir) { - return ((EEL_PME(ir.coulombtype) || ir.coulombtype == eelEWALD) && ir.ePBC == epbcXYZ + return ((EEL_PME(ir.coulombtype) || ir.coulombtype == eelEWALD) && ir.pbcType == PbcType::Xyz && ir.ewald_geometry == eewg3DC); } @@ -364,8 +364,8 @@ static float comm_cost_est(real limit, float temp; /* Check the DD algorithm restrictions */ - if ((ir.ePBC == epbcXY && ir.nwall < 2 && nc[ZZ] > 1) - || (ir.ePBC == epbcSCREW && (nc[XX] == 1 || nc[YY] > 1 || nc[ZZ] > 1))) + if ((ir.pbcType == PbcType::XY && ir.nwall < 2 && nc[ZZ] > 1) + || (ir.pbcType == PbcType::Screw && (nc[XX] == 1 || nc[YY] > 1 || nc[ZZ] > 1))) { return -1; } @@ -528,7 +528,7 @@ static float comm_cost_est(real limit, /* Add cost of pbc_dx for bondeds */ cost_pbcdx = 0; - if ((nc[XX] == 1 || nc[YY] == 1) || (nc[ZZ] == 1 && ir.ePBC != epbcXY)) + if ((nc[XX] == 1 || nc[YY] == 1) || (nc[ZZ] == 1 && ir.pbcType != PbcType::XY)) { if ((ddbox.tric_dir[XX] && nc[XX] == 1) || (ddbox.tric_dir[YY] && nc[YY] == 1)) { diff --git a/src/gromacs/domdec/domdec_topology.cpp b/src/gromacs/domdec/domdec_topology.cpp index a8424c8a6c..8cc5430000 100644 --- a/src/gromacs/domdec/domdec_topology.cpp +++ b/src/gromacs/domdec/domdec_topology.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2006 - 2014, The GROMACS development team. - * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020, 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. @@ -1664,7 +1664,7 @@ void dd_make_local_top(gmx_domdec_t* dd, { if (fr->bMolPBC) { - pbc_null = set_pbc_dd(&pbc, fr->ePBC, dd->numCells, TRUE, box); + pbc_null = set_pbc_dd(&pbc, fr->pbcType, dd->numCells, TRUE, box); } else { @@ -1987,14 +1987,14 @@ static void bonded_cg_distance_mol(const gmx_moltype_t* molt, static void bonded_distance_intermol(const InteractionLists& ilists_intermol, gmx_bool bBCheck, const rvec* x, - int ePBC, + PbcType pbcType, const matrix box, bonded_distance_t* bd_2b, bonded_distance_t* bd_mb) { t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (int ftype = 0; ftype < F_NRE; ftype++) { @@ -2049,7 +2049,7 @@ static bool moltypeHasVsite(const gmx_moltype_t& molt) //! Returns coordinates not broken over PBC for a molecule static void getWholeMoleculeCoordinates(const gmx_moltype_t* molt, const gmx_ffparams_t* ffparams, - int ePBC, + PbcType pbcType, t_graph* graph, const matrix box, const rvec* x, @@ -2057,9 +2057,9 @@ static void getWholeMoleculeCoordinates(const gmx_moltype_t* molt, { int n, i; - if (ePBC != epbcNONE) + if (pbcType != PbcType::No) { - mk_mshift(nullptr, graph, ePBC, box, x); + mk_mshift(nullptr, graph, pbcType, box, x); shift_x(graph, box, x, xs); /* By doing an extra mk_mshift the molecules that are broken @@ -2067,7 +2067,7 @@ static void getWholeMoleculeCoordinates(const gmx_moltype_t* molt, * will be made whole again. Such are the healing powers * of GROMACS. */ - mk_mshift(nullptr, graph, ePBC, box, xs); + mk_mshift(nullptr, graph, pbcType, box, xs); } else { @@ -2095,8 +2095,8 @@ static void getWholeMoleculeCoordinates(const gmx_moltype_t* molt, } } - construct_vsites(nullptr, xs, 0.0, nullptr, ffparams->iparams.data(), ilist, epbcNONE, TRUE, - nullptr, nullptr); + construct_vsites(nullptr, xs, 0.0, nullptr, ffparams->iparams.data(), ilist, PbcType::No, + TRUE, nullptr, nullptr); } } @@ -2130,7 +2130,7 @@ void dd_bonded_cg_distance(const gmx::MDLogger& mdlog, } else { - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { mk_graph_moltype(molt, &graph); } @@ -2138,7 +2138,7 @@ void dd_bonded_cg_distance(const gmx::MDLogger& mdlog, snew(xs, molt.atoms.nr); for (int mol = 0; mol < molb.nmol; mol++) { - getWholeMoleculeCoordinates(&molt, &mtop->ffparams, ir->ePBC, &graph, box, + getWholeMoleculeCoordinates(&molt, &mtop->ffparams, ir->pbcType, &graph, box, x + at_offset, xs); bonded_distance_t bd_mol_2b = { 0, -1, -1, -1 }; @@ -2155,7 +2155,7 @@ void dd_bonded_cg_distance(const gmx::MDLogger& mdlog, at_offset += molt.atoms.nr; } sfree(xs); - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { done_graph(&graph); } @@ -2167,7 +2167,7 @@ void dd_bonded_cg_distance(const gmx::MDLogger& mdlog, GMX_RELEASE_ASSERT(mtop->intermolecular_ilist, "We should have an ilist when intermolecular interactions are on"); - bonded_distance_intermol(*mtop->intermolecular_ilist, bBCheck, x, ir->ePBC, box, &bd_2b, &bd_mb); + bonded_distance_intermol(*mtop->intermolecular_ilist, bBCheck, x, ir->pbcType, box, &bd_2b, &bd_mb); } *r_2b = sqrt(bd_2b.r2); diff --git a/src/gromacs/domdec/dump.cpp b/src/gromacs/domdec/dump.cpp index e0e1a549e7..c3f7eaad13 100644 --- a/src/gromacs/domdec/dump.cpp +++ b/src/gromacs/domdec/dump.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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. @@ -100,7 +100,7 @@ void write_dd_grid_pdb(const char* fn, int64_t step, gmx_domdec_t* dd, matrix bo } sprintf(fname, "%s_%s.pdb", fn, gmx_step_str(step, buf)); out = gmx_fio_fopen(fname, "w"); - gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? epbcSCREW : epbcXYZ, box); + gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? PbcType::Screw : PbcType::Xyz, box); a = 1; for (i = 0; i < dd->nnodes; i++) { @@ -169,7 +169,7 @@ void write_dd_pdb(const char* fn, out = gmx_fio_fopen(fname, "w"); fprintf(out, "TITLE %s\n", title); - gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? epbcSCREW : epbcXYZ, box); + gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? PbcType::Screw : PbcType::Xyz, box); int molb = 0; for (int i = 0; i < natoms; i++) { diff --git a/src/gromacs/domdec/mdsetup.cpp b/src/gromacs/domdec/mdsetup.cpp index 5ba8445574..24edea6acb 100644 --- a/src/gromacs/domdec/mdsetup.cpp +++ b/src/gromacs/domdec/mdsetup.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018,2019,2020, 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. @@ -113,7 +113,7 @@ void mdAlgorithmsSetupAtomData(const t_commrec* cr, } } - if (!usingDomDec && ir->ePBC != epbcNONE && !fr->bMolPBC) + if (!usingDomDec && ir->pbcType != PbcType::No && !fr->bMolPBC) { GMX_ASSERT(graph != nullptr, "We use a graph with PBC (no periodic mols) and without DD"); diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index 3c701a279b..ba16e34d72 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -2774,7 +2774,7 @@ std::unique_ptr init_edsam(const gmx::MDLogger& m /* Remove PBC, make molecule(s) subject to ED whole. */ snew(x_pbc, mtop->natoms); copy_rvecn(globalState->x.rvec_array(), x_pbc, 0, mtop->natoms); - do_pbc_first_mtop(nullptr, ir->ePBC, globalState->box, mtop, x_pbc); + do_pbc_first_mtop(nullptr, ir->pbcType, globalState->box, mtop, x_pbc); } /* Reset pointer to first ED data set which contains the actual ED data */ auto edi = ed->edpar.begin(); diff --git a/src/gromacs/ewald/pme.cpp b/src/gromacs/ewald/pme.cpp index fbb59bdf92..d6cd44b346 100644 --- a/src/gromacs/ewald/pme.cpp +++ b/src/gromacs/ewald/pme.cpp @@ -682,7 +682,7 @@ gmx_pme_t* gmx_pme_init(const t_commrec* cr, } pme->bUseThreads = (sum_use_threads > 0); - if (ir->ePBC == epbcSCREW) + if (ir->pbcType == PbcType::Screw) { gmx_fatal(FARGS, "pme does not (yet) work with pbc = screw"); } @@ -903,7 +903,7 @@ void gmx_pme_reinit(struct gmx_pme_t** pmedata, // TODO: This would be better as just copying a sub-structure that contains // all the PME parameters and nothing else. t_inputrec irc; - irc.ePBC = ir->ePBC; + irc.pbcType = ir->pbcType; irc.coulombtype = ir->coulombtype; irc.vdwtype = ir->vdwtype; irc.efep = ir->efep; diff --git a/src/gromacs/ewald/pme_load_balancing.cpp b/src/gromacs/ewald/pme_load_balancing.cpp index 33924d5565..f48a9556b5 100644 --- a/src/gromacs/ewald/pme_load_balancing.cpp +++ b/src/gromacs/ewald/pme_load_balancing.cpp @@ -676,9 +676,10 @@ static void pme_load_balance(pme_load_balancing_t* pme_lb, pme_lb->elimited = epmelblimMAXSCALING; } - if (OK && ir.ePBC != epbcNONE) + if (OK && ir.pbcType != PbcType::No) { - OK = (gmx::square(pme_lb->setup[pme_lb->cur + 1].rlistOuter) <= max_cutoff2(ir.ePBC, box)); + OK = (gmx::square(pme_lb->setup[pme_lb->cur + 1].rlistOuter) + <= max_cutoff2(ir.pbcType, box)); if (!OK) { pme_lb->elimited = epmelblimBOX; diff --git a/src/gromacs/ewald/tests/pmetestcommon.cpp b/src/gromacs/ewald/tests/pmetestcommon.cpp index 543dff85ff..198c77cadd 100644 --- a/src/gromacs/ewald/tests/pmetestcommon.cpp +++ b/src/gromacs/ewald/tests/pmetestcommon.cpp @@ -128,7 +128,7 @@ PmeSafePointer pmeInitWrapper(const t_inputrec* inputRec, boxTemp[i][j] = box[i * DIM + j]; } } - const char* boxError = check_box(-1, boxTemp); + const char* boxError = check_box(PbcType::Unset, boxTemp); GMX_RELEASE_ASSERT(boxError == nullptr, boxError); switch (mode) diff --git a/src/gromacs/fileio/confio.cpp b/src/gromacs/fileio/confio.cpp index 8b3236c2e1..7114d54c6d 100644 --- a/src/gromacs/fileio/confio.cpp +++ b/src/gromacs/fileio/confio.cpp @@ -67,7 +67,7 @@ void write_sto_conf_indexed(const char* outfile, const t_atoms* atoms, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box, int nindex, int index[]) @@ -107,8 +107,8 @@ void write_sto_conf_indexed(const char* outfile, case efENT: case efPQR: out = gmx_fio_fopen(outfile, "w"); - write_pdbfile_indexed(out, title, atoms, x, ePBC, box, ' ', -1, nindex, index, nullptr, - ftp == efPQR); + write_pdbfile_indexed(out, title, atoms, x, pbcType, box, ' ', -1, nindex, index, + nullptr, ftp == efPQR); gmx_fio_fclose(out); break; case efESP: @@ -126,7 +126,7 @@ void write_sto_conf(const char* outfile, const t_atoms* atoms, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box) { FILE* out; @@ -159,7 +159,7 @@ void write_sto_conf(const char* outfile, case efBRK: case efENT: out = gmx_fio_fopen(outfile, "w"); - write_pdbfile(out, title, atoms, x, ePBC, box, ' ', -1, nullptr); + write_pdbfile(out, title, atoms, x, pbcType, box, ' ', -1, nullptr); gmx_fio_fclose(out); break; case efESP: @@ -177,7 +177,7 @@ void write_sto_conf_mtop(const char* outfile, const gmx_mtop_t* mtop, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box) { int ftp; @@ -198,7 +198,7 @@ void write_sto_conf_mtop(const char* outfile, */ atoms = gmx_mtop_global_atoms(mtop); - write_sto_conf(outfile, title, &atoms, x, v, ePBC, box); + write_sto_conf(outfile, title, &atoms, x, v, pbcType, box); done_atom(&atoms); break; @@ -344,7 +344,7 @@ static void read_stx_conf(const char* infile, t_atoms* atoms, rvec x[], rvec* v, - int* ePBC, + PbcType* pbcType, matrix box) { FILE* in; @@ -361,9 +361,9 @@ static void read_stx_conf(const char* infile, gmx_mem("Uninitialized array atom"); } - if (ePBC) + if (pbcType) { - *ePBC = -1; + *pbcType = PbcType::Unset; } ftp = fn2ftp(infile); @@ -383,7 +383,7 @@ static void read_stx_conf(const char* infile, break; case efPDB: case efBRK: - case efENT: gmx_pdb_read_conf(infile, symtab, name, atoms, x, ePBC, box); break; + case efENT: gmx_pdb_read_conf(infile, symtab, name, atoms, x, pbcType, box); break; case efESP: gmx_espresso_read_conf(infile, symtab, name, atoms, x, v, box); break; default: gmx_incons("Not supported in read_stx_conf"); } @@ -393,7 +393,7 @@ void readConfAndAtoms(const char* infile, t_symtab* symtab, char** name, t_atoms* atoms, - int* ePBC, + PbcType* pbcType, rvec** x, rvec** v, matrix box) @@ -404,7 +404,7 @@ void readConfAndAtoms(const char* infile, { bool haveTopology; gmx_mtop_t mtop; - readConfAndTopology(infile, &haveTopology, &mtop, ePBC, x, v, box); + readConfAndTopology(infile, &haveTopology, &mtop, pbcType, x, v, box); *symtab = mtop.symtab; *name = gmx_strdup(*mtop.name); *atoms = gmx_mtop_global_atoms(&mtop); @@ -437,7 +437,7 @@ void readConfAndAtoms(const char* infile, { snew(*v, natoms); } - read_stx_conf(infile, symtab, name, atoms, *x, (v == nullptr) ? nullptr : *v, ePBC, box); + read_stx_conf(infile, symtab, name, atoms, *x, (v == nullptr) ? nullptr : *v, pbcType, box); if (xIsNull) { sfree(*x); @@ -445,13 +445,19 @@ void readConfAndAtoms(const char* infile, } } -void readConfAndTopology(const char* infile, bool* haveTopology, gmx_mtop_t* mtop, int* ePBC, rvec** x, rvec** v, matrix box) +void readConfAndTopology(const char* infile, + bool* haveTopology, + gmx_mtop_t* mtop, + PbcType* pbcType, + rvec** x, + rvec** v, + matrix box) { GMX_RELEASE_ASSERT(mtop != nullptr, "readConfAndTopology requires mtop!=NULL"); - if (ePBC != nullptr) + if (pbcType != nullptr) { - *ePBC = -1; + *pbcType = PbcType::Unset; } *haveTopology = fn2bTPX(infile); @@ -466,12 +472,12 @@ void readConfAndTopology(const char* infile, bool* haveTopology, gmx_mtop_t* mto { snew(*v, header.natoms); } - int natoms; - int ePBC_tmp = read_tpx(infile, nullptr, box, &natoms, (x == nullptr) ? nullptr : *x, - (v == nullptr) ? nullptr : *v, mtop); - if (ePBC != nullptr) + int natoms; + PbcType pbcType_tmp = read_tpx(infile, nullptr, box, &natoms, (x == nullptr) ? nullptr : *x, + (v == nullptr) ? nullptr : *v, mtop); + if (pbcType != nullptr) { - *ePBC = ePBC_tmp; + *pbcType = pbcType_tmp; } } else @@ -482,19 +488,19 @@ void readConfAndTopology(const char* infile, bool* haveTopology, gmx_mtop_t* mto open_symtab(&symtab); - readConfAndAtoms(infile, &symtab, &name, &atoms, ePBC, x, v, box); + readConfAndAtoms(infile, &symtab, &name, &atoms, pbcType, x, v, box); convertAtomsToMtop(&symtab, put_symtab(&symtab, name), &atoms, mtop); sfree(name); } } -gmx_bool read_tps_conf(const char* infile, t_topology* top, int* ePBC, rvec** x, rvec** v, matrix box, gmx_bool requireMasses) +gmx_bool read_tps_conf(const char* infile, t_topology* top, PbcType* pbcType, rvec** x, rvec** v, matrix box, gmx_bool requireMasses) { bool haveTopology; gmx_mtop_t mtop; - readConfAndTopology(infile, &haveTopology, &mtop, ePBC, x, v, box); + readConfAndTopology(infile, &haveTopology, &mtop, pbcType, x, v, box); *top = gmx_mtop_t_to_t_topology(&mtop, true); diff --git a/src/gromacs/fileio/confio.h b/src/gromacs/fileio/confio.h index 5640f50637..08af69c205 100644 --- a/src/gromacs/fileio/confio.h +++ b/src/gromacs/fileio/confio.h @@ -48,13 +48,14 @@ struct gmx_mtop_t; struct t_atoms; struct t_symtab; struct t_topology; +enum class PbcType : int; void write_sto_conf_indexed(const char* outfile, const char* title, const t_atoms* atoms, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box, int nindex, int index[]); @@ -65,7 +66,7 @@ void write_sto_conf(const char* outfile, const t_atoms* atoms, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box); /* write atoms, x, v (if .gro and not NULL) and box (if not NULL) * to an STO (.gro or .pdb) file */ @@ -75,7 +76,7 @@ void write_sto_conf_mtop(const char* outfile, const gmx_mtop_t* mtop, const rvec x[], const rvec* v, - int ePBC, + PbcType pbcType, const matrix box); /* As write_sto_conf, but uses a gmx_mtop_t struct */ @@ -87,7 +88,7 @@ void write_sto_conf_mtop(const char* outfile, * \param[in] infile Input file name * \param[out] haveTopology true when a topology was read and stored in mtop * \param[out] mtop The topology, either complete or only atom data - * \param[out] ePBC Enum reporting the type of PBC + * \param[out] pbcType Enum reporting the type of PBC * \param[in,out] x Coordinates will be stored when *x!=NULL * \param[in,out] v Velocities will be stored when *v!=NULL * \param[out] box Box dimensions @@ -95,7 +96,7 @@ void write_sto_conf_mtop(const char* outfile, void readConfAndTopology(const char* infile, bool* haveTopology, gmx_mtop_t* mtop, - int* ePBC, + PbcType* pbcType, rvec** x, rvec** v, matrix box); @@ -108,7 +109,7 @@ void readConfAndTopology(const char* infile, * \param[out] symtab The symbol table * \param[out] name The title of the molecule, e.g. from pdb TITLE record * \param[out] atoms The global t_atoms struct - * \param[out] ePBC Enum reporting the type of PBC + * \param[out] pbcType Enum reporting the type of PBC * \param[in,out] x Coordinates will be stored when *x!=NULL * \param[in,out] v Velocities will be stored when *v!=NULL * \param[out] box Box dimensions @@ -117,7 +118,7 @@ void readConfAndAtoms(const char* infile, t_symtab* symtab, char** name, t_atoms* atoms, - int* ePBC, + PbcType* pbcType, rvec** x, rvec** v, matrix box); @@ -134,7 +135,8 @@ void readConfAndAtoms(const char* infile, * * \param[in] infile Input file name * \param[out] top The topology, either complete or only atom data. Caller is - * responsible for calling done_top(). \param[out] ePBC Enum reporting the type of PBC + * responsible for calling done_top(). + * \param[out] pbcType Enum reporting the type of PBC * \param[in,out] x Coordinates will be stored when *x!=NULL * \param[in,out] v Velocities will be stored when *v!=NULL * \param[out] box Box dimensions @@ -143,7 +145,7 @@ void readConfAndAtoms(const char* infile, */ gmx_bool read_tps_conf(const char* infile, struct t_topology* top, - int* ePBC, + PbcType* pbcType, rvec** x, rvec** v, matrix box, diff --git a/src/gromacs/fileio/pdbio.cpp b/src/gromacs/fileio/pdbio.cpp index 115a556804..74f776ed90 100644 --- a/src/gromacs/fileio/pdbio.cpp +++ b/src/gromacs/fileio/pdbio.cpp @@ -113,16 +113,16 @@ static std::string xlate_atomname_gmx2pdb(std::string name) } -void gmx_write_pdb_box(FILE* out, int ePBC, const matrix box) +void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box) { real alpha, beta, gamma; - if (ePBC == -1) + if (pbcType == PbcType::Unset) { - ePBC = guess_ePBC(box); + pbcType = guessPbcType(box); } - if (ePBC == epbcNONE) + if (pbcType == PbcType::No) { return; } @@ -152,7 +152,7 @@ void gmx_write_pdb_box(FILE* out, int ePBC, const matrix box) gamma = 90; } fprintf(out, "REMARK THIS IS A SIMULATION BOX\n"); - if (ePBC != epbcSCREW) + if (pbcType != PbcType::Screw) { fprintf(out, "CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s%4d\n", 10 * norm(box[XX]), 10 * norm(box[YY]), 10 * norm(box[ZZ]), alpha, beta, gamma, "P 1", 1); @@ -165,17 +165,17 @@ void gmx_write_pdb_box(FILE* out, int ePBC, const matrix box) } } -static void read_cryst1(char* line, int* ePBC, matrix box) +static void read_cryst1(char* line, PbcType* pbcType, matrix box) { #define SG_SIZE 11 - char sa[12], sb[12], sc[12], sg[SG_SIZE + 1], ident; - double fa, fb, fc, alpha, beta, gamma, cosa, cosb, cosg, sing; - int syma, symb, symc; - int ePBC_file; + char sa[12], sb[12], sc[12], sg[SG_SIZE + 1], ident; + double fa, fb, fc, alpha, beta, gamma, cosa, cosb, cosg, sing; + int syma, symb, symc; + PbcType pbcTypeFile; sscanf(line, "%*s%s%s%s%lf%lf%lf", sa, sb, sc, &alpha, &beta, &gamma); - ePBC_file = -1; + pbcTypeFile = PbcType::Unset; if (strlen(line) >= 55) { strncpy(sg, line + 55, SG_SIZE); @@ -187,17 +187,17 @@ static void read_cryst1(char* line, int* ePBC, matrix box) sscanf(sg, "%c %d %d %d", &ident, &syma, &symb, &symc); if (ident == 'P' && syma == 1 && symb <= 1 && symc <= 1) { - fc = strtod(sc, nullptr) * 0.1; - ePBC_file = (fc > 0 ? epbcXYZ : epbcXY); + fc = strtod(sc, nullptr) * 0.1; + pbcTypeFile = (fc > 0 ? PbcType::Xyz : PbcType::XY); } if (ident == 'P' && syma == 21 && symb == 1 && symc == 1) { - ePBC_file = epbcSCREW; + pbcTypeFile = PbcType::Screw; } } - if (ePBC) + if (pbcType) { - *ePBC = ePBC_file; + *pbcType = pbcTypeFile; } if (box) @@ -205,7 +205,7 @@ static void read_cryst1(char* line, int* ePBC, matrix box) fa = strtod(sa, nullptr) * 0.1; fb = strtod(sb, nullptr) * 0.1; fc = strtod(sc, nullptr) * 0.1; - if (ePBC_file == epbcSCREW) + if (pbcTypeFile == PbcType::Screw) { fa *= 0.5; } @@ -290,7 +290,7 @@ void write_pdbfile_indexed(FILE* out, const char* title, const t_atoms* atoms, const rvec x[], - int ePBC, + PbcType pbcType, const matrix box, char chainid, int model_nr, @@ -309,7 +309,7 @@ void write_pdbfile_indexed(FILE* out, fprintf(out, "TITLE %s\n", (title && title[0]) ? title : gmx::bromacs().c_str()); if (box && ((norm2(box[XX]) != 0.0F) || (norm2(box[YY]) != 0.0F) || (norm2(box[ZZ]) != 0.0F))) { - gmx_write_pdb_box(out, ePBC, box); + gmx_write_pdb_box(out, pbcType, box); } if (atoms->havePdbInfo) { @@ -415,7 +415,7 @@ void write_pdbfile(FILE* out, const char* title, const t_atoms* atoms, const rvec x[], - int ePBC, + PbcType pbcType, const matrix box, char chainid, int model_nr, @@ -428,7 +428,7 @@ void write_pdbfile(FILE* out, { index[i] = i; } - write_pdbfile_indexed(out, title, atoms, x, ePBC, box, chainid, model_nr, atoms->nr, index, + write_pdbfile_indexed(out, title, atoms, x, pbcType, box, chainid, model_nr, atoms->nr, index, conect, false); sfree(index); } @@ -839,7 +839,7 @@ int read_pdbfile(FILE* in, t_atoms* atoms, t_symtab* symtab, rvec x[], - int* ePBC, + PbcType* pbcType, matrix box, gmx_bool bChange, gmx_conect conect) @@ -853,10 +853,10 @@ int read_pdbfile(FILE* in, int natom, chainnum; gmx_bool bStop = FALSE; - if (ePBC) + if (pbcType) { /* Only assume pbc when there is a CRYST1 entry */ - *ePBC = epbcNONE; + *pbcType = PbcType::No; } if (box != nullptr) { @@ -891,7 +891,7 @@ int read_pdbfile(FILE* in, } break; - case epdbCRYST1: read_cryst1(line, ePBC, box); break; + case epdbCRYST1: read_cryst1(line, pbcType, box); break; case epdbTITLE: case epdbHEADER: @@ -1009,11 +1009,11 @@ void get_pdb_coordnum(FILE* in, int* natoms) } } -void gmx_pdb_read_conf(const char* infile, t_symtab* symtab, char** name, t_atoms* atoms, rvec x[], int* ePBC, matrix box) +void gmx_pdb_read_conf(const char* infile, t_symtab* symtab, char** name, t_atoms* atoms, rvec x[], PbcType* pbcType, matrix box) { FILE* in = gmx_fio_fopen(infile, "r"); char title[STRLEN]; - read_pdbfile(in, title, nullptr, atoms, symtab, x, ePBC, box, TRUE, nullptr); + read_pdbfile(in, title, nullptr, atoms, symtab, x, pbcType, box, TRUE, nullptr); if (name != nullptr) { *name = gmx_strdup(title); diff --git a/src/gromacs/fileio/pdbio.h b/src/gromacs/fileio/pdbio.h index a45f17bad6..d9e918c275 100644 --- a/src/gromacs/fileio/pdbio.h +++ b/src/gromacs/fileio/pdbio.h @@ -50,6 +50,7 @@ class AtomProperties; struct t_atoms; struct t_symtab; struct t_topology; +enum class PbcType : int; typedef struct gmx_conect_t* gmx_conect; @@ -88,9 +89,9 @@ void pdb_use_ter(gmx_bool bSet); /* set read_pdbatoms to read upto 'TER' or 'ENDMDL' (default, bSet=FALSE). This function is fundamentally broken as far as thread-safety is concerned.*/ -void gmx_write_pdb_box(FILE* out, int ePBC, const matrix box); +void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box); /* write the box in the CRYST1 record, - * with ePBC=-1 the pbc is guessed from the box + * with pbcType=PbcType::Unset the pbc is guessed from the box * This function is fundamentally broken as far as thread-safety is concerned. */ @@ -98,7 +99,7 @@ void write_pdbfile_indexed(FILE* out, const char* title, const t_atoms* atoms, const rvec x[], - int ePBC, + PbcType pbcType, const matrix box, char chain, int model_nr, @@ -112,7 +113,7 @@ void write_pdbfile(FILE* out, const char* title, const t_atoms* atoms, const rvec x[], - int ePBC, + PbcType pbcType, const matrix box, char chain, int model_nr, @@ -139,18 +140,24 @@ int read_pdbfile(FILE* in, struct t_atoms* atoms, struct t_symtab* symtab, rvec x[], - int* ePBC, + PbcType* pbcType, matrix box, gmx_bool bChange, gmx_conect conect); /* Function returns number of atoms found. - * ePBC and gmx_conect structure may be NULL. + * pbcType and gmx_conect structure may be NULL. */ -void gmx_pdb_read_conf(const char* infile, t_symtab* symtab, char** name, t_atoms* atoms, rvec x[], int* ePBC, matrix box); +void gmx_pdb_read_conf(const char* infile, + t_symtab* symtab, + char** name, + t_atoms* atoms, + rvec x[], + PbcType* pbcType, + matrix box); /* Read a pdb file and extract ATOM and HETATM fields. * Read a box from the CRYST1 line, return 0 box when no CRYST1 is found. - * ePBC may be NULL. + * pbcType may be NULL. * * If name is not nullptr, gmx_strdup the title string into it. */ diff --git a/src/gromacs/fileio/tests/confio.cpp b/src/gromacs/fileio/tests/confio.cpp index e0f6c7231f..53a1216ff3 100644 --- a/src/gromacs/fileio/tests/confio.cpp +++ b/src/gromacs/fileio/tests/confio.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020, 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. @@ -52,6 +52,7 @@ #include "gromacs/fileio/filetypes.h" #include "gromacs/math/vec.h" #include "gromacs/math/vectypes.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/topology/atoms.h" #include "gromacs/topology/symtab.h" #include "gromacs/topology/topology.h" @@ -103,14 +104,14 @@ public: void writeReferenceFile() { write_sto_conf(referenceFilename_.c_str(), *refTop_->name, &refTop_->atoms, - as_rvec_array(refX_.data()), nullptr, -1, refBox_); + as_rvec_array(refX_.data()), nullptr, PbcType::Unset, refBox_); } void readReferenceFileTps() { snew(testTop_, 1); - int ePBC = -2; - read_tps_conf(referenceFilename_.c_str(), testTop_, &ePBC, &testX_, nullptr, testBox_, FALSE); + PbcType pbcType = PbcType::Unset; + read_tps_conf(referenceFilename_.c_str(), testTop_, &pbcType, &testX_, nullptr, testBox_, FALSE); } void testTopologies() @@ -121,7 +122,7 @@ public: void writeTestFileAndTest() { write_sto_conf(testFilename_.c_str(), *testTop_->name, &testTop_->atoms, testX_, nullptr, - -1, testBox_); + PbcType::Unset, testBox_); testFilesEqual(referenceFilename_, testFilename_); } diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 7b11b7c065..c39d7f0edb 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -2939,9 +2939,9 @@ static void do_tpx_state_second(gmx::ISerializer* serializer, TpxFileHeader* tpx * \param[in] tpx The file header data. * \param[in,out] ir Datastructure with simulation parameters. */ -static int do_tpx_ir(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputrec* ir) +static PbcType do_tpx_ir(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputrec* ir) { - int ePBC; + PbcType pbcType; gmx_bool bPeriodicMols; /* Starting with tpx version 26, we have the inputrec @@ -2951,7 +2951,7 @@ static int do_tpx_ir(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputre * * */ - ePBC = -1; + pbcType = PbcType::Unset; bPeriodicMols = FALSE; do_test(serializer, tpx->bIr, ir); @@ -2962,10 +2962,10 @@ static int do_tpx_ir(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputre /* Removed the pbc info from do_inputrec, since we always want it */ if (!serializer->reading()) { - ePBC = ir->ePBC; + pbcType = ir->pbcType; bPeriodicMols = ir->bPeriodicMols; } - serializer->doInt(&ePBC); + serializer->doInt(reinterpret_cast(&pbcType)); serializer->doBool(&bPeriodicMols); } if (tpx->fileGeneration <= tpx_generation && ir) @@ -2973,18 +2973,18 @@ static int do_tpx_ir(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputre do_inputrec(serializer, ir, tpx->fileVersion); if (tpx->fileVersion < 53) { - ePBC = ir->ePBC; + pbcType = ir->pbcType; bPeriodicMols = ir->bPeriodicMols; } } if (serializer->reading() && ir && tpx->fileVersion >= 53) { /* We need to do this after do_inputrec, since that initializes ir */ - ir->ePBC = ePBC; + ir->pbcType = pbcType; ir->bPeriodicMols = bPeriodicMols; } } - return ePBC; + return pbcType; } /*! \brief @@ -3050,13 +3050,13 @@ static void do_tpx_finalize(TpxFileHeader* tpx, t_inputrec* ir, t_state* state, * \param[in,out] v Individual velocities for processing, deprecated. * \param[in,out] mtop Global topology. */ -static int do_tpx_body(gmx::ISerializer* serializer, - TpxFileHeader* tpx, - t_inputrec* ir, - t_state* state, - rvec* x, - rvec* v, - gmx_mtop_t* mtop) +static PbcType do_tpx_body(gmx::ISerializer* serializer, + TpxFileHeader* tpx, + t_inputrec* ir, + t_state* state, + rvec* x, + rvec* v, + gmx_mtop_t* mtop) { if (state) { @@ -3067,12 +3067,12 @@ static int do_tpx_body(gmx::ISerializer* serializer, { do_tpx_state_second(serializer, tpx, state, x, v); } - int ePBC = do_tpx_ir(serializer, tpx, ir); + PbcType pbcType = do_tpx_ir(serializer, tpx, ir); if (serializer->reading()) { do_tpx_finalize(tpx, ir, state, mtop); } - return ePBC; + return pbcType; } /*! \brief @@ -3083,7 +3083,7 @@ static int do_tpx_body(gmx::ISerializer* serializer, * \param[in,out] ir Datastructures with simulation parameters. * \param[in,out] mtop Global topology. */ -static int do_tpx_body(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputrec* ir, gmx_mtop_t* mtop) +static PbcType do_tpx_body(gmx::ISerializer* serializer, TpxFileHeader* tpx, t_inputrec* ir, gmx_mtop_t* mtop) { return do_tpx_body(serializer, tpx, ir, nullptr, nullptr, nullptr, mtop); } @@ -3188,12 +3188,12 @@ static PartialDeserializedTprFile readTpxBody(TpxFileHeader* tpx, partialDeserializedTpr.header = *tpx; doTpxBodyBuffer(serializer, partialDeserializedTpr.body); - partialDeserializedTpr.ePBC = + partialDeserializedTpr.pbcType = completeTprDeserialization(&partialDeserializedTpr, ir, state, x, v, mtop); } else { - partialDeserializedTpr.ePBC = do_tpx_body(serializer, tpx, ir, state, x, v, mtop); + partialDeserializedTpr.pbcType = do_tpx_body(serializer, tpx, ir, state, x, v, mtop); } // Update header to system info for communication to nodes. // As we only need to communicate the inputrec and mtop to other nodes, @@ -3263,12 +3263,12 @@ void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, close_tpx(fio); } -int completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, - t_inputrec* ir, - t_state* state, - rvec* x, - rvec* v, - gmx_mtop_t* mtop) +PbcType completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, + t_inputrec* ir, + t_state* state, + rvec* x, + rvec* v, + gmx_mtop_t* 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 @@ -3281,9 +3281,9 @@ int completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTp return do_tpx_body(&tprBodyDeserializer, &partialDeserializedTpr->header, ir, state, x, v, mtop); } -int completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, - t_inputrec* ir, - gmx_mtop_t* mtop) +PbcType completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, + t_inputrec* ir, + gmx_mtop_t* mtop) { return completeTprDeserialization(partialDeserializedTpr, ir, nullptr, nullptr, nullptr, mtop); } @@ -3301,7 +3301,7 @@ PartialDeserializedTprFile read_tpx_state(const char* fn, t_inputrec* ir, t_stat return partialDeserializedTpr; } -int read_tpx(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, gmx_mtop_t* mtop) +PbcType read_tpx(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, gmx_mtop_t* mtop) { t_fileio* fio; t_state state; @@ -3321,19 +3321,19 @@ int read_tpx(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, r { copy_mat(state.box, box); } - return partialDeserializedTpr.ePBC; + return partialDeserializedTpr.pbcType; } -int read_tpx_top(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, t_topology* top) +PbcType read_tpx_top(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, t_topology* top) { gmx_mtop_t mtop; - int ePBC; + PbcType pbcType; - ePBC = read_tpx(fn, ir, box, natoms, x, v, &mtop); + pbcType = read_tpx(fn, ir, box, natoms, x, v, &mtop); *top = gmx_mtop_t_to_t_topology(&mtop, true); - return ePBC; + return pbcType; } gmx_bool fn2bTPX(const char* file) diff --git a/src/gromacs/fileio/tpxio.h b/src/gromacs/fileio/tpxio.h index a925caba91..b3633a7c79 100644 --- a/src/gromacs/fileio/tpxio.h +++ b/src/gromacs/fileio/tpxio.h @@ -43,6 +43,7 @@ #include #include "gromacs/math/vectypes.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/utility/arrayref.h" #include "gromacs/utility/basedefinitions.h" #include "gromacs/utility/real.h" @@ -110,7 +111,7 @@ struct PartialDeserializedTprFile //! The file body. std::vector body; //! Flag for PBC needed by legacy implementation. - int ePBC = -1; + PbcType pbcType = PbcType::Unset; }; /* @@ -154,17 +155,17 @@ void write_tpx_state(const char* fn, const t_inputrec* ir, const t_state* state, * * \returns PBC flag. */ -int completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, - t_inputrec* ir, - t_state* state, - rvec* x, - rvec* v, - gmx_mtop_t* mtop); +PbcType completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, + t_inputrec* ir, + t_state* state, + rvec* x, + rvec* v, + gmx_mtop_t* mtop); //! Overload for final TPR deserialization when not using state vectors. -int completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, - t_inputrec* ir, - gmx_mtop_t* mtop); +PbcType completeTprDeserialization(PartialDeserializedTprFile* partialDeserializedTpr, + t_inputrec* ir, + gmx_mtop_t* mtop); /*! \brief * Read a file to set up a simulation and close it after reading. @@ -203,11 +204,11 @@ PartialDeserializedTprFile read_tpx_state(const char* fn, t_inputrec* ir, t_stat * \param[out] x Positions to be filled from file, or nullptr. * \param[out] v Velocities to be filled from file, or nullptr. * \param[out] mtop Topology to be populated, or nullptr. - * \returns ir->ePBC if it was read from the file. + * \returns ir->pbcType if it was read from the file. */ -int read_tpx(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, gmx_mtop_t* mtop); +PbcType read_tpx(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, gmx_mtop_t* mtop); -int read_tpx_top(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, t_topology* top); +PbcType read_tpx_top(const char* fn, t_inputrec* ir, matrix box, int* natoms, rvec* x, rvec* v, t_topology* top); /* As read_tpx, but for the old t_topology struct */ gmx_bool fn2bTPX(const char* file); diff --git a/src/gromacs/fileio/trxio.cpp b/src/gromacs/fileio/trxio.cpp index 4deccda373..06ff8bcf12 100644 --- a/src/gromacs/fileio/trxio.cpp +++ b/src/gromacs/fileio/trxio.cpp @@ -292,15 +292,15 @@ void clear_trxframe(t_trxframe* fr, gmx_bool bFirst) fr->v = nullptr; fr->f = nullptr; clear_mat(fr->box); - fr->bPBC = FALSE; - fr->ePBC = -1; + fr->bPBC = FALSE; + fr->pbcType = PbcType::Unset; } } -void set_trxframe_ePBC(t_trxframe* fr, int ePBC) +void setTrxFramePbcType(t_trxframe* fr, PbcType pbcType) { - fr->bPBC = (ePBC == -1); - fr->ePBC = ePBC; + fr->bPBC = (pbcType == PbcType::Unset); + fr->pbcType = pbcType; } int write_trxframe_indexed(t_trxstatus* status, const t_trxframe* fr, int nind, const int* ind, gmx_conect gc) @@ -410,8 +410,8 @@ int write_trxframe_indexed(t_trxstatus* status, const t_trxframe* fr, int nind, } else { - write_pdbfile_indexed(gmx_fio_getfp(status->fio), title, fr->atoms, fr->x, -1, - fr->box, ' ', fr->step, nind, ind, gc, FALSE); + write_pdbfile_indexed(gmx_fio_getfp(status->fio), title, fr->atoms, fr->x, + PbcType::Unset, fr->box, ' ', fr->step, nind, ind, gc, FALSE); } break; case efG96: @@ -550,7 +550,7 @@ int write_trxframe(t_trxstatus* status, t_trxframe* fr, gmx_conect gc) else { write_pdbfile(gmx_fio_getfp(status->fio), title, fr->atoms, fr->x, - fr->bPBC ? fr->ePBC : -1, fr->box, ' ', fr->step, gc); + fr->bPBC ? fr->pbcType : PbcType::Unset, fr->box, ' ', fr->step, gc); } break; case efG96: write_g96_conf(gmx_fio_getfp(status->fio), title, fr, -1, nullptr); break; @@ -697,9 +697,10 @@ static gmx_bool pdb_next_x(t_trxstatus* status, FILE* fp, t_trxframe* fr) // Initiate model_nr to -1 rather than NOTSET. // It is not worthwhile introducing extra variables in the // read_pdbfile call to verify that a model_nr was read. - int ePBC, model_nr = -1, na; - char title[STRLEN], *time, *step; - double dbl; + PbcType pbcType; + int model_nr = -1, na; + char title[STRLEN], *time, *step; + double dbl; atoms.nr = fr->natoms; atoms.atom = nullptr; @@ -707,10 +708,10 @@ static gmx_bool pdb_next_x(t_trxstatus* status, FILE* fp, t_trxframe* fr) /* the other pointers in atoms should not be accessed if these are NULL */ snew(symtab, 1); open_symtab(symtab); - na = read_pdbfile(fp, title, &model_nr, &atoms, symtab, fr->x, &ePBC, boxpdb, TRUE, nullptr); + na = read_pdbfile(fp, title, &model_nr, &atoms, symtab, fr->x, &pbcType, boxpdb, TRUE, nullptr); free_symtab(symtab); sfree(symtab); - set_trxframe_ePBC(fr, ePBC); + setTrxFramePbcType(fr, pbcType); if (nframes_read(status) == 0) { fprintf(stderr, " '%s', %d atoms\n", title, fr->natoms); @@ -1082,16 +1083,17 @@ void rewind_trj(t_trxstatus* status) /***** T O P O L O G Y S T U F F ******/ -t_topology* read_top(const char* fn, int* ePBC) +t_topology* read_top(const char* fn, PbcType* pbcType) { - int epbc, natoms; + int natoms; + PbcType pbcTypeFile; t_topology* top; snew(top, 1); - epbc = read_tpx_top(fn, nullptr, nullptr, &natoms, nullptr, nullptr, top); - if (ePBC) + pbcTypeFile = read_tpx_top(fn, nullptr, nullptr, &natoms, nullptr, nullptr, top); + if (pbcType) { - *ePBC = epbc; + *pbcType = pbcTypeFile; } return top; diff --git a/src/gromacs/fileio/trxio.h b/src/gromacs/fileio/trxio.h index d1b8ad1b06..8940bc5903 100644 --- a/src/gromacs/fileio/trxio.h +++ b/src/gromacs/fileio/trxio.h @@ -71,8 +71,8 @@ void clear_trxframe(struct t_trxframe* fr, gmx_bool bFirst); * and all data to zero. */ -void set_trxframe_ePBC(struct t_trxframe* fr, int ePBC); -/* Set the type of periodic boundary conditions, ePBC=-1 is not set */ +void setTrxFramePbcType(struct t_trxframe* fr, PbcType pbcType); +/* Set the type of periodic boundary conditions, pbcType=PbcType::Unset is not set */ int nframes_read(t_trxstatus* status); /* Returns the number of frames read from the trajectory */ @@ -243,9 +243,9 @@ gmx_bool read_next_x(const gmx_output_env_t* oenv, t_trxstatus* status, real* t, void rewind_trj(t_trxstatus* status); /* Rewind trajectory file as opened with read_first_x */ -struct t_topology* read_top(const char* fn, int* ePBC); +struct t_topology* read_top(const char* fn, PbcType* pbcType); /* Extract a topology data structure from a topology file. - * If ePBC!=NULL *ePBC gives the pbc type. + * If pbcType!=NULL *pbcType gives the pbc type. */ #endif diff --git a/src/gromacs/gmxana/anadih.cpp b/src/gromacs/gmxana/anadih.cpp index bdacdd2fa4..a015a329b8 100644 --- a/src/gromacs/gmxana/anadih.cpp +++ b/src/gromacs/gmxana/anadih.cpp @@ -887,7 +887,7 @@ void read_ang_dih(const char* trj_fn, if (pbc) { - set_pbc(pbc, -1, box); + set_pbc(pbc, PbcType::Unset, box); } if (bAngles) diff --git a/src/gromacs/gmxana/gmx_anaeig.cpp b/src/gromacs/gmxana/gmx_anaeig.cpp index ce282f7b6f..448640c2d4 100644 --- a/src/gromacs/gmxana/gmx_anaeig.cpp +++ b/src/gromacs/gmxana/gmx_anaeig.cpp @@ -466,7 +466,7 @@ static void overlap(const char* outfile, static void project(const char* trajfile, const t_topology* top, - int ePBC, + PbcType pbcType, matrix topbox, const char* projfile, const char* twodplotfile, @@ -550,7 +550,7 @@ static void project(const char* trajfile, if (top) { - gpbc = gmx_rmpbc_init(&top->idef, ePBC, nat); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, nat); } for (i = 0; i < nat; i++) @@ -767,7 +767,7 @@ static void project(const char* trajfile, } else { - write_sto_conf(threedplotfile, str, &atoms, x, nullptr, ePBC, box); + write_sto_conf(threedplotfile, str, &atoms, x, nullptr, pbcType, box); } done_atom(&atoms); } @@ -1069,8 +1069,8 @@ int gmx_anaeig(int argc, char* argv[]) #define NPA asize(pa) t_topology top; - int ePBC = -1; - const t_atoms* atoms = nullptr; + PbcType pbcType = PbcType::Unset; + const t_atoms* atoms = nullptr; rvec * xtop, *xref1, *xref2, *xrefp = nullptr; gmx_bool bDMR1, bDMA1, bDMR2, bDMA2; int nvec1, nvec2, *eignr1 = nullptr, *eignr2 = nullptr; @@ -1263,9 +1263,9 @@ int gmx_anaeig(int argc, char* argv[]) } else { - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, topbox, bM); + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, topbox, bM); atoms = &top.atoms; - gpbc = gmx_rmpbc_init(&top.idef, ePBC, atoms->nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, atoms->nr); gmx_rmpbc(gpbc, atoms->nr, topbox, xtop); /* Fitting is only required for the projection */ if (bProj && bFit1) @@ -1465,7 +1465,7 @@ int gmx_anaeig(int argc, char* argv[]) if (bProj) { - project(bTraj ? opt2fn("-f", NFILE, fnm) : nullptr, bTop ? &top : nullptr, ePBC, topbox, + project(bTraj ? opt2fn("-f", NFILE, fnm) : nullptr, bTop ? &top : nullptr, pbcType, topbox, ProjOnVecFile, TwoDPlotFile, ThreeDPlotFile, FilterFile, skip, ExtremeFile, bFirstLastSet, max, nextr, atoms, natoms, index, bFit1, xrefp, nfit, ifit, w_rls, sqrtm, xav1, eignr1, eigvec1, noutvec, outvec, bSplit, oenv); diff --git a/src/gromacs/gmxana/gmx_bundle.cpp b/src/gromacs/gmxana/gmx_bundle.cpp index be9c6f4be6..a55cde5f95 100644 --- a/src/gromacs/gmxana/gmx_bundle.cpp +++ b/src/gromacs/gmxana/gmx_bundle.cpp @@ -228,7 +228,7 @@ int gmx_bundle(int argc, char* argv[]) t_trxstatus* status; t_trxstatus* fpdb; t_topology top; - int ePBC; + PbcType pbcType; rvec* xtop; matrix box; t_trxframe fr; @@ -263,7 +263,7 @@ int gmx_bundle(int argc, char* argv[]) return 0; } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, box, TRUE); bKink = opt2bSet("-ok", NFILE, fnm) || opt2bSet("-okr", NFILE, fnm) || opt2bSet("-okl", NFILE, fnm); if (bKink) @@ -345,7 +345,7 @@ int gmx_bundle(int argc, char* argv[]) } read_first_frame(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &fr, TRX_NEED_X); - gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, fr.natoms); do { diff --git a/src/gromacs/gmxana/gmx_chi.cpp b/src/gromacs/gmxana/gmx_chi.cpp index 03e50be5d9..21be848c98 100644 --- a/src/gromacs/gmxana/gmx_chi.cpp +++ b/src/gromacs/gmxana/gmx_chi.cpp @@ -1072,7 +1072,7 @@ static void order_params(FILE* log, real bfac_init, t_atoms* atoms, const rvec x[], - int ePBC, + PbcType pbcType, matrix box, gmx_bool bPhi, gmx_bool bPsi, @@ -1182,7 +1182,7 @@ static void order_params(FILE* log, fprintf(fp, "REMARK " "B-factor field contains negative of dihedral order parameters\n"); - write_pdbfile(fp, nullptr, atoms, x, ePBC, box, ' ', 0, nullptr); + write_pdbfile(fp, nullptr, atoms, x, pbcType, box, ' ', 0, nullptr); x0 = y0 = z0 = 1000.0; for (i = 0; (i < atoms->nr); i++) { @@ -1402,7 +1402,7 @@ int gmx_chi(int argc, char* argv[]) FILE* log; int nlist, idum, nbin; rvec* x; - int ePBC; + PbcType pbcType; matrix box; char grpname[256]; t_dlist* dlist; @@ -1488,7 +1488,7 @@ int gmx_chi(int argc, char* argv[]) /* Find the chi angles using atoms struct and a list of amino acids */ t_topology* top; snew(top, 1); - read_tps_conf(ftp2fn(efSTX, NFILE, fnm), top, &ePBC, &x, nullptr, box, FALSE); + read_tps_conf(ftp2fn(efSTX, NFILE, fnm), top, &pbcType, &x, nullptr, box, FALSE); t_atoms& atoms = top->atoms; if (atoms.pdbinfo == nullptr) { @@ -1572,7 +1572,7 @@ int gmx_chi(int argc, char* argv[]) /* Order parameters */ order_params(log, opt2fn("-o", NFILE, fnm), maxchi, nlist, dlist, ftp2fn_null(efPDB, NFILE, fnm), - bfac_init, &atoms, x, ePBC, box, bPhi, bPsi, bChi, oenv); + bfac_init, &atoms, x, pbcType, box, bPhi, bPsi, bChi, oenv); /* Print ramachandran maps! */ if (bRama) diff --git a/src/gromacs/gmxana/gmx_cluster.cpp b/src/gromacs/gmxana/gmx_cluster.cpp index 160ddc64b3..751c62f6d0 100644 --- a/src/gromacs/gmxana/gmx_cluster.cpp +++ b/src/gromacs/gmxana/gmx_cluster.cpp @@ -1437,7 +1437,7 @@ int gmx_cluster(int argc, char* argv[]) t_mat * rms, *orig = nullptr; real* eigenvalues; t_topology top; - int ePBC; + PbcType pbcType; t_atoms useatoms; real* eigenvectors; @@ -1670,10 +1670,10 @@ int gmx_cluster(int argc, char* argv[]) if (bReadTraj) { /* don't read mass-database as masses (and top) are not used */ - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtps, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtps, nullptr, box, TRUE); if (bPBC) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, top.atoms.nr); } fprintf(stderr, "\nSelect group for least squares fit%s:\n", bReadMat ? "" : " and RMSD calculation"); diff --git a/src/gromacs/gmxana/gmx_clustsize.cpp b/src/gromacs/gmxana/gmx_clustsize.cpp index 69c815c130..fd64ddf7f9 100644 --- a/src/gromacs/gmxana/gmx_clustsize.cpp +++ b/src/gromacs/gmxana/gmx_clustsize.cpp @@ -96,8 +96,8 @@ static void clust_size(const char* ndx, /* Topology stuff */ t_trxframe fr; TpxFileHeader tpxh; - gmx_mtop_t* mtop = nullptr; - int ePBC = -1; + gmx_mtop_t* mtop = nullptr; + PbcType pbcType = PbcType::Unset; int ii, jj; real temp, tfac; /* Cluster size distribution (matrix) */ @@ -133,7 +133,7 @@ static void clust_size(const char* ndx, { gmx_fatal(FARGS, "tpr (%d atoms) and trajectory (%d atoms) do not match!", tpxh.natoms, natoms); } - ePBC = read_tpx(tpr, nullptr, nullptr, &natoms, nullptr, nullptr, mtop); + pbcType = read_tpx(tpr, nullptr, nullptr, &natoms, nullptr, nullptr, mtop); } if (ndf <= -1) { @@ -188,7 +188,7 @@ static void clust_size(const char* ndx, { if (bPBC) { - set_pbc(&pbc, ePBC, fr.box); + set_pbc(&pbc, pbcType, fr.box); } max_clust_size = 1; max_clust_ind = -1; diff --git a/src/gromacs/gmxana/gmx_confrms.cpp b/src/gromacs/gmxana/gmx_confrms.cpp index 40d756f8f0..213aaf1130 100644 --- a/src/gromacs/gmxana/gmx_confrms.cpp +++ b/src/gromacs/gmxana/gmx_confrms.cpp @@ -526,7 +526,7 @@ int gmx_confrms(int argc, char* argv[]) FILE* fp; char * name1, *name2; t_topology *top1, *top2; - int ePBC1, ePBC2; + PbcType pbcType1, pbcType2; t_atoms * atoms1, *atoms2; int warn = 0; int at; @@ -562,7 +562,7 @@ int gmx_confrms(int argc, char* argv[]) /* reading reference structure from first structure file */ fprintf(stderr, "\nReading first structure file\n"); snew(top1, 1); - read_tps_conf(conf1file, top1, &ePBC1, &x1, &v1, box1, TRUE); + read_tps_conf(conf1file, top1, &pbcType1, &x1, &v1, box1, TRUE); atoms1 = &(top1->atoms); fprintf(stderr, "%s\nContaining %d atoms in %d residues\n", *top1->name, atoms1->nr, atoms1->nres); @@ -583,7 +583,7 @@ int gmx_confrms(int argc, char* argv[]) /* reading second structure file */ fprintf(stderr, "\nReading second structure file\n"); snew(top2, 1); - read_tps_conf(conf2file, top2, &ePBC2, &x2, &v2, box2, TRUE); + read_tps_conf(conf2file, top2, &pbcType2, &x2, &v2, box2, TRUE); atoms2 = &(top2->atoms); fprintf(stderr, "%s\nContaining %d atoms in %d residues\n", *top2->name, atoms2->nr, atoms2->nres); @@ -793,9 +793,9 @@ int gmx_confrms(int argc, char* argv[]) fp = gmx_ffopen(outfile, "w"); if (!bOne) { - write_pdbfile(fp, *top1->name, atoms1, x1, ePBC1, box1, ' ', 1, nullptr); + write_pdbfile(fp, *top1->name, atoms1, x1, pbcType1, box1, ' ', 1, nullptr); } - write_pdbfile(fp, *top2->name, atoms2, x2, ePBC2, box2, ' ', bOne ? -1 : 2, nullptr); + write_pdbfile(fp, *top2->name, atoms2, x2, pbcType2, box2, ' ', bOne ? -1 : 2, nullptr); gmx_ffclose(fp); break; case efGRO: @@ -822,7 +822,7 @@ int gmx_confrms(int argc, char* argv[]) fprintf(stderr, "WARNING: cannot write the reference structure to %s file\n", ftp2ext(fn2ftp(outfile))); } - write_sto_conf(outfile, *top2->name, atoms2, x2, v2, ePBC2, box2); + write_sto_conf(outfile, *top2->name, atoms2, x2, v2, pbcType2, box2); break; } diff --git a/src/gromacs/gmxana/gmx_covar.cpp b/src/gromacs/gmxana/gmx_covar.cpp index 9fa548e9bd..5fa50372bf 100644 --- a/src/gromacs/gmxana/gmx_covar.cpp +++ b/src/gromacs/gmxana/gmx_covar.cpp @@ -114,7 +114,7 @@ int gmx_covar(int argc, char* argv[]) FILE* out = nullptr; /* initialization makes all compilers happy */ t_trxstatus* status; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; rvec * x, *xread, *xref, *xav, *xproj; matrix box, zerobox; @@ -165,7 +165,7 @@ int gmx_covar(int argc, char* argv[]) xpmfile = opt2fn_null("-xpm", NFILE, fnm); xpmafile = opt2fn_null("-xpma", NFILE, fnm); - read_tps_conf(fitfile, &top, &ePBC, &xref, nullptr, box, TRUE); + read_tps_conf(fitfile, &top, &pbcType, &xref, nullptr, box, TRUE); atoms = &top.atoms; if (bFit) @@ -239,7 +239,7 @@ int gmx_covar(int argc, char* argv[]) /* Prepare reference frame */ if (bPBC) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, atoms->nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, atoms->nr); gmx_rmpbc(gpbc, atoms->nr, box, xref); } if (bFit) @@ -294,7 +294,7 @@ int gmx_covar(int argc, char* argv[]) } } write_sto_conf_indexed(opt2fn("-av", NFILE, fnm), "Average structure", atoms, xread, nullptr, - epbcNONE, zerobox, natoms, index); + PbcType::No, zerobox, natoms, index); sfree(xread); fprintf(stderr, "Constructing covariance matrix (%dx%d) ...\n", static_cast(ndim), diff --git a/src/gromacs/gmxana/gmx_current.cpp b/src/gromacs/gmxana/gmx_current.cpp index 4010e2751d..067f46c797 100644 --- a/src/gromacs/gmxana/gmx_current.cpp +++ b/src/gromacs/gmxana/gmx_current.cpp @@ -189,7 +189,7 @@ static void remove_jump(matrix box, int natoms, rvec xp[], rvec x[]) } static void calc_mj(t_topology top, - int ePBC, + PbcType pbcType, matrix box, gmx_bool bNoJump, int isize, @@ -211,7 +211,7 @@ static void calc_mj(t_topology top, if (!bNoJump) { - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); } clear_rvec(tmp); @@ -355,7 +355,7 @@ static void dielectric(FILE* fmj, gmx_bool bNoJump, gmx_bool bACF, gmx_bool bINT, - int ePBC, + PbcType pbcType, t_topology top, t_trxframe fr, real temp, @@ -455,7 +455,7 @@ static void dielectric(FILE* fmj, clear_rvec(mjd_tmp); clear_rvec(mdvec); clear_rvec(tmp); - gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, fr.natoms); do { @@ -519,7 +519,7 @@ static void dielectric(FILE* fmj, gmx_rmpbc_trxfr(gpbc, &fr); - calc_mj(top, ePBC, fr.box, bNoJump, nmols, indexm, fr.x, mtrans[nfr], mass2, qmol); + calc_mj(top, pbcType, fr.box, bNoJump, nmols, indexm, fr.x, mtrans[nfr], mass2, qmol); for (i = 0; i < isize; i++) { @@ -857,7 +857,7 @@ int gmx_current(int argc, char* argv[]) int flags = 0; gmx_bool bACF; gmx_bool bINT; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; int nmols; int i; real* qmol; @@ -943,7 +943,7 @@ int gmx_current(int argc, char* argv[]) bACF = opt2bSet("-caf", NFILE, fnm); bINT = opt2bSet("-mc", NFILE, fnm); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, nullptr, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, nullptr, nullptr, box, TRUE); indexfn = ftp2fn_null(efNDX, NFILE, fnm); snew(grpname, 1); @@ -1009,7 +1009,7 @@ int gmx_current(int argc, char* argv[]) /* System information is read and prepared, dielectric() processes the frames * and calculates the requested quantities */ - dielectric(fmj, fmd, outf, fcur, mcor, fmjdsp, bNoJump, bACF, bINT, ePBC, top, fr, temp, bfit, efit, + dielectric(fmj, fmd, outf, fcur, mcor, fmjdsp, bNoJump, bACF, bINT, pbcType, top, fr, temp, bfit, efit, bvit, evit, status, isize, nmols, nshift, index0, indexm, mass2, qmol, eps_rf, oenv); xvgrclose(fmj); diff --git a/src/gromacs/gmxana/gmx_density.cpp b/src/gromacs/gmxana/gmx_density.cpp index b750f13e0a..1a15db384e 100644 --- a/src/gromacs/gmxana/gmx_density.cpp +++ b/src/gromacs/gmxana/gmx_density.cpp @@ -174,7 +174,7 @@ static void calc_electron_density(const char* fn, double*** slDensity, int* nslices, t_topology* top, - int ePBC, + PbcType pbcType, int axis, int nr_grps, real* slWidth, @@ -225,7 +225,7 @@ static void calc_electron_density(const char* fn, snew((*slDensity)[i], *nslices); } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr); /*********** Start processing trajectory ***********/ do { @@ -338,7 +338,7 @@ static void calc_density(const char* fn, double*** slDensity, int* nslices, t_topology* top, - int ePBC, + PbcType pbcType, int axis, int nr_grps, real* slWidth, @@ -386,7 +386,7 @@ static void calc_density(const char* fn, snew((*slDensity)[i], *nslices); } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr); /*********** Start processing trajectory ***********/ snew(den_val, top->atoms.nr); @@ -714,7 +714,7 @@ int gmx_density(int argc, char* argv[]) int* ngx; /* sizes of groups */ t_electron* el_tab; /* tabel with nr. of electrons*/ t_topology* top; /* topology */ - int ePBC; + PbcType pbcType; int* index_center; /* index for centering group */ int** index; /* indices for all groups */ @@ -745,7 +745,7 @@ int gmx_density(int argc, char* argv[]) /* Calculate axis */ axis = toupper(axtitle[0]) - 'X'; - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); /* read topology file */ + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); /* read topology file */ snew(grpname, ngrps); snew(index, ngrps); @@ -774,13 +774,13 @@ int gmx_density(int argc, char* argv[]) nr_electrons = get_electrons(&el_tab, ftp2fn(efDAT, NFILE, fnm)); fprintf(stderr, "Read %d atomtypes from datafile\n", nr_electrons); - calc_electron_density(ftp2fn(efTRX, NFILE, fnm), index, ngx, &density, &nslices, top, ePBC, - axis, ngrps, &slWidth, el_tab, nr_electrons, bCenter, index_center, - ncenter, bRelative, oenv); + calc_electron_density(ftp2fn(efTRX, NFILE, fnm), index, ngx, &density, &nslices, top, + pbcType, axis, ngrps, &slWidth, el_tab, nr_electrons, bCenter, + index_center, ncenter, bRelative, oenv); } else { - calc_density(ftp2fn(efTRX, NFILE, fnm), index, ngx, &density, &nslices, top, ePBC, axis, + calc_density(ftp2fn(efTRX, NFILE, fnm), index, ngx, &density, &nslices, top, pbcType, axis, ngrps, &slWidth, bCenter, index_center, ncenter, bRelative, oenv, dens_opt); } diff --git a/src/gromacs/gmxana/gmx_densmap.cpp b/src/gromacs/gmxana/gmx_densmap.cpp index f9bca9de09..f9c838b2a7 100644 --- a/src/gromacs/gmxana/gmx_densmap.cpp +++ b/src/gromacs/gmxana/gmx_densmap.cpp @@ -121,7 +121,7 @@ int gmx_densmap(int argc, char* argv[]) FILE* fp; t_trxstatus* status; t_topology top; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; rvec * x, xcom[2], direction, center, dx; matrix box; real t, m, mtot; @@ -184,7 +184,7 @@ int gmx_densmap(int argc, char* argv[]) if (ftp2bSet(efTPS, NFILE, fnm) || !ftp2bSet(efNDX, NFILE, fnm)) { - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x, nullptr, box, bRadial); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x, nullptr, box, bRadial); } if (!bRadial) { @@ -316,7 +316,7 @@ int gmx_densmap(int argc, char* argv[]) } else { - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (i = 0; i < 2; i++) { if (gnx[i] == 1) diff --git a/src/gromacs/gmxana/gmx_densorder.cpp b/src/gromacs/gmxana/gmx_densorder.cpp index 194a3b4a35..0942cda75c 100644 --- a/src/gromacs/gmxana/gmx_densorder.cpp +++ b/src/gromacs/gmxana/gmx_densorder.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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 @@ static void density_in_time(const char* fn, int* zslices, int* tblock, const t_topology* top, - int ePBC, + PbcType pbcType, int axis, gmx_bool bCenter, gmx_bool bps1d, @@ -191,7 +191,7 @@ static void density_in_time(const char* fn, /****Start trajectory processing***/ /*Initialize Densdevel and PBC-remove*/ - gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr); *Densdevel = nullptr; @@ -708,7 +708,8 @@ int gmx_densorder(int argc, char* argv[]) gmx_output_env_t* oenv; t_topology* top; char** grpname; - int ePBC, *ngx; + PbcType pbcType; + int* ngx; static real binw = 0.2; static real binwz = 0.05; static real dens1 = 0.00; @@ -789,7 +790,7 @@ int gmx_densorder(int argc, char* argv[]) bRawOut = opt2bSet("-or", NFILE, fnm); bGraph = opt2bSet("-og", NFILE, fnm); bOut = opt2bSet("-o", NFILE, fnm); - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); snew(grpname, 1); snew(index, 1); snew(ngx, 1); @@ -800,7 +801,7 @@ int gmx_densorder(int argc, char* argv[]) get_index(&top->atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, ngx, index, grpname); density_in_time(ftp2fn(efTRX, NFILE, fnm), index, ngx, binw, binwz, nsttblock, &Densmap, - &xslices, &yslices, &zslices, &tblock, top, ePBC, axis, bCenter, b1d, oenv); + &xslices, &yslices, &zslices, &tblock, top, pbcType, axis, bCenter, b1d, oenv); if (ftorder > 0) { diff --git a/src/gromacs/gmxana/gmx_dipoles.cpp b/src/gromacs/gmxana/gmx_dipoles.cpp index 0ba82617c6..4f5e8f2d00 100644 --- a/src/gromacs/gmxana/gmx_dipoles.cpp +++ b/src/gromacs/gmxana/gmx_dipoles.cpp @@ -186,7 +186,7 @@ static void do_gkr(t_gkrbin* gb, const int mindex[], rvec x[], rvec mu[], - int ePBC, + PbcType pbcType, const matrix box, const t_atom* atom, const int* nAtom) @@ -231,7 +231,7 @@ static void do_gkr(t_gkrbin* gb, } } } - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); grp0 = 0; grp1 = ncos - 1; for (i = 0; i < ngrp[grp0]; i++) @@ -726,7 +726,7 @@ static void compute_avercos(int n, rvec dip[], real* dd, rvec axis, gmx_bool bPa } static void do_dip(const t_topology* top, - int ePBC, + PbcType pbcType, real volume, const char* fn, const char* out_mtot, @@ -1020,7 +1020,7 @@ static void do_dip(const t_topology* top, gkrbin = mk_gkrbin(rcut, rcmax, bPhi, ndegrees); } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natom); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natom); /* Start while loop over frames */ t0 = t; @@ -1214,7 +1214,7 @@ static void do_dip(const t_topology* top, if (bGkr) { - do_gkr(gkrbin, ncos, gnx, molindex, mols->index, x, dipole, ePBC, box, atom, gkatom); + do_gkr(gkrbin, ncos, gnx, molindex, mols->index, x, dipole, pbcType, box, atom, gkatom); } if (bTotal) @@ -1623,7 +1623,7 @@ int gmx_dipoles(int argc, char* argv[]) int npargs; t_pargs* ppa; t_topology* top; - int ePBC; + PbcType pbcType; int k, natoms; matrix box; @@ -1682,7 +1682,7 @@ int gmx_dipoles(int argc, char* argv[]) } snew(top, 1); - ePBC = read_tpx_top(ftp2fn(efTPR, NFILE, fnm), nullptr, box, &natoms, nullptr, nullptr, top); + pbcType = read_tpx_top(ftp2fn(efTPR, NFILE, fnm), nullptr, box, &natoms, nullptr, nullptr, top); snew(gnx, ncos); snew(grpname, ncos); @@ -1695,7 +1695,7 @@ int gmx_dipoles(int argc, char* argv[]) } nFF[0] = nFA; nFF[1] = nFB; - do_dip(top, ePBC, det(box), ftp2fn(efTRX, NFILE, fnm), opt2fn("-o", NFILE, fnm), + do_dip(top, pbcType, det(box), ftp2fn(efTRX, NFILE, fnm), opt2fn("-o", NFILE, fnm), opt2fn("-eps", NFILE, fnm), opt2fn("-a", NFILE, fnm), opt2fn("-d", NFILE, fnm), opt2fn_null("-cos", NFILE, fnm), opt2fn_null("-dip3d", NFILE, fnm), opt2fn_null("-adip", NFILE, fnm), bPairs, corrtype[0], opt2fn("-c", NFILE, fnm), bGkr, diff --git a/src/gromacs/gmxana/gmx_disre.cpp b/src/gromacs/gmxana/gmx_disre.cpp index 57d58981ea..5aee92a348 100644 --- a/src/gromacs/gmxana/gmx_disre.cpp +++ b/src/gromacs/gmxana/gmx_disre.cpp @@ -752,7 +752,7 @@ int gmx_disre(int argc, char* argv[]) g = nullptr; pbc_null = nullptr; - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { if (ir->bPeriodicMols) { @@ -812,19 +812,19 @@ int gmx_disre(int argc, char* argv[]) auto mdAtoms = gmx::makeMDAtoms(fplog, *topInfo.mtop(), *ir, false); atoms2md(topInfo.mtop(), ir, -1, nullptr, ntopatoms, mdAtoms.get()); update_mdatoms(mdAtoms->mdatoms(), ir->fepvals->init_lambda); - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { - gpbc = gmx_rmpbc_init(&top.idef, ir->ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, ir->pbcType, natoms); } j = 0; do { - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { if (ir->bPeriodicMols) { - set_pbc(&pbc, ir->ePBC, box); + set_pbc(&pbc, ir->pbcType, box); } else { @@ -885,7 +885,7 @@ int gmx_disre(int argc, char* argv[]) j++; } while (read_next_x(oenv, status, &t, x, box)); close_trx(status); - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { gmx_rmpbc_done(gpbc); } @@ -902,7 +902,7 @@ int gmx_disre(int argc, char* argv[]) if (bPDB) { write_sto_conf(opt2fn("-q", NFILE, fnm), "Coloured by average violation in Angstrom", - atoms.get(), xav, nullptr, ir->ePBC, box); + atoms.get(), xav, nullptr, ir->pbcType, box); } dump_disre_matrix(opt2fn_null("-x", NFILE, fnm), &dr, fcd.disres.nres, j, &top.idef, topInfo.mtop(), max_dr, nlevels, bThird); diff --git a/src/gromacs/gmxana/gmx_do_dssp.cpp b/src/gromacs/gmxana/gmx_do_dssp.cpp index a52ced5734..f030505f71 100644 --- a/src/gromacs/gmxana/gmx_do_dssp.cpp +++ b/src/gromacs/gmxana/gmx_do_dssp.cpp @@ -522,7 +522,7 @@ int gmx_do_dssp(int argc, char* argv[]) const char * fnSCount, *fnArea, *fnTArea, *fnAArea; const char* leg[] = { "Phobic", "Phylic" }; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; t_matrix mat; int nres, nr0, naccr, nres_plus_separators; @@ -562,7 +562,7 @@ int gmx_do_dssp(int argc, char* argv[]) fnAArea = opt2fn_null("-aa", NFILE, fnm); bDoAccSurf = ((fnArea != nullptr) || (fnTArea != nullptr) || (fnAArea != nullptr)); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xp, nullptr, box, FALSE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xp, nullptr, box, FALSE); atoms = &(top.atoms); check_oo(atoms); bPhbres = bPhobics(atoms); @@ -674,7 +674,7 @@ int gmx_do_dssp(int argc, char* argv[]) accr = nullptr; naccr = 0; - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); do { t = output_env_conv_time(oenv, t); @@ -689,7 +689,7 @@ int gmx_do_dssp(int argc, char* argv[]) } gmx_rmpbc(gpbc, natoms, box, x); tapein = gmx_ffopen(pdbfile, "w"); - write_pdbfile_indexed(tapein, nullptr, atoms, x, ePBC, box, ' ', -1, gnx, index, nullptr, FALSE); + write_pdbfile_indexed(tapein, nullptr, atoms, x, pbcType, box, ' ', -1, gnx, index, nullptr, FALSE); gmx_ffclose(tapein); /* strip_dssp returns the number of lines found in the dssp file, i.e. * the number of residues plus the separator lines */ diff --git a/src/gromacs/gmxana/gmx_dos.cpp b/src/gromacs/gmxana/gmx_dos.cpp index 344ad272ea..2c1a9717c4 100644 --- a/src/gromacs/gmxana/gmx_dos.cpp +++ b/src/gromacs/gmxana/gmx_dos.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2011-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -54,6 +54,7 @@ #include "gromacs/math/units.h" #include "gromacs/math/utilities.h" #include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/topology/index.h" #include "gromacs/topology/topology.h" #include "gromacs/trajectory/trajectoryframe.h" @@ -270,7 +271,7 @@ int gmx_dos(int argc, char* argv[]) }; FILE * fp, *fplog; t_topology top; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; t_trxframe fr; matrix box; int gnx; @@ -347,7 +348,7 @@ int gmx_dos(int argc, char* argv[]) please_cite(fplog, "Pascal2011a"); please_cite(fplog, "Caleman2011b"); - read_tps_conf(ftp2fn(efTPR, NFILE, fnm), &top, &ePBC, nullptr, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPR, NFILE, fnm), &top, &pbcType, nullptr, nullptr, box, TRUE); /* Handle index groups */ get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &grpNatoms, &index, &grpname); diff --git a/src/gromacs/gmxana/gmx_dyecoupl.cpp b/src/gromacs/gmxana/gmx_dyecoupl.cpp index 2391009e84..301ca77e8e 100644 --- a/src/gromacs/gmxana/gmx_dyecoupl.cpp +++ b/src/gromacs/gmxana/gmx_dyecoupl.cpp @@ -108,7 +108,7 @@ int gmx_dyecoupl(int argc, char* argv[]) int natoms; /*we rely on PBC autodetection (...currently)*/ - int ePBC = -1; + PbcType pbcType = PbcType::Unset; real * rvalues = nullptr, *kappa2values = nullptr, *rhist = nullptr, *khist = nullptr; t_pbc* pbc = nullptr; @@ -285,7 +285,7 @@ int gmx_dyecoupl(int argc, char* argv[]) if (bPBCdist) { - set_pbc(pbc, ePBC, fr.box); + set_pbc(pbc, pbcType, fr.box); pbc_dx(pbc, donpos, accpos, dist); } else diff --git a/src/gromacs/gmxana/gmx_filter.cpp b/src/gromacs/gmxana/gmx_filter.cpp index 45505439f4..c9567a806b 100644 --- a/src/gromacs/gmxana/gmx_filter.cpp +++ b/src/gromacs/gmxana/gmx_filter.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2017,2019,2020, 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. @@ -47,6 +47,7 @@ #include "gromacs/math/do_fit.h" #include "gromacs/math/utilities.h" #include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/pbcutil/rmpbc.h" #include "gromacs/topology/index.h" #include "gromacs/topology/topology.h" @@ -94,7 +95,7 @@ int gmx_filter(int argc, char* argv[]) const char * topfile, *lowfile, *highfile; gmx_bool bTop = FALSE; t_topology top; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; rvec* xtop; matrix topbox, *box, boxf; char* grpname; @@ -137,10 +138,10 @@ int gmx_filter(int argc, char* argv[]) } if (topfile) { - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, topbox, TRUE); + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, topbox, TRUE); if (bTop) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, top.atoms.nr); gmx_rmpbc(gpbc, top.atoms.nr, topbox, xtop); } } diff --git a/src/gromacs/gmxana/gmx_gyrate.cpp b/src/gromacs/gmxana/gmx_gyrate.cpp index 4a723ef399..6df19ae6fe 100644 --- a/src/gromacs/gmxana/gmx_gyrate.cpp +++ b/src/gromacs/gmxana/gmx_gyrate.cpp @@ -222,7 +222,7 @@ int gmx_gyrate(int argc, char* argv[]) FILE* out; t_trxstatus* status; t_topology top; - int ePBC; + PbcType pbcType; rvec * x, *x_s; rvec xcm, gvec, gvec1; matrix box, trans; @@ -283,7 +283,7 @@ int gmx_gyrate(int argc, char* argv[]) printf("Will print radius normalised by charge\n"); } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x, nullptr, box, TRUE); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &gnx, &index, &grpname); if (nmol > gnx || gnx % nmol != 0) @@ -329,7 +329,7 @@ int gmx_gyrate(int argc, char* argv[]) } if (nz == 0) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); } do { diff --git a/src/gromacs/gmxana/gmx_h2order.cpp b/src/gromacs/gmxana/gmx_h2order.cpp index f3abed6da4..1e52fe0b49 100644 --- a/src/gromacs/gmxana/gmx_h2order.cpp +++ b/src/gromacs/gmxana/gmx_h2order.cpp @@ -72,7 +72,7 @@ static void calc_h2order(const char* fn, real* slWidth, int* nslices, const t_topology* top, - int ePBC, + PbcType pbcType, int axis, gmx_bool bMicel, int micel[], @@ -133,7 +133,7 @@ static void calc_h2order(const char* fn, teller = 0; - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); /*********** Start processing trajectory ***********/ do { @@ -301,7 +301,7 @@ int gmx_h2order(int argc, char* argv[]) int ngx, /* nr. of atomsin sol group */ nmic = 0; /* nr. of atoms in micelle */ t_topology* top; /* topology */ - int ePBC; + PbcType pbcType; int * index, /* indices for solvent group */ *micelle = nullptr; gmx_bool bMicel = FALSE; /* think we're a micel */ @@ -323,7 +323,7 @@ int gmx_h2order(int argc, char* argv[]) } bMicel = opt2bSet("-nm", NFILE, fnm); - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); /* read topology file */ + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); /* read topology file */ rd_index(ftp2fn(efNDX, NFILE, fnm), 1, &ngx, &index, &grpname); @@ -333,7 +333,7 @@ int gmx_h2order(int argc, char* argv[]) } calc_h2order(ftp2fn(efTRX, NFILE, fnm), index, ngx, &slDipole, &slOrder, &slWidth, &nslices, - top, ePBC, axis, bMicel, micelle, nmic, oenv); + top, pbcType, axis, bMicel, micelle, nmic, oenv); h2order_plot(slDipole, slOrder, opt2fn("-o", NFILE, fnm), nslices, slWidth, oenv); diff --git a/src/gromacs/gmxana/gmx_hbond.cpp b/src/gromacs/gmxana/gmx_hbond.cpp index 2c614d1a44..2348ef122a 100644 --- a/src/gromacs/gmxana/gmx_hbond.cpp +++ b/src/gromacs/gmxana/gmx_hbond.cpp @@ -2848,7 +2848,7 @@ int gmx_hbond(int argc, char* argv[]) gmx_fatal(FARGS, "Topology (%d atoms) does not match trajectory (%d atoms)", top.atoms.nr, natoms); } - bBox = (ir->ePBC != epbcNONE); + bBox = (ir->pbcType != PbcType::No); grid = init_grid(bBox, box, (rcut > r2cut) ? rcut : r2cut, ngrid); nabin = static_cast(acut / abin); nrbin = static_cast(rcut / rbin); diff --git a/src/gromacs/gmxana/gmx_helix.cpp b/src/gromacs/gmxana/gmx_helix.cpp index 4495954434..0b9399ae09 100644 --- a/src/gromacs/gmxana/gmx_helix.cpp +++ b/src/gromacs/gmxana/gmx_helix.cpp @@ -144,7 +144,7 @@ int gmx_helix(int argc, char* argv[]) int i, j, nall, nbb, nca, teller; int * bbindex, *caindex, *allindex; t_topology* top; - int ePBC; + PbcType pbcType; rvec * x, *xref; real t; real rms; @@ -167,7 +167,7 @@ int gmx_helix(int argc, char* argv[]) bRange = (opt2parg_bSet("-ahxstart", asize(pa), pa) && opt2parg_bSet("-ahxend", asize(pa), pa)); - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); natoms = read_first_x(oenv, &status, opt2fn("-f", NFILE, fnm), &t, &x, box); @@ -212,7 +212,7 @@ int gmx_helix(int argc, char* argv[]) pr_bb(stdout, nres, bb); } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); teller = 0; do @@ -238,7 +238,7 @@ int gmx_helix(int argc, char* argv[]) if (teller == 1) { write_sto_conf(opt2fn("-cz", NFILE, fnm), "Helix fitted to Z-Axis", &(top->atoms), - x, nullptr, ePBC, box); + x, nullptr, pbcType, box); } xf[efhRAD].val = radius(xf[efhRAD].fp2, nca, caindex, x); diff --git a/src/gromacs/gmxana/gmx_helixorient.cpp b/src/gromacs/gmxana/gmx_helixorient.cpp index fef5d10ae4..c5651ce84a 100644 --- a/src/gromacs/gmxana/gmx_helixorient.cpp +++ b/src/gromacs/gmxana/gmx_helixorient.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2017,2019,2020, 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. @@ -126,11 +126,11 @@ int gmx_helixorient(int argc, char* argv[]) t_pbc pbc; matrix A; - FILE *fpaxis, *fpcenter, *fptilt, *fprotation; - FILE *fpradius, *fprise, *fptwist; - FILE *fptheta1, *fptheta2, *fptheta3; - FILE* fpbending; - int ePBC; + FILE * fpaxis, *fpcenter, *fptilt, *fprotation; + FILE * fpradius, *fprise, *fptwist; + FILE * fptheta1, *fptheta2, *fptheta3; + FILE* fpbending; + PbcType pbcType; gmx_output_env_t* oenv; gmx_rmpbc_t gpbc = nullptr; @@ -168,7 +168,7 @@ int gmx_helixorient(int argc, char* argv[]) return 0; } - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); for (i = 0; i < 3; i++) { @@ -249,12 +249,12 @@ int gmx_helixorient(int argc, char* argv[]) unitaxes[1][1] = 1; unitaxes[2][2] = 1; - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); do { /* initialisation for correct distance calculations */ - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); /* make molecules whole again */ gmx_rmpbc(gpbc, natoms, box, x); diff --git a/src/gromacs/gmxana/gmx_hydorder.cpp b/src/gromacs/gmxana/gmx_hydorder.cpp index c7f81a1ee4..9e45a5ba7d 100644 --- a/src/gromacs/gmxana/gmx_hydorder.cpp +++ b/src/gromacs/gmxana/gmx_hydorder.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -61,7 +61,7 @@ #include "gromacs/utility/smalloc.h" static void find_tetra_order_grid(t_topology top, - int ePBC, + PbcType pbcType, int natoms, matrix box, rvec x[], @@ -115,8 +115,8 @@ static void find_tetra_order_grid(t_topology top, snew(skmol, maxidx); /* Must init pbc every step because of pressure coupling */ - set_pbc(&pbc, ePBC, box); - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + set_pbc(&pbc, pbcType, box); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); gmx_rmpbc(gpbc, natoms, box, x); *sgmean = 0.0; @@ -280,7 +280,7 @@ static void calc_tetra_order_interface(const char* fnNDX, { FILE * fpsg = nullptr, *fpsk = nullptr; t_topology top; - int ePBC; + PbcType pbcType; t_trxstatus* status; int natoms; real t; @@ -300,7 +300,7 @@ static void calc_tetra_order_interface(const char* fnNDX, * i.e 1D Row-major order in (t,x,y) */ - read_tps_conf(fnTPS, &top, &ePBC, &xtop, nullptr, box, FALSE); + read_tps_conf(fnTPS, &top, &pbcType, &xtop, nullptr, box, FALSE); *nslicex = static_cast(box[XX][XX] / binw + onehalf); /*Calculate slicenr from binwidth*/ *nslicey = static_cast(box[YY][YY] / binw + onehalf); @@ -366,7 +366,7 @@ static void calc_tetra_order_interface(const char* fnNDX, } } - find_tetra_order_grid(top, ePBC, natoms, box, x, isize[0], index[0], &sg, &sk, *nslicex, + find_tetra_order_grid(top, pbcType, natoms, box, x, isize[0], index[0], &sg, &sk, *nslicex, *nslicey, nslicez, sg_grid, sk_grid); GMX_RELEASE_ASSERT(sk_fravg != nullptr, "Trying to dereference NULL sk_fravg pointer"); for (i = 0; i < *nslicex; i++) diff --git a/src/gromacs/gmxana/gmx_make_edi.cpp b/src/gromacs/gmxana/gmx_make_edi.cpp index e3dbfe1906..288cff7fed 100644 --- a/src/gromacs/gmxana/gmx_make_edi.cpp +++ b/src/gromacs/gmxana/gmx_make_edi.cpp @@ -901,7 +901,7 @@ int gmx_make_edi(int argc, char* argv[]) /*to read topology file*/ t_topology top; - int ePBC; + PbcType pbcType; matrix topbox; rvec* xtop; gmx_bool bFit1; @@ -999,7 +999,7 @@ int gmx_make_edi(int argc, char* argv[]) read_eigenvectors(EigvecFile, &nav, &bFit1, &xref1, &edi_params.fitmas, &xav1, &edi_params.pcamas, &nvec1, &eignr1, &eigvec1, &eigval1); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, topbox, false); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, topbox, false); atoms = &top.atoms; diff --git a/src/gromacs/gmxana/gmx_mdmat.cpp b/src/gromacs/gmxana/gmx_mdmat.cpp index 9667fb4a21..a6a9058d7a 100644 --- a/src/gromacs/gmxana/gmx_mdmat.cpp +++ b/src/gromacs/gmxana/gmx_mdmat.cpp @@ -115,7 +115,7 @@ static void calc_mat(int nres, real trunc, real** mdmat, int** nmat, - int ePBC, + PbcType pbcType, matrix box) { int i, j, resi, resj; @@ -123,7 +123,7 @@ static void calc_mat(int nres, t_pbc pbc; rvec ddx; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); trunc2 = gmx::square(trunc); for (resi = 0; (resi < nres); resi++) { @@ -207,7 +207,7 @@ int gmx_mdmat(int argc, char* argv[]) FILE * out = nullptr, *fp; t_topology top; - int ePBC; + PbcType pbcType; t_atoms useatoms; int isize; int* index; @@ -243,7 +243,7 @@ int gmx_mdmat(int argc, char* argv[]) fprintf(stderr, "Will calculate number of different contacts\n"); } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x, nullptr, box, FALSE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x, nullptr, box, FALSE); fprintf(stderr, "Select group for analysis\n"); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &isize, &index, &grpname); @@ -313,7 +313,7 @@ int gmx_mdmat(int argc, char* argv[]) rhi.g = 0.0; rhi.b = 0.0; - gpbc = gmx_rmpbc_init(&top.idef, ePBC, trxnat); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, trxnat); if (bFrames) { @@ -323,7 +323,7 @@ int gmx_mdmat(int argc, char* argv[]) { gmx_rmpbc(gpbc, trxnat, box, x); nframes++; - calc_mat(nres, natoms, rndx, x, index, truncate, mdmat, nmat, ePBC, box); + calc_mat(nres, natoms, rndx, x, index, truncate, mdmat, nmat, pbcType, box); for (i = 0; (i < nres); i++) { for (j = 0; (j < natoms); j++) diff --git a/src/gromacs/gmxana/gmx_mindist.cpp b/src/gromacs/gmxana/gmx_mindist.cpp index 6619826f8b..ed51f851d9 100644 --- a/src/gromacs/gmxana/gmx_mindist.cpp +++ b/src/gromacs/gmxana/gmx_mindist.cpp @@ -64,7 +64,8 @@ #include "gromacs/utility/smalloc.h" -static void periodic_dist(int ePBC, matrix box, rvec x[], int n, const int index[], real* rmin, real* rmax, int* min_ind) +static void +periodic_dist(PbcType pbcType, matrix box, rvec x[], int n, const int index[], real* rmin, real* rmax, int* min_ind) { #define NSHIFT_MAX 26 int nsz, nshift, sx, sy, sz, i, j, s; @@ -72,18 +73,18 @@ static void periodic_dist(int ePBC, matrix box, rvec x[], int n, const int index rvec shift[NSHIFT_MAX], d0, d; sqr_box = std::min(norm2(box[XX]), norm2(box[YY])); - if (ePBC == epbcXYZ) + if (pbcType == PbcType::Xyz) { sqr_box = std::min(sqr_box, norm2(box[ZZ])); nsz = 1; } - else if (ePBC == epbcXY) + else if (pbcType == PbcType::XY) { nsz = 0; } else { - gmx_fatal(FARGS, "pbc = %s is not supported by g_mindist", epbc_names[ePBC]); + gmx_fatal(FARGS, "pbc = %s is not supported by g_mindist", c_pbcTypeNames[pbcType].c_str()); } nshift = 0; @@ -139,7 +140,7 @@ static void periodic_dist(int ePBC, matrix box, rvec x[], int n, const int index static void periodic_mindist_plot(const char* trxfn, const char* outfn, const t_topology* top, - int ePBC, + PbcType pbcType, int n, int index[], gmx_bool bSplit, @@ -173,7 +174,7 @@ static void periodic_mindist_plot(const char* trxfn, if (nullptr != top) { - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); } bFirst = TRUE; @@ -184,7 +185,7 @@ static void periodic_mindist_plot(const char* trxfn, gmx_rmpbc(gpbc, natoms, box, x); } - periodic_dist(ePBC, box, x, n, index, &rmin, &rmax, ind_min); + periodic_dist(pbcType, box, x, n, index, &rmin, &rmax, ind_min); if (rmin < rmint) { rmint = rmin; @@ -217,7 +218,7 @@ static void periodic_mindist_plot(const char* trxfn, static void calc_dist(real rcut, gmx_bool bPBC, - int ePBC, + PbcType pbcType, matrix box, rvec x[], int nx1, @@ -254,7 +255,7 @@ static void calc_dist(real rcut, /* Must init pbc every step because of pressure coupling */ if (bPBC) { - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); } if (index2) { @@ -356,7 +357,7 @@ static void dist_plot(const char* fn, int nres, int* residue, gmx_bool bPBC, - int ePBC, + PbcType pbcType, gmx_bool bGroup, gmx_bool bEachResEachTime, gmx_bool bPrintResName, @@ -497,7 +498,7 @@ static void dist_plot(const char* fn, { if (ng == 1) { - calc_dist(rcut, bPBC, ePBC, box, x0, gnx[0], gnx[0], index[0], index[0], bGroup, + calc_dist(rcut, bPBC, pbcType, box, x0, gnx[0], gnx[0], index[0], index[0], bGroup, &dmin, &dmax, &nmin, &nmax, &min1, &min2, &max1, &max2); fprintf(dist, " %12e", bMin ? dmin : dmax); if (num) @@ -511,7 +512,7 @@ static void dist_plot(const char* fn, { for (k = i + 1; (k < ng); k++) { - calc_dist(rcut, bPBC, ePBC, box, x0, gnx[i], gnx[k], index[i], index[k], + calc_dist(rcut, bPBC, pbcType, box, x0, gnx[i], gnx[k], index[i], index[k], bGroup, &dmin, &dmax, &nmin, &nmax, &min1, &min2, &max1, &max2); fprintf(dist, " %12e", bMin ? dmin : dmax); if (num) @@ -527,7 +528,7 @@ static void dist_plot(const char* fn, GMX_RELEASE_ASSERT(ng > 1, "Must have more than one group when not using -matrix"); for (i = 1; (i < ng); i++) { - calc_dist(rcut, bPBC, ePBC, box, x0, gnx[0], gnx[i], index[0], index[i], bGroup, + calc_dist(rcut, bPBC, pbcType, box, x0, gnx[0], gnx[i], index[0], index[i], bGroup, &dmin, &dmax, &nmin, &nmax, &min1, &min2, &max1, &max2); fprintf(dist, " %12e", bMin ? dmin : dmax); if (num) @@ -538,7 +539,7 @@ static void dist_plot(const char* fn, { for (j = 0; j < nres; j++) { - calc_dist(rcut, bPBC, ePBC, box, x0, residue[j + 1] - residue[j], gnx[i], + calc_dist(rcut, bPBC, pbcType, box, x0, residue[j + 1] - residue[j], gnx[i], &(index[0][residue[j]]), index[i], bGroup, &dmin, &dmax, &nmin, &nmax, &min1r, &min2r, &max1r, &max2r); mindres[i - 1][j] = std::min(mindres[i - 1][j], dmin); @@ -737,9 +738,9 @@ int gmx_mindist(int argc, char* argv[]) { "-printresname", FALSE, etBOOL, { &bPrintResName }, "Write residue names" } }; gmx_output_env_t* oenv; - t_topology* top = nullptr; - int ePBC = -1; - rvec* x = nullptr; + t_topology* top = nullptr; + PbcType pbcType = PbcType::Unset; + rvec* x = nullptr; matrix box; gmx_bool bTop = FALSE; @@ -799,7 +800,7 @@ int gmx_mindist(int argc, char* argv[]) if (tpsfnm || resfnm || !ndxfnm) { snew(top, 1); - bTop = read_tps_conf(tpsfnm, top, &ePBC, &x, nullptr, box, FALSE); + bTop = read_tps_conf(tpsfnm, top, &pbcType, &x, nullptr, box, FALSE); if (bPI && !bTop) { printf("\nWARNING: Without a run input file a trajectory with broken molecules will " @@ -843,13 +844,13 @@ int gmx_mindist(int argc, char* argv[]) if (bPI) { - periodic_mindist_plot(trxfnm, distfnm, top, ePBC, gnx[0], index[0], bSplit, oenv); + periodic_mindist_plot(trxfnm, distfnm, top, pbcType, gnx[0], index[0], bSplit, oenv); } else { dist_plot(trxfnm, atmfnm, distfnm, numfnm, resfnm, oxfnm, rcutoff, bMat, top ? &(top->atoms) : nullptr, ng, index, gnx, grpname, bSplit, !bMax, nres, - residues, bPBC, ePBC, bGroup, bEachResEachTime, bPrintResName, oenv); + residues, bPBC, pbcType, bGroup, bEachResEachTime, bPrintResName, oenv); } do_view(oenv, distfnm, "-nxy"); diff --git a/src/gromacs/gmxana/gmx_msd.cpp b/src/gromacs/gmxana/gmx_msd.cpp index fedacb0c31..deb0ac2539 100644 --- a/src/gromacs/gmxana/gmx_msd.cpp +++ b/src/gromacs/gmxana/gmx_msd.cpp @@ -565,7 +565,7 @@ static void printmol(t_corr* curr, const int* molindex, const t_topology* top, rvec* x, - int ePBC, + PbcType pbcType, matrix box, const gmx_output_env_t* oenv) { @@ -647,7 +647,7 @@ static void printmol(t_corr* curr, { pdbinfo[i].bfac *= scale; } - write_sto_conf(fn_pdb, "molecular MSD", &top->atoms, x, nullptr, ePBC, box); + write_sto_conf(fn_pdb, "molecular MSD", &top->atoms, x, nullptr, pbcType, box); } } @@ -658,7 +658,7 @@ static void printmol(t_corr* curr, static int corr_loop(t_corr* curr, const char* fn, const t_topology* top, - int ePBC, + PbcType pbcType, gmx_bool bMol, int gnx[], int* index[], @@ -721,7 +721,7 @@ static int corr_loop(t_corr* curr, if (bMol) { - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); } /* the loop over all frames */ @@ -906,7 +906,7 @@ static void do_corr(const char* trx_file, real t_pdb, int nrgrp, t_topology* top, - int ePBC, + PbcType pbcType, gmx_bool bTen, gmx_bool bMW, gmx_bool bRmCOMM, @@ -955,7 +955,7 @@ static void do_corr(const char* trx_file, msd = std::make_unique(nrgrp, type, axis, dim_factor, mol_file == nullptr ? 0 : gnx[0], bTen, bMW, dt, top, beginfit, endfit); - nat_trx = corr_loop(msd.get(), trx_file, top, ePBC, mol_file ? gnx[0] != 0 : false, gnx.data(), + nat_trx = corr_loop(msd.get(), trx_file, top, pbcType, mol_file ? gnx[0] != 0 : false, gnx.data(), index, (mol_file != nullptr) ? calc1_mol : (bMW ? calc1_mw : calc1_norm), bTen, gnx_com, index_com, dt, t_pdb, pdb_file ? &x : nullptr, box, oenv); @@ -987,7 +987,7 @@ static void do_corr(const char* trx_file, { snew(top->atoms.pdbinfo, top->atoms.nr); } - printmol(msd.get(), mol_file, pdb_file, index[0], top, x, ePBC, box, oenv); + printmol(msd.get(), mol_file, pdb_file, index[0], top, x, pbcType, box, oenv); top->atoms.nr = i; } @@ -1140,7 +1140,7 @@ int gmx_msd(int argc, char* argv[]) #define NFILE asize(fnm) t_topology top; - int ePBC; + PbcType pbcType; matrix box; const char * trx_file, *tps_file, *ndx_file, *msd_file, *mol_file, *pdb_file; rvec* xdum; @@ -1213,14 +1213,14 @@ int gmx_msd(int argc, char* argv[]) gmx_fatal(FARGS, "Can only calculate the full tensor for 3D msd"); } - bTop = read_tps_conf(tps_file, &top, &ePBC, &xdum, nullptr, box, bMW || bRmCOMM); + bTop = read_tps_conf(tps_file, &top, &pbcType, &xdum, nullptr, box, bMW || bRmCOMM); if (mol_file && !bTop) { gmx_fatal(FARGS, "Could not read a topology from %s. Try a tpr file instead.", tps_file); } - do_corr(trx_file, ndx_file, msd_file, mol_file, pdb_file, t_pdb, ngroup, &top, ePBC, bTen, bMW, - bRmCOMM, type, dim_factor, axis, dt, beginfit, endfit, oenv); + do_corr(trx_file, ndx_file, msd_file, mol_file, pdb_file, t_pdb, ngroup, &top, pbcType, bTen, + bMW, bRmCOMM, type, dim_factor, axis, dt, beginfit, endfit, oenv); done_top(&top); view_all(oenv, NFILE, fnm); diff --git a/src/gromacs/gmxana/gmx_nmens.cpp b/src/gromacs/gmxana/gmx_nmens.cpp index d031be6901..78859917b4 100644 --- a/src/gromacs/gmxana/gmx_nmens.cpp +++ b/src/gromacs/gmxana/gmx_nmens.cpp @@ -84,7 +84,7 @@ int gmx_nmens(int argc, char* argv[]) t_trxstatus* out; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; rvec * xtop, *xref, *xav, *xout1, *xout2; gmx_bool bDMR, bDMA, bFit; @@ -123,7 +123,7 @@ int gmx_nmens(int argc, char* argv[]) read_eigenvectors(opt2fn("-v", NFILE, fnm), &natoms, &bFit, &xref, &bDMR, &xav, &bDMA, &nvec, &eignr, &eigvec, &eigval); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, box, bDMA); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, box, bDMA); atoms = &top.atoms; printf("\nSelect an index group of %d elements that corresponds to the eigenvectors\n", natoms); diff --git a/src/gromacs/gmxana/gmx_nmtraj.cpp b/src/gromacs/gmxana/gmx_nmtraj.cpp index 7c4557cec0..c752308e92 100644 --- a/src/gromacs/gmxana/gmx_nmtraj.cpp +++ b/src/gromacs/gmxana/gmx_nmtraj.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2017,2019,2020, 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. @@ -97,7 +97,7 @@ int gmx_nmtraj(int argc, char* argv[]) t_trxstatus* out; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; rvec * xtop, *xref, *xav, *xout; int nvec, *eignr = nullptr; @@ -130,7 +130,7 @@ int gmx_nmtraj(int argc, char* argv[]) read_eigenvectors(opt2fn("-v", NFILE, fnm), &natoms, &bFit, &xref, &bDMR, &xav, &bDMA, &nvec, &eignr, &eigvec, &eigval); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, box, bDMA); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, box, bDMA); /* Find vectors and phases */ diff --git a/src/gromacs/gmxana/gmx_order.cpp b/src/gromacs/gmxana/gmx_order.cpp index 31f4d27d43..aa97af5f97 100644 --- a/src/gromacs/gmxana/gmx_order.cpp +++ b/src/gromacs/gmxana/gmx_order.cpp @@ -76,7 +76,7 @@ /* P.J. van Maaren, November 2005 Added tetrahedral stuff */ /****************************************************************************/ -static void find_nearest_neighbours(int ePBC, +static void find_nearest_neighbours(PbcType pbcType, int natoms, matrix box, rvec x[], @@ -116,7 +116,7 @@ static void find_nearest_neighbours(int ePBC, snew(skmol, maxidx); /* Must init pbc every step because of pressure coupling */ - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); gmx_rmpbc(gpbc, natoms, box, x); @@ -283,7 +283,7 @@ static void calc_tetra_order_parm(const char* fnNDX, { FILE * fpsg = nullptr, *fpsk = nullptr; t_topology top; - int ePBC; + PbcType pbcType; t_trxstatus* status; int natoms; real t; @@ -297,7 +297,7 @@ static void calc_tetra_order_parm(const char* fnNDX, gmx_rmpbc_t gpbc = nullptr; - read_tps_conf(fnTPS, &top, &ePBC, &xtop, nullptr, box, FALSE); + read_tps_conf(fnTPS, &top, &pbcType, &xtop, nullptr, box, FALSE); snew(sg_slice, nslice); snew(sk_slice, nslice); @@ -324,11 +324,11 @@ static void calc_tetra_order_parm(const char* fnNDX, fpsk = xvgropen(skfn, "S\\sk\\N Distance Order Parameter", "Time (ps)", "S\\sk\\N", oenv); /* loop over frames */ - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); nframes = 0; do { - find_nearest_neighbours(ePBC, natoms, box, x, isize[0], index[0], &sg, &sk, nslice, + find_nearest_neighbours(pbcType, natoms, box, x, isize[0], index[0], &sg, &sk, nslice, slice_dim, sg_slice, sk_slice, gpbc); for (i = 0; (i < nslice); i++) { @@ -398,7 +398,7 @@ static void calc_order(const char* fn, gmx_bool bSliced, gmx_bool bUnsat, const t_topology* top, - int ePBC, + PbcType pbcType, int ngrps, int axis, gmx_bool permolecule, @@ -515,7 +515,7 @@ static void calc_order(const char* fn, teller = 0; - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); /*********** Start processing trajectory ***********/ do { @@ -525,7 +525,7 @@ static void calc_order(const char* fn, } teller++; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); gmx_rmpbc_copy(gpbc, natoms, box, x0, x1); /* Now loop over all groups. There are ngrps groups, the order parameter can @@ -938,7 +938,7 @@ static void write_bfactors(t_filenm* fnm, } write_sto_conf(opt2fn("-ob", nfile, fnm), "Order parameters", &useatoms, frout.x, nullptr, - frout.ePBC, frout.box); + frout.pbcType, frout.box); sfree(frout.x); done_atom(&useatoms); @@ -1008,11 +1008,11 @@ int gmx_order(int argc, char* argv[]) char** grpname; /* groupnames */ int ngrps, /* nr. of groups */ i, axis = 0; /* normal axis */ - t_topology* top; /* topology */ - int ePBC; - int * index, /* indices for a */ - *a; /* atom numbers in each group */ - t_blocka* block; /* data from index file */ + t_topology* top; /* topology */ + PbcType pbcType; /* type of periodic boundary conditions */ + int * index, /* indices for a */ + *a; /* atom numbers in each group */ + t_blocka* block; /* data from index file */ t_filenm fnm[] = { /* files for g_order */ { efTRX, "-f", nullptr, ffREAD }, /* trajectory file */ @@ -1111,7 +1111,7 @@ int gmx_order(int argc, char* argv[]) fprintf(stderr, "Taking carbons as unsaturated!\n"); } - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); /* read topology file */ + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); /* read topology file */ block = init_index(ftp2fn(efNDX, NFILE, fnm), &grpname); index = block->index; /* get indices from t_block block */ @@ -1137,7 +1137,7 @@ int gmx_order(int argc, char* argv[]) print_types(index, a, ngrps, grpname, top); calc_order(ftp2fn(efTRX, NFILE, fnm), index, a, &order, &slOrder, &slWidth, nslices, - bSliced, bUnsat, top, ePBC, ngrps, axis, permolecule, radial, distcalc, + bSliced, bUnsat, top, pbcType, ngrps, axis, permolecule, radial, distcalc, opt2fn_null("-nr", NFILE, fnm), &distvals, oenv); if (radial) diff --git a/src/gromacs/gmxana/gmx_polystat.cpp b/src/gromacs/gmxana/gmx_polystat.cpp index 9cbaf1ec96..ee1cfe1af4 100644 --- a/src/gromacs/gmxana/gmx_polystat.cpp +++ b/src/gromacs/gmxana/gmx_polystat.cpp @@ -147,7 +147,7 @@ int gmx_polystat(int argc, char* argv[]) t_topology* top; gmx_output_env_t* oenv; - int ePBC; + PbcType pbcType; int isize, *index, nmol, *molind, mol, nat_min = 0, nat_max = 0; char* grpname; t_trxstatus* status; @@ -177,7 +177,7 @@ int gmx_polystat(int argc, char* argv[]) } snew(top, 1); - ePBC = read_tpx_top(ftp2fn(efTPR, NFILE, fnm), nullptr, box, &natoms, nullptr, nullptr, top); + pbcType = read_tpx_top(ftp2fn(efTPR, NFILE, fnm), nullptr, box, &natoms, nullptr, nullptr, top); fprintf(stderr, "Select a group of polymer mainchain atoms:\n"); get_index(&top->atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &isize, &index, &grpname); @@ -274,7 +274,7 @@ int gmx_polystat(int argc, char* argv[]) sum_gyro_tot = 0; sum_pers_tot = 0; - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); do { diff --git a/src/gromacs/gmxana/gmx_potential.cpp b/src/gromacs/gmxana/gmx_potential.cpp index 943ab872ee..fb417b0f8f 100644 --- a/src/gromacs/gmxana/gmx_potential.cpp +++ b/src/gromacs/gmxana/gmx_potential.cpp @@ -109,7 +109,7 @@ static void calc_potential(const char* fn, double*** slField, int* nslices, const t_topology* top, - int ePBC, + PbcType pbcType, int axis, int nr_grps, double* slWidth, @@ -172,7 +172,7 @@ static void calc_potential(const char* fn, } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); /*********** Start processing trajectory ***********/ do @@ -485,7 +485,7 @@ int gmx_potential(int argc, char* argv[]) char** grpname; /* groupnames */ int* ngx; /* sizes of groups */ t_topology* top; /* topology */ - int ePBC; + PbcType pbcType; int** index; /* indices for all groups */ t_filenm fnm[] = { /* files for g_order */ @@ -508,7 +508,7 @@ int gmx_potential(int argc, char* argv[]) /* Calculate axis */ axis = toupper(axtitle[0]) - 'X'; - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); /* read topology file */ + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); /* read topology file */ snew(grpname, ngrps); snew(index, ngrps); @@ -518,7 +518,7 @@ int gmx_potential(int argc, char* argv[]) calc_potential(ftp2fn(efTRX, NFILE, fnm), index, ngx, &potential, &charge, &field, &nslices, - top, ePBC, axis, ngrps, &slWidth, fudge_z, bSpherical, bCorrect, oenv); + top, pbcType, axis, ngrps, &slWidth, fudge_z, bSpherical, bCorrect, oenv); plot_potential(potential, charge, field, opt2fn("-o", NFILE, fnm), opt2fn("-oc", NFILE, fnm), opt2fn("-of", NFILE, fnm), nslices, ngrps, grpname, slWidth, oenv); diff --git a/src/gromacs/gmxana/gmx_principal.cpp b/src/gromacs/gmxana/gmx_principal.cpp index 8201b3ee70..40092a218f 100644 --- a/src/gromacs/gmxana/gmx_principal.cpp +++ b/src/gromacs/gmxana/gmx_principal.cpp @@ -80,7 +80,7 @@ int gmx_principal(int argc, char* argv[]) t_pargs pa[] = { { "-foo", FALSE, etBOOL, { &foo }, "Dummy option to avoid empty array" } }; t_trxstatus* status; t_topology top; - int ePBC; + PbcType pbcType; real t; rvec* x; @@ -143,13 +143,13 @@ int gmx_principal(int argc, char* argv[]) } sfree(legend); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, nullptr, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, nullptr, nullptr, box, TRUE); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &gnx, &index, &grpname); natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box); - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); do { diff --git a/src/gromacs/gmxana/gmx_rms.cpp b/src/gromacs/gmxana/gmx_rms.cpp index 6efc874ce0..43c3419d25 100644 --- a/src/gromacs/gmxana/gmx_rms.cpp +++ b/src/gromacs/gmxana/gmx_rms.cpp @@ -208,7 +208,7 @@ int gmx_rms(int argc, char* argv[]) gmx_bool bNorm, bAv, bFreq2, bFile2, bMat, bBond, bDelta, bMirror, bMass; gmx_bool bFit, bReset; t_topology top; - int ePBC; + PbcType pbcType; t_iatom* iatom = nullptr; matrix box = { { 0 } }; @@ -327,7 +327,7 @@ int gmx_rms(int argc, char* argv[]) } } - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xp, nullptr, box, TRUE); + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xp, nullptr, box, TRUE); snew(w_rls, top.atoms.nr); snew(w_rms, top.atoms.nr); @@ -436,7 +436,7 @@ int gmx_rms(int argc, char* argv[]) /* Prepare reference frame */ if (bPBC) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, top.atoms.nr); gmx_rmpbc(gpbc, top.atoms.nr, box, xp); } if (bReset) diff --git a/src/gromacs/gmxana/gmx_rmsdist.cpp b/src/gromacs/gmxana/gmx_rmsdist.cpp index 65b1e2bdba..af62354919 100644 --- a/src/gromacs/gmxana/gmx_rmsdist.cpp +++ b/src/gromacs/gmxana/gmx_rmsdist.cpp @@ -63,14 +63,14 @@ #include "gromacs/utility/strdb.h" -static void calc_dist(int nind, const int index[], const rvec x[], int ePBC, matrix box, real** d) +static void calc_dist(int nind, const int index[], const rvec x[], PbcType pbcType, matrix box, real** d) { int i, j; rvec dx; real temp2; t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (i = 0; (i < nind - 1); i++) { const real* xi = x[index[i]]; @@ -86,7 +86,7 @@ static void calc_dist(int nind, const int index[], const rvec x[], int ePBC, mat static void calc_dist_tot(int nind, const int index[], rvec x[], - int ePBC, + PbcType pbcType, matrix box, real** d, real** dtot, @@ -101,7 +101,7 @@ static void calc_dist_tot(int nind, rvec dx; t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (i = 0; (i < nind - 1); i++) { xi = x[index[i]]; @@ -669,7 +669,7 @@ int gmx_rmsdist(int argc, char* argv[]) real t; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; matrix box; rvec* x; @@ -742,11 +742,11 @@ int gmx_rmsdist(int argc, char* argv[]) } /* get topology and index */ - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x, nullptr, box, FALSE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x, nullptr, box, FALSE); if (!bPBC) { - ePBC = epbcNONE; + pbcType = PbcType::No; } atoms = &(top.atoms); @@ -784,7 +784,7 @@ int gmx_rmsdist(int argc, char* argv[]) } /*set box type*/ - calc_dist(isize, index, x, ePBC, box, d_r); + calc_dist(isize, index, x, pbcType, box, d_r); sfree(x); /*open output files*/ @@ -800,7 +800,7 @@ int gmx_rmsdist(int argc, char* argv[]) do { - calc_dist_tot(isize, index, x, ePBC, box, d, dtot, dtot2, bNMR, dtot1_3, dtot1_6); + calc_dist_tot(isize, index, x, pbcType, box, d, dtot, dtot2, bNMR, dtot1_3, dtot1_6); rmsnow = rms_diff(isize, d, d_r); fprintf(fp, "%g %g\n", t, rmsnow); diff --git a/src/gromacs/gmxana/gmx_rmsf.cpp b/src/gromacs/gmxana/gmx_rmsf.cpp index 1884a9f6a7..c0c439afd6 100644 --- a/src/gromacs/gmxana/gmx_rmsf.cpp +++ b/src/gromacs/gmxana/gmx_rmsf.cpp @@ -240,7 +240,7 @@ int gmx_rmsf(int argc, char* argv[]) real t, *w_rls; t_topology top; - int ePBC; + PbcType pbcType; t_atoms * pdbatoms, *refatoms; matrix box, pdbbox; @@ -288,7 +288,7 @@ int gmx_rmsf(int argc, char* argv[]) devfn = opt2fn_null("-od", NFILE, fnm); dirfn = opt2fn_null("-dir", NFILE, fnm); - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xref, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xref, nullptr, box, TRUE); const char* title = *top.name; snew(w_rls, top.atoms.nr); @@ -349,7 +349,7 @@ int gmx_rmsf(int argc, char* argv[]) if (bFit) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natom); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natom); } /* Now read the trj again to compute fluctuations */ @@ -555,7 +555,7 @@ int gmx_rmsf(int argc, char* argv[]) { rvec_inc(pdbx[index[i]], xcm); } - write_sto_conf_indexed(opt2fn("-oq", NFILE, fnm), title, pdbatoms, pdbx, nullptr, ePBC, + write_sto_conf_indexed(opt2fn("-oq", NFILE, fnm), title, pdbatoms, pdbx, nullptr, pbcType, pdbbox, isize, index); } if (opt2bSet("-ox", NFILE, fnm)) @@ -570,8 +570,8 @@ int gmx_rmsf(int argc, char* argv[]) } } /* Write a .pdb file with B-factors and optionally anisou records */ - write_sto_conf_indexed(opt2fn("-ox", NFILE, fnm), title, pdbatoms, bFactorX, nullptr, ePBC, - pdbbox, isize, index); + write_sto_conf_indexed(opt2fn("-ox", NFILE, fnm), title, pdbatoms, bFactorX, nullptr, + pbcType, pdbbox, isize, index); sfree(bFactorX); } if (bAniso) diff --git a/src/gromacs/gmxana/gmx_rotacf.cpp b/src/gromacs/gmxana/gmx_rotacf.cpp index 5c1af31668..048c663158 100644 --- a/src/gromacs/gmxana/gmx_rotacf.cpp +++ b/src/gromacs/gmxana/gmx_rotacf.cpp @@ -99,7 +99,7 @@ int gmx_rotacf(int argc, char* argv[]) real t, t0, t1, dt; gmx_rmpbc_t gpbc = nullptr; t_topology* top; - int ePBC; + PbcType pbcType; t_filenm fnm[] = { { efTRX, "-f", nullptr, ffREAD }, { efTPR, nullptr, nullptr, ffREAD }, { efNDX, nullptr, nullptr, ffREAD }, @@ -144,7 +144,7 @@ int gmx_rotacf(int argc, char* argv[]) "these can not be atom doublets\n"); } - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); snew(c1, nvec); for (i = 0; (i < nvec); i++) @@ -156,7 +156,7 @@ int gmx_rotacf(int argc, char* argv[]) natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box); snew(x_s, natoms); - gpbc = gmx_rmpbc_init(&(top->idef), ePBC, natoms); + gpbc = gmx_rmpbc_init(&(top->idef), pbcType, natoms); /* Start the loop over frames */ t0 = t; diff --git a/src/gromacs/gmxana/gmx_rotmat.cpp b/src/gromacs/gmxana/gmx_rotmat.cpp index 9aa0fd82ca..6bc93086af 100644 --- a/src/gromacs/gmxana/gmx_rotmat.cpp +++ b/src/gromacs/gmxana/gmx_rotmat.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2009-2017, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -64,7 +64,7 @@ static void get_refx(gmx_output_env_t* oenv, int* index, gmx_bool bMW, const t_topology* top, - int ePBC, + PbcType pbcType, rvec* x_ref) { int natoms, nfr_all, nfr, i, j, a, r, c, min_fr; @@ -97,7 +97,7 @@ static void get_refx(gmx_output_env_t* oenv, w_rls[a] = (bMW ? top->atoms.atom[index[a]].m : 1.0); tot_mass += w_rls[a]; } - gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms); do { @@ -227,7 +227,7 @@ int gmx_rotmat(int argc, char* argv[]) FILE* out; t_trxstatus* status; t_topology top; - int ePBC; + PbcType pbcType; rvec * x_ref, *x; matrix box, R; real t; @@ -252,9 +252,9 @@ int gmx_rotmat(int argc, char* argv[]) return 0; } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x_ref, nullptr, box, bMW); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x_ref, nullptr, box, bMW); - gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, top.atoms.nr); gmx_rmpbc(gpbc, top.atoms.nr, box, x_ref); @@ -264,7 +264,7 @@ int gmx_rotmat(int argc, char* argv[]) if (reffit[0][0] != 'n') { get_refx(oenv, ftp2fn(efTRX, NFILE, fnm), reffit[0][2] == 'z' ? 3 : 2, skip, gnx, index, - bMW, &top, ePBC, x_ref); + bMW, &top, pbcType, x_ref); } natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box); diff --git a/src/gromacs/gmxana/gmx_saltbr.cpp b/src/gromacs/gmxana/gmx_saltbr.cpp index e7980d845b..e82a4a365f 100644 --- a/src/gromacs/gmxana/gmx_saltbr.cpp +++ b/src/gromacs/gmxana/gmx_saltbr.cpp @@ -136,7 +136,7 @@ int gmx_saltbr(int argc, char* argv[]) int nset[3] = { 0, 0, 0 }; t_topology* top; - int ePBC; + PbcType pbcType; char* buf; t_trxstatus* status; int i, j, k, m, nnn, teller, ncg; @@ -156,7 +156,7 @@ int gmx_saltbr(int argc, char* argv[]) return 0; } - top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); + top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType); cg = mk_charge(&top->atoms, &ncg); snew(cgdist, ncg); snew(nWithin, ncg); @@ -175,7 +175,7 @@ int gmx_saltbr(int argc, char* argv[]) srenew(time, teller + 1); time[teller] = t; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (i = 0; (i < ncg); i++) { diff --git a/src/gromacs/gmxana/gmx_sans.cpp b/src/gromacs/gmxana/gmx_sans.cpp index c9edbbc6e7..ab77d08a1c 100644 --- a/src/gromacs/gmxana/gmx_sans.cpp +++ b/src/gromacs/gmxana/gmx_sans.cpp @@ -48,6 +48,7 @@ #include "gromacs/gmxana/gstat.h" #include "gromacs/gmxana/nsfactor.h" #include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/pbcutil/rmpbc.h" #include "gromacs/topology/index.h" #include "gromacs/topology/topology.h" @@ -126,8 +127,8 @@ int gmx_sans(int argc, char* argv[]) t_topology* top = nullptr; gmx_rmpbc_t gpbc = nullptr; gmx_bool bFFT = FALSE, bDEBYE = FALSE; - gmx_bool bMC = FALSE; - int ePBC = -1; + gmx_bool bMC = FALSE; + PbcType pbcType = PbcType::Unset; matrix box; rvec* x; int natoms; @@ -219,7 +220,7 @@ int gmx_sans(int argc, char* argv[]) snew(grpname, 1); snew(index, 1); - read_tps_conf(fnTPX, top, &ePBC, &x, nullptr, box, TRUE); + read_tps_conf(fnTPX, top, &pbcType, &x, nullptr, box, TRUE); printf("\nPlease select group for SANS spectra calculation:\n"); get_index(&(top->atoms), ftp2fn_null(efNDX, NFILE, fnm), 1, &isize, &index, grpname); @@ -229,7 +230,7 @@ int gmx_sans(int argc, char* argv[]) /* Prepare reference frame */ if (bPBC) { - gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr); gmx_rmpbc(gpbc, top->atoms.nr, box, x); } diff --git a/src/gromacs/gmxana/gmx_sorient.cpp b/src/gromacs/gmxana/gmx_sorient.cpp index 3d8d922cb9..4561a28a80 100644 --- a/src/gromacs/gmxana/gmx_sorient.cpp +++ b/src/gromacs/gmxana/gmx_sorient.cpp @@ -115,7 +115,7 @@ static void calc_com_pbc(int nrefat, t_topology* top, rvec x[], t_pbc* pbc, cons int gmx_sorient(int argc, char* argv[]) { t_topology top; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; t_trxstatus* status; int natoms; real t; @@ -204,7 +204,7 @@ int gmx_sorient(int argc, char* argv[]) bTPS = (opt2bSet("-s", NFILE, fnm) || !opt2bSet("-n", NFILE, fnm) || bCom); if (bTPS) { - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, box, bCom); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, box, bCom); } /* get index groups */ @@ -242,7 +242,7 @@ int gmx_sorient(int argc, char* argv[]) rmin2 = gmx::square(rmin); rmax2 = gmx::square(rmax); - rcut = 0.99 * std::sqrt(max_cutoff2(guess_ePBC(box), box)); + rcut = 0.99 * std::sqrt(max_cutoff2(guessPbcType(box), box)); if (rcut == 0) { rcut = 10 * rmax; @@ -274,7 +274,7 @@ int gmx_sorient(int argc, char* argv[]) if (bTPS) { /* make molecules whole again */ - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); } /* start analysis of trajectory */ do @@ -285,7 +285,7 @@ int gmx_sorient(int argc, char* argv[]) gmx_rmpbc(gpbc, natoms, box, x); } - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); n = 0; inp = 0; for (p = 0; (p < nrefgrp); p++) diff --git a/src/gromacs/gmxana/gmx_spatial.cpp b/src/gromacs/gmxana/gmx_spatial.cpp index 694df6790e..0ec43ffafd 100644 --- a/src/gromacs/gmxana/gmx_spatial.cpp +++ b/src/gromacs/gmxana/gmx_spatial.cpp @@ -158,7 +158,7 @@ int gmx_spatial(int argc, char* argv[]) double MINBIN[3]; double MAXBIN[3]; t_topology top; - int ePBC; + PbcType pbcType; t_trxframe fr; rvec* xtop; matrix box, box_pbc; @@ -196,7 +196,7 @@ int gmx_spatial(int argc, char* argv[]) return 0; } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, box, TRUE); sfree(xtop); atoms = &(top.atoms); @@ -262,7 +262,7 @@ int gmx_spatial(int argc, char* argv[]) if (bPBC) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); } /* This is the main loop over frames */ do @@ -273,7 +273,7 @@ int gmx_spatial(int argc, char* argv[]) if (bPBC) { gmx_rmpbc_trxfr(gpbc, &fr); - set_pbc(&pbc, ePBC, box_pbc); + set_pbc(&pbc, pbcType, box_pbc); } for (i = 0; i < nidx; i++) diff --git a/src/gromacs/gmxana/gmx_spol.cpp b/src/gromacs/gmxana/gmx_spol.cpp index c52f4ab7a5..d67045be90 100644 --- a/src/gromacs/gmxana/gmx_spol.cpp +++ b/src/gromacs/gmxana/gmx_spol.cpp @@ -59,7 +59,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/smalloc.h" -static void calc_com_pbc(int nrefat, const t_topology* top, rvec x[], t_pbc* pbc, const int index[], rvec xref, int ePBC) +static void calc_com_pbc(int nrefat, const t_topology* top, rvec x[], t_pbc* pbc, const int index[], rvec xref, PbcType pbcType) { const real tol = 1e-4; gmx_bool bChanged; @@ -82,7 +82,7 @@ static void calc_com_pbc(int nrefat, const t_topology* top, rvec x[], t_pbc* pbc } svmul(1 / mtot, xref, xref); /* Now check if any atom is more than half the box from the COM */ - if (ePBC != epbcNONE) + if (pbcType != PbcType::No) { iter = 0; do @@ -217,7 +217,7 @@ int gmx_spol(int argc, char* argv[]) } snew(top, 1); - // TODO: Only ePBC is used, not the full inputrec. + // TODO: Only pbcType is used, not the full inputrec. t_inputrec irInstance; t_inputrec* ir = &irInstance; read_tpx_top(ftp2fn(efTPR, NFILE, fnm), ir, box, &natoms, nullptr, nullptr, top); @@ -246,7 +246,7 @@ int gmx_spol(int argc, char* argv[]) /* initialize reading trajectory: */ natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box); - rcut = 0.99 * std::sqrt(max_cutoff2(ir->ePBC, box)); + rcut = 0.99 * std::sqrt(max_cutoff2(ir->pbcType, box)); if (rcut == 0) { rcut = 10 * rmax; @@ -269,7 +269,7 @@ int gmx_spol(int argc, char* argv[]) molindex = top->mols.index; atom = top->atoms.atom; - gpbc = gmx_rmpbc_init(&top->idef, ir->ePBC, natoms); + gpbc = gmx_rmpbc_init(&top->idef, ir->pbcType, natoms); /* start analysis of trajectory */ do @@ -277,10 +277,10 @@ int gmx_spol(int argc, char* argv[]) /* make molecules whole again */ gmx_rmpbc(gpbc, natoms, box, x); - set_pbc(&pbc, ir->ePBC, box); + set_pbc(&pbc, ir->pbcType, box); if (bCom) { - calc_com_pbc(nrefat, top, x, &pbc, index[0], xref, ir->ePBC); + calc_com_pbc(nrefat, top, x, &pbc, index[0], xref, ir->pbcType); } for (m = 0; m < isize[1]; m++) diff --git a/src/gromacs/gmxana/gmx_tcaf.cpp b/src/gromacs/gmxana/gmx_tcaf.cpp index 734ad4c0ea..03e9f2c6ad 100644 --- a/src/gromacs/gmxana/gmx_tcaf.cpp +++ b/src/gromacs/gmxana/gmx_tcaf.cpp @@ -320,7 +320,7 @@ int gmx_tcaf(int argc, char* argv[]) }; t_topology top; - int ePBC; + PbcType pbcType; t_trxframe fr; matrix box; gmx_bool bTop; @@ -357,7 +357,7 @@ int gmx_tcaf(int argc, char* argv[]) return 0; } - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, nullptr, nullptr, box, TRUE); + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, nullptr, nullptr, box, TRUE); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &gnx, &index, &grpname); if (bMol) diff --git a/src/gromacs/gmxana/gmx_traj.cpp b/src/gromacs/gmxana/gmx_traj.cpp index 7a6f5d5a9c..93c811bb5a 100644 --- a/src/gromacs/gmxana/gmx_traj.cpp +++ b/src/gromacs/gmxana/gmx_traj.cpp @@ -427,7 +427,7 @@ static void write_pdb_bfac(const char* fname, const char* xname, const char* title, t_atoms* atoms, - int ePBC, + PbcType pbcType, matrix box, int isize, int* index, @@ -548,7 +548,7 @@ static void write_pdb_bfac(const char* fname, atoms->pdbinfo[index[i]].bfac = sum[index[i]][onedim] * scale; } } - write_sto_conf_indexed(fname, title, atoms, x, nullptr, ePBC, box, isize, index); + write_sto_conf_indexed(fname, title, atoms, x, nullptr, pbcType, box, isize, index); } } @@ -671,7 +671,7 @@ int gmx_traj(int argc, char* argv[]) FILE * outx = nullptr, *outv = nullptr, *outf = nullptr, *outb = nullptr, *outt = nullptr; FILE * outekt = nullptr, *outekr = nullptr; t_topology top; - int ePBC; + PbcType pbcType; real * mass, time; const char* indexfn; t_trxframe fr; @@ -751,7 +751,7 @@ int gmx_traj(int argc, char* argv[]) } std::string sffmt6 = gmx::formatString("%s%s%s%s%s%s", sffmt, sffmt, sffmt, sffmt, sffmt, sffmt); - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, topbox, + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, topbox, bCom && (bOX || bOXT || bOV || bOT || bEKT || bEKR)); sfree(xtop); if ((bMol || bCV || bCF) && !bTop) @@ -929,7 +929,7 @@ int gmx_traj(int argc, char* argv[]) if (bCom && bPBC) { - gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, fr.natoms); } do @@ -1098,7 +1098,7 @@ int gmx_traj(int argc, char* argv[]) { if (nr_xfr > 1) { - if (ePBC != epbcNONE && !bNoJump) + if (pbcType != PbcType::No && !bNoJump) { fprintf(stderr, "\nWARNING: More than one frame was used for option -cv or -cf\n" @@ -1118,14 +1118,14 @@ int gmx_traj(int argc, char* argv[]) if (bCV) { write_pdb_bfac(opt2fn("-cv", NFILE, fnm), opt2fn("-av", NFILE, fnm), "average velocity", - &(top.atoms), ePBC, topbox, isize[0], index[0], nr_xfr, sumx, nr_vfr, sumv, - bDim, scale, oenv); + &(top.atoms), pbcType, topbox, isize[0], index[0], nr_xfr, sumx, nr_vfr, + sumv, bDim, scale, oenv); } if (bCF) { write_pdb_bfac(opt2fn("-cf", NFILE, fnm), opt2fn("-af", NFILE, fnm), "average force", - &(top.atoms), ePBC, topbox, isize[0], index[0], nr_xfr, sumx, nr_ffr, sumf, - bDim, scale, oenv); + &(top.atoms), pbcType, topbox, isize[0], index[0], nr_xfr, sumx, nr_ffr, + sumf, bDim, scale, oenv); } /* view it */ diff --git a/src/gromacs/gmxana/gmx_trjorder.cpp b/src/gromacs/gmxana/gmx_trjorder.cpp index c0f8fe28cd..96966c9a00 100644 --- a/src/gromacs/gmxana/gmx_trjorder.cpp +++ b/src/gromacs/gmxana/gmx_trjorder.cpp @@ -133,7 +133,7 @@ int gmx_trjorder(int argc, char* argv[]) t_trxstatus* status; gmx_bool bNShell, bPDBout; t_topology top; - int ePBC; + PbcType pbcType; rvec * x, *xsol, xcom, dx; matrix box; t_pbc pbc; @@ -157,7 +157,7 @@ int gmx_trjorder(int argc, char* argv[]) return 0; } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &x, nullptr, box, TRUE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &x, nullptr, box, TRUE); sfree(x); /* get index groups */ @@ -240,11 +240,11 @@ int gmx_trjorder(int argc, char* argv[]) } out = open_trx(opt2fn("-o", NFILE, fnm), "w"); } - gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms); + gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms); do { gmx_rmpbc(gpbc, natoms, box, x); - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); if (ref_a == -1) { diff --git a/src/gromacs/gmxana/gmx_vanhove.cpp b/src/gromacs/gmxana/gmx_vanhove.cpp index eed02c0dcb..44edc6539d 100644 --- a/src/gromacs/gmxana/gmx_vanhove.cpp +++ b/src/gromacs/gmxana/gmx_vanhove.cpp @@ -134,7 +134,7 @@ int gmx_vanhove(int argc, char* argv[]) gmx_output_env_t* oenv; const char * matfile, *otfile, *orfile; t_topology top; - int ePBC; + PbcType pbcType; matrix boxtop, box, *sbox, avbox, corr; rvec * xtop, *x, **sx; int isize, nalloc, nallocn; @@ -180,7 +180,7 @@ int gmx_vanhove(int argc, char* argv[]) exit(0); } - read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtop, nullptr, boxtop, FALSE); + read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, &xtop, nullptr, boxtop, FALSE); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &isize, &index, &grpname); nalloc = 0; @@ -295,7 +295,7 @@ int gmx_vanhove(int argc, char* argv[]) fprintf(stderr, "\rProcessing frame %d", f); fflush(stderr); } - if (ePBC != epbcNONE) + if (pbcType != PbcType::No) { /* Scale all the configuration to the average box */ gmx::invertBoxMatrix(sbox[f], corr); diff --git a/src/gromacs/gmxana/gmx_velacc.cpp b/src/gromacs/gmxana/gmx_velacc.cpp index dd94814e2e..48a0ee567f 100644 --- a/src/gromacs/gmxana/gmx_velacc.cpp +++ b/src/gromacs/gmxana/gmx_velacc.cpp @@ -54,6 +54,7 @@ #include "gromacs/math/units.h" #include "gromacs/math/utilities.h" #include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/topology/index.h" #include "gromacs/topology/topology.h" #include "gromacs/trajectory/trajectoryframe.h" @@ -196,7 +197,7 @@ int gmx_velacc(int argc, char* argv[]) }; t_topology top; - int ePBC = -1; + PbcType pbcType = PbcType::Unset; t_trxframe fr; matrix box; gmx_bool bTPS = FALSE, bTop = FALSE; @@ -242,7 +243,7 @@ int gmx_velacc(int argc, char* argv[]) if (bTPS) { - bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, nullptr, nullptr, box, TRUE); + bTop = read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &pbcType, nullptr, nullptr, box, TRUE); get_index(&top.atoms, ftp2fn_null(efNDX, NFILE, fnm), 1, &gnx, &index, &grpname); } else diff --git a/src/gromacs/gmxana/nrama.cpp b/src/gromacs/gmxana/nrama.cpp index 412fdce66e..1c92c76e1f 100644 --- a/src/gromacs/gmxana/nrama.cpp +++ b/src/gromacs/gmxana/nrama.cpp @@ -78,7 +78,7 @@ static void calc_dihs(t_xrama* xr) t_dih* dd; gmx_rmpbc_t gpbc = nullptr; - gpbc = gmx_rmpbc_init(xr->idef, xr->ePBC, xr->natoms); + gpbc = gmx_rmpbc_init(xr->idef, xr->pbcType, xr->natoms); gmx_rmpbc(gpbc, xr->natoms, xr->box, xr->x); gmx_rmpbc_done(gpbc); @@ -241,7 +241,7 @@ t_topology* init_rama(gmx_output_env_t* oenv, const char* infile, const char* to t_topology* top; real t; - top = read_top(topfile, &xr->ePBC); + top = read_top(topfile, &xr->pbcType); /*get_dih2(xr,top->idef.functype,&(top->idef.bondeds),&(top->atoms));*/ get_dih(xr, &(top->atoms)); diff --git a/src/gromacs/gmxana/nrama.h b/src/gromacs/gmxana/nrama.h index 6aee0a3e94..71c00fded0 100644 --- a/src/gromacs/gmxana/nrama.h +++ b/src/gromacs/gmxana/nrama.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2018,2019,2020, 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. @@ -72,7 +72,7 @@ typedef struct rvec* x; matrix box; t_idef* idef; - int ePBC; + PbcType pbcType; gmx_output_env_t* oenv; } t_xrama; diff --git a/src/gromacs/gmxana/sfactor.cpp b/src/gromacs/gmxana/sfactor.cpp index c9249c2e9f..87b08d6e84 100644 --- a/src/gromacs/gmxana/sfactor.cpp +++ b/src/gromacs/gmxana/sfactor.cpp @@ -460,7 +460,7 @@ extern int do_scattering_intensity(const char* fnTPS, char** grpname; int** index; t_topology top; - int ePBC; + PbcType pbcType; t_trxframe fr; reduced_atom_t** red; structure_factor* sf; @@ -484,7 +484,7 @@ extern int do_scattering_intensity(const char* fnTPS, sf->energy = energy; /* Read the topology informations */ - read_tps_conf(fnTPS, &top, &ePBC, &xtop, nullptr, box, TRUE); + read_tps_conf(fnTPS, &top, &pbcType, &xtop, nullptr, box, TRUE); sfree(xtop); /* groups stuff... */ diff --git a/src/gromacs/gmxpreprocess/editconf.cpp b/src/gromacs/gmxpreprocess/editconf.cpp index 72d398d52b..45f02a99cc 100644 --- a/src/gromacs/gmxpreprocess/editconf.cpp +++ b/src/gromacs/gmxpreprocess/editconf.cpp @@ -329,7 +329,7 @@ static void pdb_legend(FILE* out, int natoms, int nres, t_atoms* atoms, rvec x[] } } -static void visualize_images(const char* fn, int ePBC, matrix box) +static void visualize_images(const char* fn, PbcType pbcType, matrix box) { t_atoms atoms; rvec* img; @@ -353,7 +353,7 @@ static void visualize_images(const char* fn, int ePBC, matrix box) } calc_triclinic_images(box, img + 1); - write_sto_conf(fn, "Images", &atoms, img, nullptr, ePBC, box); + write_sto_conf(fn, "Images", &atoms, img, nullptr, pbcType, box); done_atom(&atoms); sfree(img); @@ -682,7 +682,7 @@ int gmx_editconf(int argc, char* argv[]) int isize, ssize, numAlignmentAtoms; int * index, *sindex, *aindex; rvec * x, *v, gc, rmin, rmax, size; - int ePBC; + PbcType pbcType; matrix box, rotmatrix, trans; rvec princd, tmpvec; gmx_bool bIndex, bSetSize, bSetAng, bDist, bSetCenter, bAlign; @@ -769,7 +769,7 @@ int gmx_editconf(int argc, char* argv[]) char* name; t_atoms atoms; open_symtab(&symtab); - readConfAndAtoms(infile, &symtab, &name, &atoms, &ePBC, &x, &v, box); + readConfAndAtoms(infile, &symtab, &name, &atoms, &pbcType, &x, &v, box); natom = atoms.nr; if (atoms.pdbinfo == nullptr) { @@ -789,7 +789,7 @@ int gmx_editconf(int argc, char* argv[]) get_pdb_atomnumber(&atoms, &aps); } - if (ePBC != epbcNONE) + if (pbcType != PbcType::No) { real vol = det(box); printf("Volume: %g nm^3, corresponds to roughly %d electrons\n", vol, @@ -881,7 +881,7 @@ int gmx_editconf(int argc, char* argv[]) } else if (visbox[0] == -1) { - visualize_images("images.pdb", ePBC, box); + visualize_images("images.pdb", pbcType, box); } /* remove pbc */ @@ -1072,7 +1072,7 @@ int gmx_editconf(int argc, char* argv[]) if ((btype[0] != nullptr) && (bSetSize || bDist || (btype[0][0] == 't' && bSetAng))) { - ePBC = epbcXYZ; + pbcType = PbcType::Xyz; if (!(bSetSize || bDist)) { for (i = 0; i < DIM; i++) @@ -1170,12 +1170,12 @@ int gmx_editconf(int argc, char* argv[]) printf("new box volume :%7.2f (nm^3)\n", det(box)); } - if (check_box(epbcXYZ, box)) + if (check_box(PbcType::Xyz, box)) { printf("\nWARNING: %s\n" "See the GROMACS manual for a description of the requirements that\n" "must be satisfied by descriptions of simulation cells.\n", - check_box(epbcXYZ, box)); + check_box(PbcType::Xyz, box)); } if (bDist && btype[0][0] == 't') @@ -1231,12 +1231,13 @@ int gmx_editconf(int argc, char* argv[]) if (outftp == efPDB) { out = gmx_ffopen(outfile, "w"); - write_pdbfile_indexed(out, name, &atoms, x, ePBC, box, ' ', 1, isize, index, conect, FALSE); + write_pdbfile_indexed(out, name, &atoms, x, pbcType, box, ' ', 1, isize, index, conect, FALSE); gmx_ffclose(out); } else { - write_sto_conf_indexed(outfile, name, &atoms, x, bHaveV ? v : nullptr, ePBC, box, isize, index); + write_sto_conf_indexed(outfile, name, &atoms, x, bHaveV ? v : nullptr, pbcType, box, + isize, index); } sfree(grpname); sfree(index); @@ -1291,8 +1292,8 @@ int gmx_editconf(int argc, char* argv[]) { index[i] = i; } - write_pdbfile_indexed(out, name, &atoms, x, ePBC, box, ' ', -1, atoms.nr, index, conect, - outftp == efPQR); + write_pdbfile_indexed(out, name, &atoms, x, pbcType, box, ' ', -1, atoms.nr, index, + conect, outftp == efPQR); sfree(index); if (bLegend) { @@ -1307,7 +1308,7 @@ int gmx_editconf(int argc, char* argv[]) } else { - write_sto_conf(outfile, name, &atoms, x, bHaveV ? v : nullptr, ePBC, box); + write_sto_conf(outfile, name, &atoms, x, bHaveV ? v : nullptr, pbcType, box); } } done_atom(&atoms); diff --git a/src/gromacs/gmxpreprocess/genconf.cpp b/src/gromacs/gmxpreprocess/genconf.cpp index 1e08978999..37d6384f6e 100644 --- a/src/gromacs/gmxpreprocess/genconf.cpp +++ b/src/gromacs/gmxpreprocess/genconf.cpp @@ -123,7 +123,7 @@ int gmx_genconf(int argc, char* argv[]) rvec * x, *xx, *v; /* coordinates? */ real t; vec4 * xrot, *vrot; - int ePBC; + PbcType pbcType; matrix box, boxx; /* box length matrix */ rvec shift; int natoms; /* number of atoms in one molecule */ @@ -178,7 +178,7 @@ int gmx_genconf(int argc, char* argv[]) gmx_mtop_t mtop; bool haveTop = false; - readConfAndTopology(opt2fn("-f", NFILE, fnm), &haveTop, &mtop, &ePBC, &x, &v, box); + readConfAndTopology(opt2fn("-f", NFILE, fnm), &haveTop, &mtop, &pbcType, &x, &v, box); t_atoms atoms = gmx_mtop_global_atoms(&mtop); natoms = atoms.nr; nres = atoms.nres; /* nr of residues in one element? */ @@ -242,7 +242,7 @@ int gmx_genconf(int argc, char* argv[]) v[ndx + l][m] = v[l][m]; } } - if (ePBC == epbcSCREW && i % 2 == 1) + if (pbcType == PbcType::Screw && i % 2 == 1) { /* Rotate around x axis */ for (m = YY; m <= ZZ; m++) @@ -290,10 +290,10 @@ int gmx_genconf(int argc, char* argv[]) svmul(nx, box[XX], box[XX]); svmul(ny, box[YY], box[YY]); svmul(nz, box[ZZ], box[ZZ]); - if (ePBC == epbcSCREW && nx % 2 == 0) + if (pbcType == PbcType::Screw && nx % 2 == 0) { /* With an even number of boxes in x we can forgot about the screw */ - ePBC = epbcXYZ; + pbcType = PbcType::Xyz; } /*depending on how you look at it, this is either a nasty hack or the way it should work*/ @@ -305,7 +305,7 @@ int gmx_genconf(int argc, char* argv[]) } } - write_sto_conf(opt2fn("-o", NFILE, fnm), *mtop.name, &atoms, x, v, ePBC, box); + write_sto_conf(opt2fn("-o", NFILE, fnm), *mtop.name, &atoms, x, v, pbcType, box); sfree(x); sfree(v); diff --git a/src/gromacs/gmxpreprocess/genion.cpp b/src/gromacs/gmxpreprocess/genion.cpp index 96519dbfe4..165e115e8d 100644 --- a/src/gromacs/gmxpreprocess/genion.cpp +++ b/src/gromacs/gmxpreprocess/genion.cpp @@ -481,7 +481,8 @@ int gmx_genion(int argc, char* argv[]) matrix box; t_atoms atoms; t_pbc pbc; - int * repl, ePBC; + int* repl; + PbcType pbcType; int nw, nsa, nsalt, iqtot; gmx_output_env_t* oenv = nullptr; t_filenm fnm[] = { { efTPR, nullptr, nullptr, ffREAD }, @@ -512,7 +513,7 @@ int gmx_genion(int argc, char* argv[]) } /* Read atom positions and charges */ - read_tps_conf(ftp2fn(efTPR, NFILE, fnm), &top, &ePBC, &x, nullptr, box, FALSE); + read_tps_conf(ftp2fn(efTPR, NFILE, fnm), &top, &pbcType, &x, nullptr, box, FALSE); atoms = top.atoms; /* Compute total charge */ @@ -621,7 +622,7 @@ int gmx_genion(int argc, char* argv[]) } snew(repl, nw); - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); if (seed == 0) @@ -667,7 +668,7 @@ int gmx_genion(int argc, char* argv[]) sfree(atoms.pdbinfo); atoms.pdbinfo = nullptr; - write_sto_conf(ftp2fn(efSTO, NFILE, fnm), *top.name, &atoms, x, nullptr, ePBC, box); + write_sto_conf(ftp2fn(efSTO, NFILE, fnm), *top.name, &atoms, x, nullptr, pbcType, box); sfree(pptr); sfree(paptr); diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 854db40b50..28562ffeb4 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -869,7 +869,7 @@ static void read_posres(gmx_mtop_t* mtop, gmx_bool bTopB, const char* fn, int rc_scaling, - int ePBC, + PbcType pbcType, rvec com, warninp* wi) { @@ -898,7 +898,7 @@ static void read_posres(gmx_mtop_t* mtop, warning(wi, warn_buf); } - npbcdim = ePBC2npbcdim(ePBC); + npbcdim = numPbcDimensions(pbcType); GMX_RELEASE_ASSERT(npbcdim <= DIM, "Invalid npbcdim"); clear_rvec(com); if (rc_scaling != erscNO) @@ -1058,16 +1058,16 @@ static void gen_posres(gmx_mtop_t* mtop, const char* fnA, const char* fnB, int rc_scaling, - int ePBC, + PbcType pbcType, rvec com, rvec comB, warninp* wi) { - read_posres(mtop, mi, FALSE, fnA, rc_scaling, ePBC, com, wi); + read_posres(mtop, mi, FALSE, fnA, rc_scaling, pbcType, com, wi); /* It is safer to simply read the b-state posres rather than trying * to be smart and copy the positions. */ - read_posres(mtop, mi, TRUE, fnB, rc_scaling, ePBC, comB, wi); + read_posres(mtop, mi, TRUE, fnB, rc_scaling, pbcType, comB, wi); } static void set_wall_atomtype(PreprocessingAtomTypes* at, t_gromppopts* opts, t_inputrec* ir, warninp* wi) @@ -1613,13 +1613,13 @@ static void set_verlet_buffer(const gmx_mtop_t* mtop, t_inputrec* ir, real buffe printf("Note that mdrun will redetermine rlist based on the actual pair-list setup\n"); - if (gmx::square(ir->rlist) >= max_cutoff2(ir->ePBC, box)) + if (gmx::square(ir->rlist) >= max_cutoff2(ir->pbcType, box)) { gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or " "longer than the smallest box diagonal element (%g nm). Increase the box size or " "decrease nstlist or increase verlet-buffer-tolerance.", - ir->rlist, std::sqrt(max_cutoff2(ir->ePBC, box))); + ir->rlist, std::sqrt(max_cutoff2(ir->pbcType, box))); } } @@ -1979,7 +1979,8 @@ int gmx_grompp(int argc, char* argv[]) fprintf(stderr, " and %s\n", fnB); } } - gen_posres(&sys, mi, fn, fnB, ir->refcoord_scaling, ir->ePBC, ir->posres_com, ir->posres_comB, wi); + gen_posres(&sys, mi, fn, fnB, ir->refcoord_scaling, ir->pbcType, ir->posres_com, + ir->posres_comB, wi); } /* If we are using CMAP, setup the pre-interpolation grid */ @@ -2196,7 +2197,7 @@ int gmx_grompp(int argc, char* argv[]) fr_time, ir, &state, &sys, oenv); } - if (ir->ePBC == epbcXY && ir->nwall != 2) + if (ir->pbcType == PbcType::XY && ir->nwall != 2) { clear_rvec(state.box[ZZ]); } @@ -2276,7 +2277,7 @@ int gmx_grompp(int argc, char* argv[]) { copy_mat(ir->compress, compressibility); } - setStateDependentAwhParams(ir->awhParams, ir->pull, pull, state.box, ir->ePBC, + setStateDependentAwhParams(ir->awhParams, ir->pull, pull, state.box, ir->pbcType, compressibility, &ir->opts, wi); } diff --git a/src/gromacs/gmxpreprocess/insert_molecules.cpp b/src/gromacs/gmxpreprocess/insert_molecules.cpp index 209abf3e09..6afabf9da4 100644 --- a/src/gromacs/gmxpreprocess/insert_molecules.cpp +++ b/src/gromacs/gmxpreprocess/insert_molecules.cpp @@ -175,7 +175,7 @@ static void insert_mols(int nmol_insrt, const std::set& removableAtoms, const t_atoms& atoms_insrt, gmx::ArrayRef x_insrt, - int ePBC, + PbcType pbcType, matrix box, const std::string& posfn, const rvec deltaR, @@ -211,7 +211,7 @@ static void insert_mols(int nmol_insrt, gmx::DefaultRandomEngine rng(seed); t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); /* With -ip, take nmol_insrt from file posfn */ double** rpos = nullptr; @@ -370,7 +370,7 @@ private: gmx_mtop_t top_; std::vector x_; matrix box_; - int ePBC_; + PbcType pbcType_; }; void InsertMolecules::initOptions(IOptionsContainer* options, ICommandLineOptionsModuleSettings* settings) @@ -504,7 +504,7 @@ void InsertMolecules::optionsFinished() bool bTprFileWasRead; rvec* temporaryX = nullptr; fprintf(stderr, "Reading solute configuration\n"); - readConfAndTopology(inputConfFile_.c_str(), &bTprFileWasRead, &top_, &ePBC_, &temporaryX, + readConfAndTopology(inputConfFile_.c_str(), &bTprFileWasRead, &top_, &pbcType_, &temporaryX, nullptr, box_); x_.assign(temporaryX, temporaryX + top_.natoms); sfree(temporaryX); @@ -521,7 +521,7 @@ int InsertMolecules::run() if (replaceSel_.isValid()) { t_pbc pbc; - set_pbc(&pbc, ePBC_, box_); + set_pbc(&pbc, pbcType_, box_); t_trxframe* fr; snew(fr, 1); fr->natoms = x_.size(); @@ -535,10 +535,10 @@ int InsertMolecules::run() // individual atoms. } - int ePBCForOutput = ePBC_; + PbcType pbcTypeForOutput = pbcType_; if (bBox_) { - ePBCForOutput = epbcXYZ; + pbcTypeForOutput = PbcType::Xyz; clear_mat(box_); box_[XX][XX] = newBox_[XX]; box_[YY][YY] = newBox_[YY]; @@ -555,11 +555,11 @@ int InsertMolecules::run() t_atoms atomsInserted; std::vector xInserted; { - bool bTprFileWasRead; - int ePBC_dummy; - matrix box_dummy; - rvec* temporaryX; - readConfAndTopology(insertConfFile_.c_str(), &bTprFileWasRead, &topInserted, &ePBC_dummy, + bool bTprFileWasRead; + PbcType pbcType_dummy; + matrix box_dummy; + rvec* temporaryX; + readConfAndTopology(insertConfFile_.c_str(), &bTprFileWasRead, &topInserted, &pbcType_dummy, &temporaryX, nullptr, box_dummy); xInserted.assign(temporaryX, temporaryX + topInserted.natoms); sfree(temporaryX); @@ -583,13 +583,13 @@ int InsertMolecules::run() /* add nmol_ins molecules of atoms_ins in random orientation at random place */ insert_mols(nmolIns_, nmolTry_, seed_, defaultDistance_, scaleFactor_, &atoms, &top_.symtab, - &x_, removableAtoms, atomsInserted, xInserted, ePBCForOutput, box_, positionFile_, - deltaR_, enumRot_); + &x_, removableAtoms, atomsInserted, xInserted, pbcTypeForOutput, box_, + positionFile_, deltaR_, enumRot_); /* write new configuration to file confout */ fprintf(stderr, "Writing generated configuration to %s\n", outputConfFile_.c_str()); write_sto_conf(outputConfFile_.c_str(), *top_.name, &atoms, as_rvec_array(x_.data()), nullptr, - ePBCForOutput, box_); + pbcTypeForOutput, box_); /* print size of generated configuration */ fprintf(stderr, "\nOutput configuration contains %d atoms in %d residues\n", atoms.nr, atoms.nres); diff --git a/src/gromacs/gmxpreprocess/pdb2gmx.cpp b/src/gromacs/gmxpreprocess/pdb2gmx.cpp index eb9da92af5..f3885d21ed 100644 --- a/src/gromacs/gmxpreprocess/pdb2gmx.cpp +++ b/src/gromacs/gmxpreprocess/pdb2gmx.cpp @@ -524,7 +524,7 @@ static int read_pdball(const char* inf, char** title, t_atoms* atoms, rvec** x, - int* ePBC, + PbcType* pbcType, matrix box, bool bRemoveH, t_symtab* symtab, @@ -538,7 +538,7 @@ static int read_pdball(const char* inf, /* READ IT */ printf("Reading %s...\n", inf); - readConfAndAtoms(inf, symtab, title, atoms, ePBC, x, nullptr, box); + readConfAndAtoms(inf, symtab, title, atoms, pbcType, x, nullptr, box); natom = atoms->nr; if (atoms->pdbinfo == nullptr) { @@ -586,7 +586,7 @@ static int read_pdball(const char* inf, } if (bOutput) { - write_sto_conf(outf, *title, atoms, *x, nullptr, *ePBC, box); + write_sto_conf(outf, *title, atoms, *x, nullptr, *pbcType, box); } return natom; @@ -1735,11 +1735,11 @@ int pdb2gmx::run() AtomProperties aps; char* title = nullptr; - int ePBC; + PbcType pbcType; t_atoms pdba_all; rvec* pdbx; int natom = read_pdball(inputConfFile_.c_str(), bOutputSet_, outFile_.c_str(), &title, &pdba_all, - &pdbx, &ePBC, box, bRemoveH_, &symtab, &rt, watres, &aps, bVerbose_); + &pdbx, &pbcType, box, bRemoveH_, &symtab, &rt, watres, &aps, bVerbose_); if (natom == 0) { @@ -2409,7 +2409,8 @@ int pdb2gmx::run() { make_new_box(atoms->nr, gmx::as_rvec_array(x.data()), box, box_space, false); } - write_sto_conf(outputConfFile_.c_str(), title, atoms, gmx::as_rvec_array(x.data()), nullptr, ePBC, box); + write_sto_conf(outputConfFile_.c_str(), title, atoms, gmx::as_rvec_array(x.data()), nullptr, + pbcType, box); done_symtab(&symtab); done_atom(&pdba_all); diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index 9a5e6908ed..657fcea1e6 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -589,8 +589,8 @@ void check_ir(const char* mdparin, /* TPI STUFF */ if (EI_TPI(ir->eI)) { - sprintf(err_buf, "TPI only works with pbc = %s", epbc_names[epbcXYZ]); - CHECK(ir->ePBC != epbcXYZ); + sprintf(err_buf, "TPI only works with pbc = %s", c_pbcTypeNames[PbcType::Xyz].c_str()); + CHECK(ir->pbcType != PbcType::Xyz); sprintf(err_buf, "with TPI nstlist should be larger than zero"); CHECK(ir->nstlist <= 0); sprintf(err_buf, "TPI does not work with full electrostatics other than PME"); @@ -910,13 +910,13 @@ void check_ir(const char* mdparin, } /* PBC/WALLS */ - sprintf(err_buf, "walls only work with pbc=%s", epbc_names[epbcXY]); - CHECK(ir->nwall && ir->ePBC != epbcXY); + sprintf(err_buf, "walls only work with pbc=%s", c_pbcTypeNames[PbcType::XY].c_str()); + CHECK(ir->nwall && ir->pbcType != PbcType::XY); /* VACUUM STUFF */ - if (ir->ePBC != epbcXYZ && ir->nwall != 2) + if (ir->pbcType != PbcType::Xyz && ir->nwall != 2) { - if (ir->ePBC == epbcNONE) + if (ir->pbcType == PbcType::No) { if (ir->epc != epcNO) { @@ -926,13 +926,15 @@ void check_ir(const char* mdparin, } else { - sprintf(err_buf, "Can not have pressure coupling with pbc=%s", epbc_names[ir->ePBC]); + sprintf(err_buf, "Can not have pressure coupling with pbc=%s", + c_pbcTypeNames[ir->pbcType].c_str()); CHECK(ir->epc != epcNO); } - sprintf(err_buf, "Can not have Ewald with pbc=%s", epbc_names[ir->ePBC]); + sprintf(err_buf, "Can not have Ewald with pbc=%s", c_pbcTypeNames[ir->pbcType].c_str()); CHECK(EEL_FULL(ir->coulombtype)); - sprintf(err_buf, "Can not have dispersion correction with pbc=%s", epbc_names[ir->ePBC]); + sprintf(err_buf, "Can not have dispersion correction with pbc=%s", + c_pbcTypeNames[ir->pbcType].c_str()); CHECK(ir->eDispCorr != edispcNO); } @@ -943,9 +945,9 @@ void check_ir(const char* mdparin, "with coulombtype = %s or coulombtype = %s\n" "without periodic boundary conditions (pbc = %s) and\n" "rcoulomb and rvdw set to zero", - eel_names[eelCUT], eel_names[eelUSER], epbc_names[epbcNONE]); + eel_names[eelCUT], eel_names[eelUSER], c_pbcTypeNames[PbcType::No].c_str()); CHECK(((ir->coulombtype != eelCUT) && (ir->coulombtype != eelUSER)) - || (ir->ePBC != epbcNONE) || (ir->rcoulomb != 0.0) || (ir->rvdw != 0.0)); + || (ir->pbcType != PbcType::No) || (ir->rcoulomb != 0.0) || (ir->rvdw != 0.0)); if (ir->nstlist > 0) { @@ -991,7 +993,7 @@ void check_ir(const char* mdparin, "Can not remove the rotation around the center of mass with periodic " "molecules"); CHECK(ir->bPeriodicMols); - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { warning(wi, "Removing the rotation around the center of mass in a periodic system, " @@ -1001,7 +1003,7 @@ void check_ir(const char* mdparin, } } - if (EI_STATE_VELOCITY(ir->eI) && !EI_SD(ir->eI) && ir->ePBC == epbcNONE && ir->comm_mode != ecmANGULAR) + if (EI_STATE_VELOCITY(ir->eI) && !EI_SD(ir->eI) && ir->pbcType == PbcType::No && ir->comm_mode != ecmANGULAR) { sprintf(warn_buf, "Tumbling and flying ice-cubes: We are not removing rotation around center of mass " @@ -1308,18 +1310,18 @@ void check_ir(const char* mdparin, { if (ir->ewald_geometry == eewg3D) { - sprintf(warn_buf, "With pbc=%s you should use ewald-geometry=%s", epbc_names[ir->ePBC], - eewg_names[eewg3DC]); + sprintf(warn_buf, "With pbc=%s you should use ewald-geometry=%s", + c_pbcTypeNames[ir->pbcType].c_str(), eewg_names[eewg3DC]); warning(wi, warn_buf); } /* This check avoids extra pbc coding for exclusion corrections */ sprintf(err_buf, "wall-ewald-zfac should be >= 2"); CHECK(ir->wall_ewald_zfac < 2); } - if ((ir->ewald_geometry == eewg3DC) && (ir->ePBC != epbcXY) && EEL_FULL(ir->coulombtype)) + if ((ir->ewald_geometry == eewg3DC) && (ir->pbcType != PbcType::XY) && EEL_FULL(ir->coulombtype)) { sprintf(warn_buf, "With %s and ewald_geometry = %s you should use pbc = %s", - eel_names[ir->coulombtype], eewg_names[eewg3DC], epbc_names[epbcXY]); + eel_names[ir->coulombtype], eewg_names[eewg3DC], c_pbcTypeNames[PbcType::XY].c_str()); warning(wi, warn_buf); } if ((ir->epsilon_surface != 0) && EEL_FULL(ir->coulombtype)) @@ -1963,7 +1965,13 @@ void get_ir(const char* mdparin, printStringNoNewline(&inp, "nblist update frequency"); ir->nstlist = get_eint(&inp, "nstlist", 10, wi); printStringNoNewline(&inp, "Periodic boundary conditions: xyz, no, xy"); - ir->ePBC = get_eeenum(&inp, "pbc", epbc_names, wi); + // TODO This conversion should be removed when proper std:string handling will be added to get_eeenum(...), etc. + std::vector pbcTypesNamesChar; + for (const auto& pbcTypeName : c_pbcTypeNames) + { + pbcTypesNamesChar.push_back(pbcTypeName.c_str()); + } + ir->pbcType = static_cast(get_eeenum(&inp, "pbc", pbcTypesNamesChar.data(), wi)); ir->bPeriodicMols = get_eeenum(&inp, "periodic-molecules", yesno_names, wi) != 0; printStringNoNewline(&inp, "Allowed energy error due to the Verlet buffer in kJ/mol/ps per atom,"); @@ -4376,7 +4384,7 @@ void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool b char warn_buf[STRLEN]; const char* ptr; - ptr = check_box(ir->ePBC, box); + ptr = check_box(ir->pbcType, box); if (ptr) { warning_error(wi, ptr); @@ -4426,7 +4434,7 @@ void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool b ir->LincsWarnAngle = 90.0; } - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { if (ir->nstlist == 0) { @@ -4434,7 +4442,7 @@ void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool b "With nstlist=0 atoms are only put into the box at step 0, therefore drifting " "atoms might cause the simulation to crash."); } - if (gmx::square(ir->rlist) >= max_cutoff2(ir->ePBC, box)) + if (gmx::square(ir->rlist) >= max_cutoff2(ir->pbcType, box)) { sprintf(warn_buf, "ERROR: The cut-off length is longer than half the shortest box vector or " diff --git a/src/gromacs/gmxpreprocess/readpull.cpp b/src/gromacs/gmxpreprocess/readpull.cpp index f45a0e4d69..6aae234fa7 100644 --- a/src/gromacs/gmxpreprocess/readpull.cpp +++ b/src/gromacs/gmxpreprocess/readpull.cpp @@ -539,7 +539,7 @@ pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix bo update_mdatoms(md, lambda); } - set_pbc(&pbc, ir->ePBC, box); + set_pbc(&pbc, ir->pbcType, box); t_start = ir->init_t + ir->init_step * ir->delta_t; diff --git a/src/gromacs/gmxpreprocess/solvate.cpp b/src/gromacs/gmxpreprocess/solvate.cpp index 3a6ee40ecf..054d5b223a 100644 --- a/src/gromacs/gmxpreprocess/solvate.cpp +++ b/src/gromacs/gmxpreprocess/solvate.cpp @@ -608,7 +608,7 @@ static void add_solv(const char* filename, t_symtab* symtab, std::vector* x, std::vector* v, - int ePBC, + PbcType pbcType, matrix box, AtomProperties* aps, real defaultDistance, @@ -619,13 +619,13 @@ static void add_solv(const char* filename, gmx_mtop_t topSolvent; std::vector xSolvent, vSolvent; matrix boxSolvent = { { 0 } }; - int ePBCSolvent; + PbcType pbcTypeSolvent; fprintf(stderr, "Reading solvent configuration\n"); bool bTprFileWasRead; rvec *temporaryX = nullptr, *temporaryV = nullptr; readConfAndTopology(gmx::findLibraryFile(filename).c_str(), &bTprFileWasRead, &topSolvent, - &ePBCSolvent, &temporaryX, &temporaryV, boxSolvent); + &pbcTypeSolvent, &temporaryX, &temporaryV, boxSolvent); t_atoms* atomsSolvent; snew(atomsSolvent, 1); *atomsSolvent = gmx_mtop_global_atoms(&topSolvent); @@ -655,7 +655,7 @@ static void add_solv(const char* filename, /* generate a new solvent configuration */ fprintf(stderr, "Generating solvent configuration\n"); t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); if (!gmx::boxesAreEqual(boxSolvent, box)) { if (TRICLINIC(boxSolvent)) @@ -667,7 +667,7 @@ static void add_solv(const char* filename, /* apply pbc for solvent configuration for whole molecules */ rm_res_pbc(atomsSolvent, &xSolvent, boxSolvent); replicateSolventBox(atomsSolvent, &xSolvent, &vSolvent, &exclusionDistances_solvt, boxSolvent, box); - if (ePBC != epbcNONE) + if (pbcType != PbcType::No) { removeSolventBoxOverlap(atomsSolvent, &xSolvent, &vSolvent, &exclusionDistances_solvt, pbc); } @@ -964,8 +964,8 @@ int gmx_solvate(int argc, char* argv[]) /* solute configuration data */ gmx_mtop_t top; std::vector x, v; - matrix box = { { 0 } }; - int ePBC = -1; + matrix box = { { 0 } }; + PbcType pbcType = PbcType::Unset; t_atoms* atoms; snew(atoms, 1); if (bProt) @@ -975,7 +975,7 @@ int gmx_solvate(int argc, char* argv[]) fprintf(stderr, "Reading solute configuration%s\n", bReadV ? " and velocities" : ""); bool bTprFileWasRead; rvec *temporaryX = nullptr, *temporaryV = nullptr; - readConfAndTopology(conf_prot, &bTprFileWasRead, &top, &ePBC, &temporaryX, + readConfAndTopology(conf_prot, &bTprFileWasRead, &top, &pbcType, &temporaryX, bReadV ? &temporaryV : nullptr, box); *atoms = gmx_mtop_global_atoms(&top); x.assign(temporaryX, temporaryX + top.natoms); @@ -999,10 +999,10 @@ int gmx_solvate(int argc, char* argv[]) firstSolventResidueIndex = atoms->nres; } } - int ePBCForOutput = ePBC; + PbcType pbcTypeForOutput = pbcType; if (bBox) { - ePBCForOutput = epbcXYZ; + pbcTypeForOutput = PbcType::Xyz; clear_mat(box); box[XX][XX] = new_box[XX]; box[YY][YY] = new_box[YY]; @@ -1015,15 +1015,15 @@ int gmx_solvate(int argc, char* argv[]) "or give explicit -box command line option"); } - add_solv(solventFileName, atoms, &top.symtab, &x, &v, ePBCForOutput, box, &aps, defaultDistance, - scaleFactor, r_shell, max_sol); + add_solv(solventFileName, atoms, &top.symtab, &x, &v, pbcTypeForOutput, box, &aps, + defaultDistance, scaleFactor, r_shell, max_sol); /* write new configuration 1 to file confout */ confout = ftp2fn(efSTO, NFILE, fnm); fprintf(stderr, "Writing generated configuration to %s\n", confout); const char* outputTitle = (bProt ? *top.name : "Generated by gmx solvate"); write_sto_conf(confout, outputTitle, atoms, as_rvec_array(x.data()), - !v.empty() ? as_rvec_array(v.data()) : nullptr, ePBCForOutput, box); + !v.empty() ? as_rvec_array(v.data()) : nullptr, pbcTypeForOutput, box); /* print size of generated configuration */ fprintf(stderr, "\nOutput configuration contains %d atoms in %d residues\n", atoms->nr, atoms->nres); diff --git a/src/gromacs/gmxpreprocess/x2top.cpp b/src/gromacs/gmxpreprocess/x2top.cpp index 960e6252c2..4aff04ce7c 100644 --- a/src/gromacs/gmxpreprocess/x2top.cpp +++ b/src/gromacs/gmxpreprocess/x2top.cpp @@ -110,7 +110,7 @@ static void mk_bonds(int nnm, std::array forceParam = { 0.0 }; if (bPBC) { - set_pbc(&pbc, -1, box); + set_pbc(&pbc, PbcType::Unset, box); } for (i = 0; (i < atoms->nr); i++) { @@ -264,7 +264,7 @@ static void calc_angles_dihs(InteractionsOfType* ang, InteractionsOfType* dih, c if (bPBC) { - set_pbc(&pbc, epbcXYZ, box); + set_pbc(&pbc, PbcType::Xyz, box); } for (auto& angle : ang->interactionTypes) { @@ -399,7 +399,7 @@ int gmx_x2top(int argc, char* argv[]) int bts[] = { 1, 1, 1, 2 }; matrix box; /* box length matrix */ int natoms; /* number of atoms in one molecule */ - int epbc; + PbcType pbcType; bool bRTP, bTOP, bOPLS; t_symtab symtab; real qtot, mtot; @@ -491,7 +491,7 @@ int gmx_x2top(int argc, char* argv[]) /* Read coordinates */ t_topology* top; snew(top, 1); - read_tps_conf(opt2fn("-f", NFILE, fnm), top, &epbc, &x, nullptr, box, FALSE); + read_tps_conf(opt2fn("-f", NFILE, fnm), top, &pbcType, &x, nullptr, box, FALSE); t_atoms* atoms = &top->atoms; natoms = atoms->nr; if (atoms->pdbinfo == nullptr) diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index 9dc5c3d876..6126e65fee 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -523,8 +523,9 @@ void write_IMDgroup_to_file(bool bIMD, if (bIMD) { IMDatoms = gmx_mtop_global_atoms(sys); - write_sto_conf_indexed(opt2fn("-imd", nfile, fnm), "IMDgroup", &IMDatoms, state->x.rvec_array(), - state->v.rvec_array(), ir->ePBC, state->box, ir->imd->nat, ir->imd->ind); + write_sto_conf_indexed(opt2fn("-imd", nfile, fnm), "IMDgroup", &IMDatoms, + state->x.rvec_array(), state->v.rvec_array(), ir->pbcType, + state->box, ir->imd->nat, ir->imd->ind); } } diff --git a/src/gromacs/listed_forces/gpubondedkernels.cu b/src/gromacs/listed_forces/gpubondedkernels.cu index fbb6baee1f..a1c81514af 100644 --- a/src/gromacs/listed_forces/gpubondedkernels.cu +++ b/src/gromacs/listed_forces/gpubondedkernels.cu @@ -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,2020, 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. @@ -870,7 +870,7 @@ void GpuBonded::Impl::launchKernel(const t_forcerec* fr, const matrix box) "TPB_BONDED must be >= SHIFTS for the virial kernel (calcVir=true)"); PbcAiuc pbcAiuc; - setPbcAiuc(fr->bMolPBC ? ePBC2npbcdim(fr->ePBC) : 0, box, &pbcAiuc); + setPbcAiuc(fr->bMolPBC ? numPbcDimensions(fr->pbcType) : 0, box, &pbcAiuc); int fTypeRangeEnd = kernelParams_.fTypeRangeEnd[numFTypesOnGpu - 1]; diff --git a/src/gromacs/listed_forces/listed_forces.cpp b/src/gromacs/listed_forces/listed_forces.cpp index a64cdc0237..2d1797f1d7 100644 --- a/src/gromacs/listed_forces/listed_forces.cpp +++ b/src/gromacs/listed_forces/listed_forces.cpp @@ -530,7 +530,7 @@ void calc_listed(const t_commrec* cr, * do with checking graph!=nullptr, which should tell us if we made * molecules whole before calling the current function. */ - GMX_RELEASE_ASSERT(fr->ePBC == epbcNONE || g != nullptr, + GMX_RELEASE_ASSERT(fr->pbcType == PbcType::No || g != nullptr, "With orientation restraints molecules should be whole"); enerd->term[F_ORIRESDEV] = calc_orires_dev(ms, idef->il[F_ORIRES].nr, idef->il[F_ORIRES].iatoms, idef->iparams, md, x, pbc_null, fcd, hist); @@ -677,7 +677,7 @@ void do_force_listed(struct gmx_wallcycle* wcycle, if ((idef->il[F_POSRES].nr > 0) || (idef->il[F_FBPOSRES].nr > 0)) { /* Not enough flops to bother counting */ - set_pbc(&pbc_full, fr->ePBC, box); + set_pbc(&pbc_full, fr->pbcType, box); } calc_listed(cr, ms, wcycle, idef, x, hist, forceOutputs, fr, pbc, &pbc_full, graph, enerd, nrnb, lambda, md, fcd, global_atom_index, stepWork); diff --git a/src/gromacs/listed_forces/pairs.cpp b/src/gromacs/listed_forces/pairs.cpp index 9a5a401db7..c3fee5885f 100644 --- a/src/gromacs/listed_forces/pairs.cpp +++ b/src/gromacs/listed_forces/pairs.cpp @@ -733,7 +733,7 @@ void do_pairs(int ftype, } else { - set_pbc(&pbc_no, epbcNONE, nullptr); + set_pbc(&pbc_no, PbcType::No, nullptr); pbc_nonnull = &pbc_no; } diff --git a/src/gromacs/listed_forces/position_restraints.cpp b/src/gromacs/listed_forces/position_restraints.cpp index 84359236cb..36482d0712 100644 --- a/src/gromacs/listed_forces/position_restraints.cpp +++ b/src/gromacs/listed_forces/position_restraints.cpp @@ -195,7 +195,7 @@ real fbposres(int nbonds, gmx::ForceWithVirial* forceWithVirial, const t_pbc* pbc, int refcoord_scaling, - int ePBC, + PbcType pbcType, const rvec com) /* compute flat-bottomed positions restraints */ { @@ -206,8 +206,8 @@ real fbposres(int nbonds, rvec com_sc, rdist, dx, dpdl, fm; gmx_bool bInvert; - npbcdim = ePBC2npbcdim(ePBC); - GMX_ASSERT((ePBC == epbcNONE) == (npbcdim == 0), ""); + npbcdim = numPbcDimensions(pbcType); + GMX_ASSERT((pbcType == PbcType::No) == (npbcdim == 0), ""); if (refcoord_scaling == erscCOM) { clear_rvec(com_sc); @@ -328,7 +328,7 @@ real posres(int nbonds, real lambda, real* dvdlambda, int refcoord_scaling, - int ePBC, + PbcType pbcType, const rvec comA, const rvec comB) { @@ -337,8 +337,8 @@ real posres(int nbonds, real kk, fm; rvec comA_sc, comB_sc, rdist, dpdl, dx; - npbcdim = ePBC2npbcdim(ePBC); - GMX_ASSERT((ePBC == epbcNONE) == (npbcdim == 0), ""); + npbcdim = numPbcDimensions(pbcType); + GMX_ASSERT((pbcType == PbcType::No) == (npbcdim == 0), ""); if (refcoord_scaling == erscCOM) { clear_rvec(comA_sc); @@ -414,8 +414,8 @@ void posres_wrapper(t_nrnb* nrnb, dvdl = 0; v = posres(idef->il[F_POSRES].nr, idef->il[F_POSRES].iatoms, idef->iparams_posres, x, - forceWithVirial, fr->ePBC == epbcNONE ? nullptr : pbc, lambda[efptRESTRAINT], - &dvdl, fr->rc_scaling, fr->ePBC, fr->posres_com, fr->posres_comB); + forceWithVirial, fr->pbcType == PbcType::No ? nullptr : pbc, lambda[efptRESTRAINT], + &dvdl, fr->rc_scaling, fr->pbcType, fr->posres_com, fr->posres_comB); enerd->term[F_POSRES] += v; /* If just the force constant changes, the FEP term is linear, * but if k changes, it is not. @@ -447,8 +447,8 @@ void posres_wrapper_lambda(struct gmx_wallcycle* wcycle, lambda_dum = (i == 0 ? lambda[efptRESTRAINT] : fepvals->all_lambda[efptRESTRAINT][i - 1]); v = posres(idef->il[F_POSRES].nr, idef->il[F_POSRES].iatoms, idef->iparams_posres, x, - nullptr, fr->ePBC == epbcNONE ? nullptr : pbc, lambda_dum, &dvdl_dum, - fr->rc_scaling, fr->ePBC, fr->posres_com, fr->posres_comB); + nullptr, fr->pbcType == PbcType::No ? nullptr : pbc, lambda_dum, + &dvdl_dum, fr->rc_scaling, fr->pbcType, fr->posres_com, fr->posres_comB); enerd->enerpart_lambda[i] += v; } wallcycle_sub_stop(wcycle, ewcsRESTRAINTS); @@ -467,8 +467,8 @@ void fbposres_wrapper(t_nrnb* nrnb, real v; v = fbposres(idef->il[F_FBPOSRES].nr, idef->il[F_FBPOSRES].iatoms, idef->iparams_fbposres, x, - forceWithVirial, fr->ePBC == epbcNONE ? nullptr : pbc, fr->rc_scaling, fr->ePBC, - fr->posres_com); + forceWithVirial, fr->pbcType == PbcType::No ? nullptr : pbc, fr->rc_scaling, + fr->pbcType, fr->posres_com); enerd->term[F_FBPOSRES] += v; inc_nrnb(nrnb, eNR_FBPOSRES, gmx::exactDiv(idef->il[F_FBPOSRES].nr, 2)); } diff --git a/src/gromacs/listed_forces/tests/bonded.cpp b/src/gromacs/listed_forces/tests/bonded.cpp index 4447cced8c..c67f0c6563 100644 --- a/src/gromacs/listed_forces/tests/bonded.cpp +++ b/src/gromacs/listed_forces/tests/bonded.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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. @@ -514,24 +514,24 @@ void fillIatoms(int ftype, std::vector* iatoms) } class ListedForcesTest : - public ::testing::TestWithParam, int>> + public ::testing::TestWithParam, PbcType>> { protected: matrix box_; t_pbc pbc_; std::vector x_; - int epbc_; + PbcType pbcType_; iListInput input_; test::TestReferenceData refData_; test::TestReferenceChecker checker_; ListedForcesTest() : checker_(refData_.rootChecker()) { - input_ = std::get<0>(GetParam()); - x_ = std::get<1>(GetParam()); - epbc_ = std::get<2>(GetParam()); + input_ = std::get<0>(GetParam()); + x_ = std::get<1>(GetParam()); + pbcType_ = std::get<2>(GetParam()); clear_mat(box_); box_[0][0] = box_[1][1] = box_[2][2] = 1.5; - set_pbc(&pbc_, epbc_, box_); + set_pbc(&pbc_, pbcType_, box_); // We need quite specific tolerances here since angle functions // etc. are not very precise and reproducible. test::FloatingPointTolerance tolerance(test::FloatingPointTolerance( @@ -540,7 +540,7 @@ protected: } void testOneIfunc(test::TestReferenceChecker* checker, const std::vector& iatoms, const real lambda) { - SCOPED_TRACE(std::string("Testing PBC ") + epbc_names[epbc_]); + SCOPED_TRACE(std::string("Testing PBC ") + c_pbcTypeNames[pbcType_]); std::vector ddgatindex = { 0, 1, 2, 3 }; std::vector chargeA = { 1.5, -2.0, 1.5, -1.0 }; t_mdatoms mdatoms = { 0 }; @@ -661,7 +661,7 @@ std::vector> c_coordinatesForTests = { }; //! PBC values for testing -std::vector c_pbcForTests = { epbcNONE, epbcXY, epbcXYZ }; +std::vector c_pbcForTests = { PbcType::No, PbcType::XY, PbcType::Xyz }; // Those tests give errors with the intel compiler and nothing else, so we disable them only there. #ifndef __INTEL_COMPILER diff --git a/src/gromacs/mdlib/constr.cpp b/src/gromacs/mdlib/constr.cpp index 2fdb1dddae..e17685d74c 100644 --- a/src/gromacs/mdlib/constr.cpp +++ b/src/gromacs/mdlib/constr.cpp @@ -268,7 +268,7 @@ static void write_constr_pdb(const char* fn, out = gmx_fio_fopen(fname, "w"); fprintf(out, "TITLE %s\n", title); - gmx_write_pdb_box(out, -1, box); + gmx_write_pdb_box(out, PbcType::Unset, box); int molb = 0; for (i = start; i < start + homenr; i++) { @@ -425,14 +425,14 @@ bool Constraints::Impl::apply(bool bLog, * Note that PBC for constraints is different from PBC for bondeds. * For constraints there is both forward and backward communication. */ - if (ir.ePBC != epbcNONE && (cr->dd || pbcHandlingRequired_) + if (ir.pbcType != PbcType::No && (cr->dd || pbcHandlingRequired_) && !(cr->dd && cr->dd->constraint_comm == nullptr)) { /* With pbc=screw the screw has been changed to a shift * by the constraint coordinate communication routine, * so that here we can use normal pbc. */ - pbc_null = set_pbc_dd(&pbc, ir.ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, FALSE, box); + pbc_null = set_pbc_dd(&pbc, ir.pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, FALSE, box); } else { @@ -659,7 +659,7 @@ bool Constraints::Impl::apply(bool bLog, { t = ir.init_t; } - set_pbc(&pbc, ir.ePBC, box); + set_pbc(&pbc, ir.pbcType, box); pull_constraint(pull_work, &md, &pbc, cr, ir.delta_t, t, x, xprime, v, *vir); } if (ed && delta_step > 0) diff --git a/src/gromacs/mdlib/coupling.cpp b/src/gromacs/mdlib/coupling.cpp index ffcc4ca76a..4281a84536 100644 --- a/src/gromacs/mdlib/coupling.cpp +++ b/src/gromacs/mdlib/coupling.cpp @@ -289,7 +289,7 @@ static void boxv_trotter(const t_inputrec* ir, /* for now, we use Elr = 0, because if you want to get it right, you really should be using PME. Maybe print a warning? */ - pscal = calc_pres(ir->ePBC, nwall, box, ekinmod, vir, localpres) + pcorr; + pscal = calc_pres(ir->pbcType, nwall, box, ekinmod, vir, localpres) + pcorr; vol = det(box); GW = (vol * (MassQ->Winv / PRESFAC)) * (DIM * pscal - trace(ir->ref_p)); /* W is in ps^2 * bar * nm^3 */ @@ -305,12 +305,12 @@ static void boxv_trotter(const t_inputrec* ir, * */ -real calc_pres(int ePBC, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres) +real calc_pres(PbcType pbcType, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres) { int n, m; real fac; - if (ePBC == epbcNONE || (ePBC == epbcXY && nwall != 2)) + if (pbcType == PbcType::No || (pbcType == PbcType::XY && nwall != 2)) { clear_mat(pres); } diff --git a/src/gromacs/mdlib/force.cpp b/src/gromacs/mdlib/force.cpp index 937b33b7ec..0bc7b13c8c 100644 --- a/src/gromacs/mdlib/force.cpp +++ b/src/gromacs/mdlib/force.cpp @@ -178,7 +178,7 @@ void do_force_lowlevel(t_forcerec* fr, /* Since all atoms are in the rectangular or triclinic unit-cell, * only single box vector shifts (2 in x) are required. */ - set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, TRUE, box); + set_pbc_dd(&pbc, fr->pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, TRUE, box); } do_force_listed(wcycle, box, ir->fepvals, cr, ms, idef, x, hist, forceOutputs, fr, &pbc, diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index adfb6caf09..1aa3402e78 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -951,9 +951,9 @@ void init_forcerec(FILE* fp, /* By default we turn SIMD kernels on, but it might be turned off further down... */ fr->use_simd_kernels = TRUE; - if (check_box(ir->ePBC, box)) + if (check_box(ir->pbcType, box)) { - gmx_fatal(FARGS, "%s", check_box(ir->ePBC, box)); + gmx_fatal(FARGS, "%s", check_box(ir->pbcType, box)); } /* Test particle insertion ? */ @@ -1051,10 +1051,10 @@ void init_forcerec(FILE* fp, /* Neighbour searching stuff */ fr->cutoff_scheme = ir->cutoff_scheme; - fr->ePBC = ir->ePBC; + fr->pbcType = ir->pbcType; /* Determine if we will do PBC for distances in bonded interactions */ - if (fr->ePBC == epbcNONE) + if (fr->pbcType == PbcType::No) { fr->bMolPBC = FALSE; } @@ -1131,7 +1131,7 @@ void init_forcerec(FILE* fp, } else { - fr->bMolPBC = dd_bonded_molpbc(cr->dd, fr->ePBC); + fr->bMolPBC = dd_bonded_molpbc(cr->dd, fr->pbcType); if (useEwaldSurfaceCorrection && !dd_moleculesAreAlwaysWhole(*cr->dd)) { diff --git a/src/gromacs/mdlib/md_support.cpp b/src/gromacs/mdlib/md_support.cpp index 897c784d47..7a37bdfef1 100644 --- a/src/gromacs/mdlib/md_support.cpp +++ b/src/gromacs/mdlib/md_support.cpp @@ -283,7 +283,7 @@ void compute_globals(gmx_global_stat* gstat, * Use the box from last timestep since we already called update(). */ - enerd->term[F_PRES] = calc_pres(fr->ePBC, ir->nwall, lastbox, ekind->ekin, total_vir, pres); + enerd->term[F_PRES] = calc_pres(fr->pbcType, ir->nwall, lastbox, ekind->ekin, total_vir, pres); } /* ########## Long range energy information ###### */ @@ -520,7 +520,7 @@ void set_state_entries(t_state* state, const t_inputrec* ir) } state->nnhpres = 0; - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { state->flags |= (1 << estBOX); if (inputrecPreserveShape(ir)) diff --git a/src/gromacs/mdlib/membed.cpp b/src/gromacs/mdlib/membed.cpp index aa6ebecd6c..06266039e6 100644 --- a/src/gromacs/mdlib/membed.cpp +++ b/src/gromacs/mdlib/membed.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -1311,7 +1311,7 @@ gmx_membed_t* init_membed(FILE* fplog, /* remove overlapping lipids and water from the membrane box*/ /*mark molecules to be removed*/ snew(pbc, 1); - set_pbc(pbc, inputrec->ePBC, state->box); + set_pbc(pbc, inputrec->pbcType, state->box); snew(rm_p, 1); lip_rm = gen_rm_list(rm_p, ins_at, rest_at, pbc, mtop, state->x.rvec_array(), mem_p, diff --git a/src/gromacs/mdlib/nsgrid.cpp b/src/gromacs/mdlib/nsgrid.cpp index 82173e7edc..e9f7f0c973 100644 --- a/src/gromacs/mdlib/nsgrid.cpp +++ b/src/gromacs/mdlib/nsgrid.cpp @@ -364,9 +364,9 @@ t_grid* init_grid(FILE* fplog, t_forcerec* fr) snew(grid, 1); - grid->npbcdim = ePBC2npbcdim(fr->ePBC); + grid->npbcdim = numPbcDimensions(fr->pbcType); - if (fr->ePBC == epbcXY && fr->nwall == 2) + if (fr->pbcType == PbcType::XY && fr->nwall == 2) { grid->nboundeddim = 3; } diff --git a/src/gromacs/mdlib/qmmm.cpp b/src/gromacs/mdlib/qmmm.cpp index 07306e4aee..5de20a019e 100644 --- a/src/gromacs/mdlib/qmmm.cpp +++ b/src/gromacs/mdlib/qmmm.cpp @@ -615,7 +615,7 @@ void update_QMMMrec(const t_commrec* cr, const t_forcerec* fr, const rvec* x, co /* init_pbc(box); needs to be called first, see pbc.h */ ivec null_ivec; clear_ivec(null_ivec); - set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : null_ivec, FALSE, box); + set_pbc_dd(&pbc, fr->pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : null_ivec, FALSE, box); /* only in standard (normal) QMMM we need the neighbouring MM * particles to provide a electric field of point charges for the QM * atoms. diff --git a/src/gromacs/mdlib/settle.cpp b/src/gromacs/mdlib/settle.cpp index d381e65d2d..f8f183bd46 100644 --- a/src/gromacs/mdlib/settle.cpp +++ b/src/gromacs/mdlib/settle.cpp @@ -848,7 +848,7 @@ void csettle(settledata* settled, } else { - set_pbc(&pbcNo, epbcNONE, nullptr); + set_pbc(&pbcNo, PbcType::No, nullptr); pbcNonNull = &pbcNo; } diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 23f13f6611..934714a2a0 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -149,11 +149,11 @@ static void calc_virial(int start, const matrix box, t_nrnb* nrnb, const t_forcerec* fr, - int ePBC) + PbcType pbcType) { /* The short-range virial from surrounding boxes */ const rvec* fshift = as_rvec_array(forceWithShiftForces.shiftForces().data()); - calc_vir(SHIFTS, fr->shift_vec, fshift, vir_part, ePBC == epbcSCREW, box); + calc_vir(SHIFTS, fr->shift_vec, fshift, vir_part, pbcType == PbcType::Screw, box); inc_nrnb(nrnb, eNR_VIRIAL, SHIFTS); /* Calculate partial virial, for local atoms only, based on short range. @@ -188,7 +188,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->ePBC, box); + set_pbc(&pbc, ir->pbcType, box); dvdl = 0; enerd->term[F_COM_PULL] += pull_potential(pull_work, mdatoms, &pbc, cr, t, lambda[efptRESTRAINT], as_rvec_array(x.data()), force, &dvdl); @@ -294,7 +294,7 @@ static void post_process_forces(const t_commrec* cr, */ matrix virial = { { 0 } }; spread_vsite_f(vsite, x, fDirectVir, nullptr, stepWork.computeVirial, virial, nrnb, - &top->idef, fr->ePBC, fr->bMolPBC, graph, box, cr, wcycle); + &top->idef, fr->pbcType, fr->bMolPBC, graph, box, cr, wcycle); forceWithVirial.addVirialContribution(virial); } @@ -569,7 +569,7 @@ static void computeSpecialForces(FILE* fplog, if (awh) { enerd->term[F_COM_PULL] += awh->applyBiasForcesAndUpdateBias( - inputrec->ePBC, *mdatoms, box, forceWithVirial, t, step, wcycle, fplog); + inputrec->pbcType, *mdatoms, box, forceWithVirial, t, step, wcycle, fplog); } } @@ -981,7 +981,7 @@ void do_force(FILE* fplog, } } - if (fr->ePBC != epbcNONE) + if (fr->pbcType != PbcType::No) { /* Compute shift vectors every step, * because of pressure coupling or box deformation! @@ -995,7 +995,7 @@ void do_force(FILE* fplog, const bool calcCGCM = (fillGrid && !DOMAINDECOMP(cr)); if (calcCGCM) { - put_atoms_in_box_omp(fr->ePBC, box, x.unpaddedArrayRef().subArray(0, homenr), + put_atoms_in_box_omp(fr->pbcType, box, x.unpaddedArrayRef().subArray(0, homenr), gmx_omp_nthreads_get(emntDefault)); inc_nrnb(nrnb, eNR_SHIFTX, homenr); } @@ -1108,7 +1108,7 @@ void do_force(FILE* fplog, if (graph && stepWork.stateChanged) { /* Calculate intramolecular shift vectors to make molecules whole */ - mk_mshift(fplog, graph, fr->ePBC, box, as_rvec_array(x.unpaddedArrayRef().data())); + mk_mshift(fplog, graph, fr->pbcType, box, as_rvec_array(x.unpaddedArrayRef().data())); } // TODO @@ -1788,15 +1788,16 @@ void do_force(FILE* fplog, if (vsite && !(fr->haveDirectVirialContributions && !stepWork.computeVirial)) { rvec* fshift = as_rvec_array(forceOut.forceWithShiftForces().shiftForces().data()); - spread_vsite_f(vsite, as_rvec_array(x.unpaddedArrayRef().data()), f, fshift, FALSE, - nullptr, nrnb, &top->idef, fr->ePBC, fr->bMolPBC, graph, box, cr, wcycle); + spread_vsite_f(vsite, as_rvec_array(x.unpaddedArrayRef().data()), f, fshift, FALSE, nullptr, + nrnb, &top->idef, fr->pbcType, fr->bMolPBC, graph, box, cr, wcycle); } if (stepWork.computeVirial) { /* Calculation of the virial must be done after vsites! */ calc_virial(0, mdatoms->homenr, as_rvec_array(x.unpaddedArrayRef().data()), - forceOut.forceWithShiftForces(), vir_force, graph, box, nrnb, fr, inputrec->ePBC); + forceOut.forceWithShiftForces(), vir_force, graph, box, nrnb, fr, + inputrec->pbcType); } } diff --git a/src/gromacs/mdlib/tests/constr.cpp b/src/gromacs/mdlib/tests/constr.cpp index 5883fd9261..5316e0c849 100644 --- a/src/gromacs/mdlib/tests/constr.cpp +++ b/src/gromacs/mdlib/tests/constr.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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,12 +138,12 @@ public: // Infinitely small box matrix boxNone = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; - set_pbc(&pbc, epbcNONE, boxNone); + set_pbc(&pbc, PbcType::No, boxNone); pbcs_["PBCNone"] = pbc; // Rectangular box matrix boxXyz = { { 10.0, 0.0, 0.0 }, { 0.0, 20.0, 0.0 }, { 0.0, 0.0, 15.0 } }; - set_pbc(&pbc, epbcXYZ, boxXyz); + set_pbc(&pbc, PbcType::Xyz, boxXyz); pbcs_["PBCXYZ"] = pbc; // @@ -178,7 +178,7 @@ public: int j = testData.constraints_.at(3 * c + 2); RVec xij0, xij1; real d0, d1; - if (pbc.ePBC == epbcXYZ) + if (pbc.pbcType == PbcType::Xyz) { pbc_dx_aiuc(&pbc, testData.x_[i], testData.x_[j], xij0); pbc_dx_aiuc(&pbc, testData.xPrime_[i], testData.xPrime_[j], xij1); @@ -216,7 +216,7 @@ public: int i = testData.constraints_.at(3 * c + 1); int j = testData.constraints_.at(3 * c + 2); RVec xij0, xij1; - if (pbc.ePBC == epbcXYZ) + if (pbc.pbcType == PbcType::Xyz) { pbc_dx_aiuc(&pbc, testData.x_[i], testData.x_[j], xij0); pbc_dx_aiuc(&pbc, testData.xPrime_[i], testData.xPrime_[j], xij1); diff --git a/src/gromacs/mdlib/tests/settle.cpp b/src/gromacs/mdlib/tests/settle.cpp index a97a131572..bc7025c5b1 100644 --- a/src/gromacs/mdlib/tests/settle.cpp +++ b/src/gromacs/mdlib/tests/settle.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2014,2015,2016,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2014,2015,2016,2018,2019,2020, 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. @@ -169,12 +169,12 @@ public: // Infinitely small box matrix boxNone = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; - set_pbc(&pbc, epbcNONE, boxNone); + set_pbc(&pbc, PbcType::No, boxNone); pbcs_["PBCNone"] = pbc; // Rectangular box matrix boxXyz = { { real(1.86206), 0, 0 }, { 0, real(1.86206), 0 }, { 0, 0, real(1.86206) } }; - set_pbc(&pbc, epbcXYZ, boxXyz); + set_pbc(&pbc, PbcType::Xyz, boxXyz); pbcs_["PBCXYZ"] = pbc; // diff --git a/src/gromacs/mdlib/trajectory_writing.cpp b/src/gromacs/mdlib/trajectory_writing.cpp index 225c8844e1..9c87f46c4c 100644 --- a/src/gromacs/mdlib/trajectory_writing.cpp +++ b/src/gromacs/mdlib/trajectory_writing.cpp @@ -194,10 +194,10 @@ void do_md_trajectory_writing(FILE* fplog, if (fr->bMolPBC && !ir->bPeriodicMols) { /* Make molecules whole only for confout writing */ - do_pbc_mtop(ir->ePBC, 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, - x_for_confout, state_global->v.rvec_array(), ir->ePBC, state->box); + x_for_confout, state_global->v.rvec_array(), ir->pbcType, state->box); if (fr->bMolPBC && state == state_global) { sfree(x_for_confout); diff --git a/src/gromacs/mdlib/update.h b/src/gromacs/mdlib/update.h index 86632a604a..5b9607b2aa 100644 --- a/src/gromacs/mdlib/update.h +++ b/src/gromacs/mdlib/update.h @@ -50,6 +50,7 @@ class ekinstate_t; struct gmx_ekindata_t; struct gmx_enerdata_t; +enum class PbcType; struct t_extmass; struct t_fcdata; struct t_graph; @@ -294,7 +295,7 @@ void update_annealing_target_temp(t_inputrec* ir, real t, gmx::Update* upd); real calc_temp(real ekin, real nrdf); /* Calculate the temperature */ -real calc_pres(int ePBC, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres); +real calc_pres(PbcType pbcType, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres); /* Calculate the pressure tensor, returns the scalar pressure. * The unit of pressure is bar. */ diff --git a/src/gromacs/mdlib/vcm.cpp b/src/gromacs/mdlib/vcm.cpp index a2d998d8ae..b6997b6e08 100644 --- a/src/gromacs/mdlib/vcm.cpp +++ b/src/gromacs/mdlib/vcm.cpp @@ -64,7 +64,8 @@ t_vcm::t_vcm(const SimulationGroups& groups, const t_inputrec& ir) : if (mode == ecmANGULAR && ndim < 3) { - gmx_fatal(FARGS, "Can not have angular comm removal with pbc=%s", epbc_names[ir.ePBC]); + gmx_fatal(FARGS, "Can not have angular comm removal with pbc=%s", + c_pbcTypeNames[ir.pbcType].c_str()); } if (mode != ecmNO) diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index a2b7f73659..5d8d19ef21 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -615,7 +615,7 @@ void construct_vsites(const gmx_vsite_t* vsite, rvec* v, const t_iparams ip[], const t_ilist ilist[], - int ePBC, + PbcType pbcType, gmx_bool bMolPBC, const t_commrec* cr, const matrix box) @@ -624,7 +624,7 @@ void construct_vsites(const gmx_vsite_t* vsite, GMX_ASSERT(!useDomdec || (cr != nullptr && DOMAINDECOMP(cr)), "When vsites are set up with domain decomposition, we need a valid commrec"); // TODO: Remove this assertion when we remove charge groups - GMX_ASSERT(vsite != nullptr || ePBC == epbcNONE, + GMX_ASSERT(vsite != nullptr || pbcType == PbcType::No, "Without a vsite struct we can not do PBC (in case we have charge groups)"); t_pbc pbc, *pbc_null; @@ -634,7 +634,7 @@ void construct_vsites(const gmx_vsite_t* vsite, * when we have at least 3 domains along each dimension. Currently we * do not optimize this case. */ - if (ePBC != epbcNONE && (useDomdec || bMolPBC) + if (pbcType != PbcType::No && (useDomdec || bMolPBC) && !(vsite != nullptr && vsite->numInterUpdategroupVsites == 0)) { /* This is wasting some CPU time as we now do this multiple times @@ -642,7 +642,7 @@ void construct_vsites(const gmx_vsite_t* vsite, */ ivec null_ivec; clear_ivec(null_ivec); - pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->numCells : null_ivec, FALSE, box); + pbc_null = set_pbc_dd(&pbc, pbcType, useDomdec ? cr->dd->numCells : null_ivec, FALSE, box); } else { @@ -762,7 +762,7 @@ void constructVsitesGlobal(const gmx_mtop_t& mtop, gmx::ArrayRef x) } construct_vsites(nullptr, as_rvec_array(x.data()) + atomOffset, 0.0, nullptr, - mtop.ffparams.iparams.data(), ilist, epbcNONE, TRUE, nullptr, nullptr); + mtop.ffparams.iparams.data(), ilist, PbcType::No, TRUE, nullptr, nullptr); atomOffset += molt.atoms.nr; } } @@ -1729,7 +1729,7 @@ void spread_vsite_f(const gmx_vsite_t* vsite, matrix vir, t_nrnb* nrnb, const t_idef* idef, - int ePBC, + PbcType pbcType, gmx_bool bMolPBC, const t_graph* g, const matrix box, @@ -1749,7 +1749,7 @@ void spread_vsite_f(const gmx_vsite_t* vsite, /* This is wasting some CPU time as we now do this multiple times * per MD step. */ - pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->numCells : nullptr, FALSE, box); + pbc_null = set_pbc_dd(&pbc, pbcType, useDomdec ? cr->dd->numCells : nullptr, FALSE, box); } else { diff --git a/src/gromacs/mdlib/vsite.h b/src/gromacs/mdlib/vsite.h index 84e33aaa88..8069b6250c 100644 --- a/src/gromacs/mdlib/vsite.h +++ b/src/gromacs/mdlib/vsite.h @@ -56,6 +56,7 @@ struct t_mdatoms; struct t_nrnb; struct gmx_wallcycle; struct VsiteThread; +enum class PbcType : int; namespace gmx { @@ -91,11 +92,16 @@ struct gmx_vsite_t /*! \brief Create positions of vsite atoms based for the local system * * \param[in] vsite The vsite struct, when nullptr is passed, no MPI and no multi-threading - * is used \param[in,out] x The coordinates \param[in] dt The time step \param[in,out] - * v When != nullptr, velocities for vsites are set as displacement/dt \param[in] ip - * Interaction parameters \param[in] ilist The interaction list \param[in] ePBC The - * type of periodic boundary conditions \param[in] bMolPBC When true, molecules are broken over - * PBC \param[in] cr The communication record \param[in] box The box + * is used + * \param[in,out] x The coordinates + * \param[in] dt The time step + * \param[in,out] v When != nullptr, velocities for vsites are set as displacement/dt + * \param[in] ip Interaction parameters + * \param[in] ilist The interaction list + * \param[in] pbcType The type of periodic boundary conditions + * \param[in] bMolPBC When true, molecules are broken over PBC + * \param[in] cr The communication record + * \param[in] box The box */ void construct_vsites(const gmx_vsite_t* vsite, rvec x[], @@ -103,7 +109,7 @@ void construct_vsites(const gmx_vsite_t* vsite, rvec v[], const t_iparams ip[], const t_ilist ilist[], - int ePBC, + PbcType pbcType, gmx_bool bMolPBC, const t_commrec* cr, const matrix box); @@ -123,7 +129,7 @@ void spread_vsite_f(const gmx_vsite_t* vsite, matrix vir, t_nrnb* nrnb, const t_idef* idef, - int ePBC, + PbcType pbcType, gmx_bool bMolPBC, const t_graph* g, const matrix box, diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index 15cf25ac1d..f7d0e0f644 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -371,7 +371,7 @@ void gmx::LegacySimulator::do_md() *ir, *top_global, stateGpu->getUpdateStream(), stateGpu->xUpdatedOnDevice()); t_pbc pbc; - set_pbc(&pbc, epbcXYZ, state->box); + set_pbc(&pbc, PbcType::Xyz, state->box); integrator->setPbc(&pbc); } @@ -471,7 +471,7 @@ void gmx::LegacySimulator::do_md() { /* Construct the virtual sites for the initial configuration */ construct_vsites(vsite, state->x.rvec_array(), ir->delta_t, nullptr, top.idef.iparams, - top.idef.il, fr->ePBC, fr->bMolPBC, cr, state->box); + top.idef.il, fr->pbcType, fr->bMolPBC, cr, state->box); } } @@ -826,7 +826,7 @@ void gmx::LegacySimulator::do_md() if (useGpuForUpdate) { t_pbc pbc; - set_pbc(&pbc, epbcXYZ, state->box); + set_pbc(&pbc, PbcType::Xyz, state->box); integrator->setPbc(&pbc); } } @@ -1363,7 +1363,7 @@ void gmx::LegacySimulator::do_md() shift_self(graph, state->box, state->x.rvec_array()); } construct_vsites(vsite, state->x.rvec_array(), ir->delta_t, state->v.rvec_array(), - top.idef.iparams, top.idef.il, fr->ePBC, fr->bMolPBC, cr, state->box); + top.idef.iparams, top.idef.il, fr->pbcType, fr->bMolPBC, cr, state->box); if (graph != nullptr) { @@ -1456,7 +1456,7 @@ void gmx::LegacySimulator::do_md() { integrator->scaleCoordinates(pressureCouplingMu); t_pbc pbc; - set_pbc(&pbc, epbcXYZ, state->box); + set_pbc(&pbc, PbcType::Xyz, state->box); integrator->setPbc(&pbc); } diff --git a/src/gromacs/mdrun/mimic.cpp b/src/gromacs/mdrun/mimic.cpp index a934bdbffa..5430e6e83f 100644 --- a/src/gromacs/mdrun/mimic.cpp +++ b/src/gromacs/mdrun/mimic.cpp @@ -469,7 +469,7 @@ void gmx::LegacySimulator::do_mimic() } construct_vsites(vsite, as_rvec_array(state->x.data()), ir->delta_t, as_rvec_array(state->v.data()), top.idef.iparams, top.idef.il, - fr->ePBC, fr->bMolPBC, cr, state->box); + fr->pbcType, fr->bMolPBC, cr, state->box); if (graph != nullptr) { diff --git a/src/gromacs/mdrun/minimize.cpp b/src/gromacs/mdrun/minimize.cpp index 93cf1c19e1..593d432b37 100644 --- a/src/gromacs/mdrun/minimize.cpp +++ b/src/gromacs/mdrun/minimize.cpp @@ -554,14 +554,14 @@ static void write_em_traj(FILE* fplog, if (MASTER(cr)) { - if (ir->ePBC != epbcNONE && !ir->bPeriodicMols && DOMAINDECOMP(cr)) + if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && DOMAINDECOMP(cr)) { /* Make molecules whole only for confout writing */ - do_pbc_mtop(ir->ePBC, 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, - state_global->x.rvec_array(), nullptr, ir->ePBC, state->s.box); + state_global->x.rvec_array(), nullptr, ir->pbcType, state->s.box); } } } @@ -829,7 +829,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres, if (vsite) { construct_vsites(vsite, ems->s.x.rvec_array(), 1, nullptr, top->idef.iparams, top->idef.il, - fr->ePBC, fr->bMolPBC, cr, ems->s.box); + fr->pbcType, fr->bMolPBC, cr, ems->s.box); } if (DOMAINDECOMP(cr) && bNS) @@ -901,7 +901,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres, } clear_mat(ekin); - enerd->term[F_PRES] = calc_pres(fr->ePBC, inputrec->nwall, ems->s.box, ekin, vir, pres); + enerd->term[F_PRES] = calc_pres(fr->pbcType, inputrec->nwall, ems->s.box, ekin, vir, pres); sum_dhdl(enerd, ems->s.lambda, *inputrec->fepvals); @@ -1751,7 +1751,7 @@ void LegacySimulator::do_lbfgs() if (vsite) { construct_vsites(vsite, state_global->x.rvec_array(), 1, nullptr, top.idef.iparams, - top.idef.il, fr->ePBC, fr->bMolPBC, cr, state_global->box); + top.idef.il, fr->pbcType, fr->bMolPBC, cr, state_global->box); } /* Call the force routine and some auxiliary (neighboursearching etc.) */ diff --git a/src/gromacs/mdrun/rerun.cpp b/src/gromacs/mdrun/rerun.cpp index 6b57ab32cd..c5e3fcf0b2 100644 --- a/src/gromacs/mdrun/rerun.cpp +++ b/src/gromacs/mdrun/rerun.cpp @@ -173,11 +173,11 @@ static void prepareRerunState(const t_trxframe& rerunFrame, /* Following is necessary because the graph may get out of sync * with the coordinates if we only have every N'th coordinate set */ - mk_mshift(nullptr, graph, forceRec.ePBC, globalState->box, globalState->x.rvec_array()); + mk_mshift(nullptr, graph, forceRec.pbcType, globalState->box, globalState->x.rvec_array()); shift_self(graph, globalState->box, as_rvec_array(globalState->x.data())); } construct_vsites(vsite, globalState->x.rvec_array(), timeStep, globalState->v.rvec_array(), - idef.iparams, idef.il, forceRec.ePBC, forceRec.bMolPBC, nullptr, + idef.iparams, idef.il, forceRec.pbcType, forceRec.bMolPBC, nullptr, globalState->box); if (graph) { @@ -427,7 +427,7 @@ void gmx::LegacySimulator::do_rerun() rerun_fr.natoms, top_global->natoms); } - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { if (!rerun_fr.bBox) { @@ -437,7 +437,7 @@ void gmx::LegacySimulator::do_rerun() "does not contain a box, while pbc is used", rerun_fr.step, rerun_fr.time); } - if (max_cutoff2(ir->ePBC, rerun_fr.box) < gmx::square(fr->rlist)) + if (max_cutoff2(ir->pbcType, rerun_fr.box) < gmx::square(fr->rlist)) { gmx_fatal(FARGS, "Rerun trajectory frame step %" PRId64 @@ -459,7 +459,7 @@ void gmx::LegacySimulator::do_rerun() rerun_parallel_comm(cr, &rerun_fr, &isLastStep); } - if (ir->ePBC != epbcNONE) + if (ir->pbcType != PbcType::No) { /* Set the shift vectors. * Necessary here when have a static box different from the tpr box. @@ -601,7 +601,7 @@ void gmx::LegacySimulator::do_rerun() } construct_vsites(vsite, as_rvec_array(state->x.data()), ir->delta_t, as_rvec_array(state->v.data()), top.idef.iparams, top.idef.il, - fr->ePBC, fr->bMolPBC, cr, state->box); + fr->pbcType, fr->bMolPBC, cr, state->box); if (graph != nullptr) { diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index deb9c503dd..cf2d8a9663 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1131,7 +1131,7 @@ int Mdrunner::mdrunner() cr->npmenodes = 0; cr->duty = (DUTY_PP | DUTY_PME); - if (inputrec->ePBC == epbcSCREW) + if (inputrec->pbcType == PbcType::Screw) { gmx_fatal(FARGS, "pbc=screw is only implemented with domain decomposition"); } @@ -1335,7 +1335,7 @@ int Mdrunner::mdrunner() { mdModulesNotifier.notify(*cr); mdModulesNotifier.notify(&atomSets); - mdModulesNotifier.notify(PeriodicBoundaryConditionType{ inputrec->ePBC }); + mdModulesNotifier.notify(PeriodicBoundaryConditionType{ inputrec->pbcType }); mdModulesNotifier.notify(SimulationTimeStep{ inputrec->delta_t }); /* Initiate forcerecord */ fr = new t_forcerec; @@ -1390,12 +1390,13 @@ int Mdrunner::mdrunner() /* With periodic molecules the charge groups should be whole at start up * and the virtual sites should not be far from their proper positions. */ - if (!inputrec->bContinuation && MASTER(cr) && !(inputrec->ePBC != epbcNONE && inputrec->bPeriodicMols)) + if (!inputrec->bContinuation && MASTER(cr) + && !(inputrec->pbcType != PbcType::No && inputrec->bPeriodicMols)) { /* Make molecules whole at start of run */ - if (fr->ePBC != epbcNONE) + if (fr->pbcType != PbcType::No) { - do_pbc_first_mtop(fplog, inputrec->ePBC, box, &mtop, globalState->x.rvec_array()); + do_pbc_first_mtop(fplog, inputrec->pbcType, box, &mtop, globalState->x.rvec_array()); } if (vsite) { diff --git a/src/gromacs/mdrun/shellfc.cpp b/src/gromacs/mdrun/shellfc.cpp index 357dbe1c26..8f27d7f6ac 100644 --- a/src/gromacs/mdrun/shellfc.cpp +++ b/src/gromacs/mdrun/shellfc.cpp @@ -1062,19 +1062,19 @@ void relax_shell_flexcon(FILE* fplog, force[i] = forceWithPadding[i].paddedArrayRef(); } - if (bDoNS && inputrec->ePBC != epbcNONE && !DOMAINDECOMP(cr)) + if (bDoNS && inputrec->pbcType != PbcType::No && !DOMAINDECOMP(cr)) { /* This is the only time where the coordinates are used * before do_force is called, which normally puts all * charge groups in the box. */ auto xRef = x.paddedArrayRef(); - put_atoms_in_box_omp(fr->ePBC, box, xRef.subArray(0, md->homenr), + put_atoms_in_box_omp(fr->pbcType, box, xRef.subArray(0, md->homenr), gmx_omp_nthreads_get(emntDefault)); if (graph) { - mk_mshift(fplog, graph, fr->ePBC, box, xRvec); + mk_mshift(fplog, graph, fr->pbcType, box, xRvec); } } @@ -1192,7 +1192,7 @@ void relax_shell_flexcon(FILE* fplog, if (vsite) { construct_vsites(vsite, as_rvec_array(pos[Min].data()), inputrec->delta_t, vRvec, - idef->iparams, idef->il, fr->ePBC, fr->bMolPBC, cr, box); + idef->iparams, idef->il, fr->pbcType, fr->bMolPBC, cr, box); } if (nflexcon) diff --git a/src/gromacs/mdrun/tpi.cpp b/src/gromacs/mdrun/tpi.cpp index 4c808700fe..9b1dd8f7e6 100644 --- a/src/gromacs/mdrun/tpi.cpp +++ b/src/gromacs/mdrun/tpi.cpp @@ -245,7 +245,7 @@ void LegacySimulator::do_tpi() init_em(fplog,TPI,inputrec,&lambda,nrnb,mu_tot, state_global->box,fr,mdatoms,top,cr,nfile,fnm,NULL,NULL);*/ /* We never need full pbc for TPI */ - fr->ePBC = epbcXYZ; + fr->pbcType = PbcType::Xyz; /* Determine the temperature for the Boltzmann weighting */ temp = inputrec->opts.ref_t[0]; if (fplog) @@ -584,7 +584,7 @@ void LegacySimulator::do_tpi() bStateChanged = TRUE; bNS = TRUE; - put_atoms_in_box(fr->ePBC, box, x); + put_atoms_in_box(fr->pbcType, box, x); /* Put all atoms except for the inserted ones on the grid */ rvec vzero = { 0, 0, 0 }; @@ -878,7 +878,7 @@ void LegacySimulator::do_tpi() sprintf(str, "t%g_step%d.pdb", t, static_cast(step)); sprintf(str2, "t: %f step %d ener: %f", t, static_cast(step), epot); write_sto_conf_mtop(str, str2, top_global, state_global->x.rvec_array(), - state_global->v.rvec_array(), inputrec->ePBC, state_global->box); + state_global->v.rvec_array(), inputrec->pbcType, state_global->box); } step++; diff --git a/src/gromacs/mdtypes/forcerec.h b/src/gromacs/mdtypes/forcerec.h index 0ef5d43f1e..20ef5e32d0 100644 --- a/src/gromacs/mdtypes/forcerec.h +++ b/src/gromacs/mdtypes/forcerec.h @@ -45,6 +45,7 @@ #include "gromacs/math/vectypes.h" #include "gromacs/mdtypes/interaction_const.h" #include "gromacs/mdtypes/md_enums.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/utility/basedefinitions.h" #include "gromacs/utility/real.h" @@ -135,7 +136,7 @@ struct t_forcerec struct interaction_const_t* ic = nullptr; /* PBC stuff */ - int ePBC = 0; + PbcType pbcType = PbcType::Xyz; //! Tells whether atoms inside a molecule can be in different periodic images, // i.e. whether we need to take into account PBC when computing distances inside molecules. // This determines whether PBC must be considered for e.g. bonded interactions. diff --git a/src/gromacs/mdtypes/inputrec.cpp b/src/gromacs/mdtypes/inputrec.cpp index ec77f940f0..c7a4ea7096 100644 --- a/src/gromacs/mdtypes/inputrec.cpp +++ b/src/gromacs/mdtypes/inputrec.cpp @@ -854,7 +854,7 @@ void pr_inputrec(FILE* fp, int indent, const char* title, const t_inputrec* ir, /* Neighborsearching parameters */ PS("cutoff-scheme", ECUTSCHEME(ir->cutoff_scheme)); PI("nstlist", ir->nstlist); - PS("pbc", epbc_names[ir->ePBC]); + PS("pbc", c_pbcTypeNames[ir->pbcType].c_str()); PS("periodic-molecules", EBOOL(ir->bPeriodicMols)); PR("verlet-buffer-tolerance", ir->verletbuf_tol); PR("rlist", ir->rlist); @@ -1293,7 +1293,7 @@ void cmp_inputrec(FILE* fp, const t_inputrec* ir1, const t_inputrec* ir2, real f cmp_int64(fp, "inputrec->nsteps", ir1->nsteps, ir2->nsteps); cmp_int64(fp, "inputrec->init_step", ir1->init_step, ir2->init_step); cmp_int(fp, "inputrec->simulation_part", -1, ir1->simulation_part, ir2->simulation_part); - cmp_int(fp, "inputrec->ePBC", -1, ir1->ePBC, ir2->ePBC); + cmp_int(fp, "inputrec->pbcType", -1, static_cast(ir1->pbcType), static_cast(ir2->pbcType)); cmp_bool(fp, "inputrec->bPeriodicMols", -1, ir1->bPeriodicMols, ir2->bPeriodicMols); cmp_int(fp, "inputrec->cutoff_scheme", -1, ir1->cutoff_scheme, ir2->cutoff_scheme); cmp_int(fp, "inputrec->nstlist", -1, ir1->nstlist, ir2->nstlist); @@ -1486,7 +1486,7 @@ gmx_bool inputrecNphTrotter(const t_inputrec* ir) bool inputrecPbcXY2Walls(const t_inputrec* ir) { - return (ir->ePBC == epbcXY && ir->nwall == 2); + return (ir->pbcType == PbcType::XY && ir->nwall == 2); } bool integratorHasConservedEnergyQuantity(const t_inputrec* ir) @@ -1525,7 +1525,7 @@ int inputrec2nboundeddim(const t_inputrec* ir) } else { - return ePBC2npbcdim(ir->ePBC); + return numPbcDimensions(ir->pbcType); } } @@ -1533,12 +1533,12 @@ int ndof_com(const t_inputrec* ir) { int n = 0; - switch (ir->ePBC) + switch (ir->pbcType) { - case epbcXYZ: - case epbcNONE: n = 3; break; - case epbcXY: n = (ir->nwall == 0 ? 3 : 2); break; - case epbcSCREW: n = 1; break; + case PbcType::Xyz: + case PbcType::No: n = 3; break; + case PbcType::XY: n = (ir->nwall == 0 ? 3 : 2); break; + case PbcType::Screw: n = 1; break; default: gmx_incons("Unknown pbc in calc_nrdf"); } diff --git a/src/gromacs/mdtypes/inputrec.h b/src/gromacs/mdtypes/inputrec.h index bf1a003f4f..4659516b55 100644 --- a/src/gromacs/mdtypes/inputrec.h +++ b/src/gromacs/mdtypes/inputrec.h @@ -61,6 +61,8 @@ struct AwhParams; class KeyValueTreeObject; } // namespace gmx +enum class PbcType; + struct t_grpopts { //! Number of T-Coupl groups @@ -389,7 +391,7 @@ struct t_inputrec // NOLINT (clang-analyzer-optin.performance.Padding) //! Type of combination rule in LJ-PME int ljpme_combination_rule; //! Type of periodic boundary conditions - int ePBC; + PbcType pbcType; //! Periodic molecules bool bPeriodicMols; //! Continuation run: starting state is correct (ie. constrained) diff --git a/src/gromacs/modularsimulator/statepropagatordata.cpp b/src/gromacs/modularsimulator/statepropagatordata.cpp index c0ed27be68..0a02f40a0d 100644 --- a/src/gromacs/modularsimulator/statepropagatordata.cpp +++ b/src/gromacs/modularsimulator/statepropagatordata.cpp @@ -93,7 +93,7 @@ StatePropagatorData::StatePropagatorData(int numAtoms lastStep_(-1), canMoleculesBeDistributedOverPBC_(canMoleculesBeDistributedOverPBC), systemHasPeriodicMolecules_(inputrec->bPeriodicMols), - pbcType_(inputrec->ePBC), + pbcType_(inputrec->pbcType), topologyHolder_(topologyHolder), lastPlannedStep_(inputrec->nsteps + inputrec->init_step), writeFinalConfiguration_(writeFinalConfiguration), diff --git a/src/gromacs/modularsimulator/statepropagatordata.h b/src/gromacs/modularsimulator/statepropagatordata.h index 71a3d269f3..3236adf61c 100644 --- a/src/gromacs/modularsimulator/statepropagatordata.h +++ b/src/gromacs/modularsimulator/statepropagatordata.h @@ -50,6 +50,7 @@ #include "topologyholder.h" struct gmx_mdoutf; +enum class PbcType : int; struct t_commrec; struct t_inputrec; class t_state; @@ -272,7 +273,7 @@ private: //! Whether system has molecules self-interacting through PBC (used for final output only) const bool systemHasPeriodicMolecules_; //! The PBC type (used for final output only) - const int pbcType_; + const PbcType pbcType_; //! Pointer to the topology (used for final output only) const TopologyHolder* topologyHolder_; //! The (planned) last step - determines whether final configuration is written (used for final output only) diff --git a/src/gromacs/nbnxm/benchmark/bench_setup.cpp b/src/gromacs/nbnxm/benchmark/bench_setup.cpp index c2c2328f66..eb29b2092f 100644 --- a/src/gromacs/nbnxm/benchmark/bench_setup.cpp +++ b/src/gromacs/nbnxm/benchmark/bench_setup.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -184,13 +184,14 @@ static std::unique_ptr setupNbnxmForBenchInstance(const Kern PairlistParams pairlistParams(kernelSetup.kernelType, false, options.pairlistCutoff, false); - GridSet gridSet(epbcXYZ, false, nullptr, nullptr, pairlistParams.pairlistType, false, + GridSet gridSet(PbcType::Xyz, false, nullptr, nullptr, pairlistParams.pairlistType, false, numThreads, pinPolicy); auto pairlistSets = std::make_unique(pairlistParams, false, 0); - auto pairSearch = std::make_unique( - epbcXYZ, false, nullptr, nullptr, pairlistParams.pairlistType, false, numThreads, pinPolicy); + auto pairSearch = + std::make_unique(PbcType::Xyz, false, nullptr, nullptr, + pairlistParams.pairlistType, false, numThreads, pinPolicy); auto atomData = std::make_unique(pinPolicy); diff --git a/src/gromacs/nbnxm/benchmark/bench_system.cpp b/src/gromacs/nbnxm/benchmark/bench_system.cpp index bf2768b414..553f4cafd2 100644 --- a/src/gromacs/nbnxm/benchmark/bench_system.cpp +++ b/src/gromacs/nbnxm/benchmark/bench_system.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -158,7 +158,7 @@ BenchmarkSystem::BenchmarkSystem(const int multiplicationFactor) nonbondedParameters[1] = c12Oxygen; generateCoordinates(multiplicationFactor, &coordinates, box); - put_atoms_in_box(epbcXYZ, box, coordinates); + put_atoms_in_box(PbcType::Xyz, box, coordinates); int numAtoms = coordinates.size(); GMX_RELEASE_ASSERT(numAtoms % numAtomsInMolecule == 0, diff --git a/src/gromacs/nbnxm/gridset.cpp b/src/gromacs/nbnxm/gridset.cpp index f171317019..1adcff76a6 100644 --- a/src/gromacs/nbnxm/gridset.cpp +++ b/src/gromacs/nbnxm/gridset.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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,11 +78,11 @@ static int numGrids(const GridSet::DomainSetup& domainSetup) return numGrids; } -GridSet::DomainSetup::DomainSetup(const int ePBC, +GridSet::DomainSetup::DomainSetup(const PbcType pbcType, const bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* ddZones) : - ePBC(ePBC), + pbcType(pbcType), doTestParticleInsertion(doTestParticleInsertion), haveMultipleDomains(numDDCells != nullptr), zones(ddZones) @@ -93,7 +93,7 @@ GridSet::DomainSetup::DomainSetup(const int ePBC, } } -GridSet::GridSet(const int ePBC, +GridSet::GridSet(const PbcType pbcType, const bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* ddZones, @@ -101,7 +101,7 @@ GridSet::GridSet(const int ePBC, const bool haveFep, const int numThreads, gmx::PinningPolicy pinningPolicy) : - domainSetup_(ePBC, doTestParticleInsertion, numDDCells, ddZones), + domainSetup_(pbcType, doTestParticleInsertion, numDDCells, ddZones), grids_(numGrids(domainSetup_), Grid(pairlistType, haveFep_)), haveFep_(haveFep), numRealAtomsLocal_(0), diff --git a/src/gromacs/nbnxm/gridset.h b/src/gromacs/nbnxm/gridset.h index 3980a37c68..3e9ffe4c8a 100644 --- a/src/gromacs/nbnxm/gridset.h +++ b/src/gromacs/nbnxm/gridset.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -63,6 +63,7 @@ struct nbnxn_atomdata_t; enum class PairlistType; +enum class PbcType : int; namespace gmx { @@ -90,13 +91,13 @@ public: struct DomainSetup { //! Constructor, without DD \p numDDCells and \p ddZones should be nullptr - DomainSetup(int ePBC, + DomainSetup(PbcType pbcType, bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* ddZones); //! The type of PBC - int ePBC; + PbcType pbcType; //! Tells whether we are doing test-particle insertion bool doTestParticleInsertion; //! Are there multiple domains? @@ -108,7 +109,7 @@ public: }; //! Constructs a grid set for 1 or multiple DD zones, when numDDCells!=nullptr - GridSet(int ePBC, + GridSet(PbcType pbcType, bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* ddZones, diff --git a/src/gromacs/nbnxm/nbnxm_setup.cpp b/src/gromacs/nbnxm/nbnxm_setup.cpp index 686179accd..cb3a230929 100644 --- a/src/gromacs/nbnxm/nbnxm_setup.cpp +++ b/src/gromacs/nbnxm/nbnxm_setup.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -456,7 +456,7 @@ std::unique_ptr init_nb_verlet(const gmx::MDLogger& mdlo minimumIlistCountForGpuBalancing); auto pairSearch = std::make_unique( - ir->ePBC, EI_TPI(ir->eI), DOMAINDECOMP(cr) ? &cr->dd->numCells : nullptr, + ir->pbcType, EI_TPI(ir->eI), DOMAINDECOMP(cr) ? &cr->dd->numCells : nullptr, DOMAINDECOMP(cr) ? domdec_zones(cr->dd) : nullptr, pairlistParams.pairlistType, bFEP_NonBonded, gmx_omp_nthreads_get(emntPairsearch), pinPolicy); diff --git a/src/gromacs/nbnxm/pairlist.cpp b/src/gromacs/nbnxm/pairlist.cpp index c3e29ab205..955c0967e6 100644 --- a/src/gromacs/nbnxm/pairlist.cpp +++ b/src/gromacs/nbnxm/pairlist.cpp @@ -3173,7 +3173,7 @@ static void nbnxn_make_pairlist_part(const Nbnxm::GridSet& gridSet, /* Check if we need periodicity shifts. * Without PBC or with domain decomposition we don't need them. */ - if (d >= ePBC2npbcdim(gridSet.domainSetup().ePBC) + if (d >= numPbcDimensions(gridSet.domainSetup().pbcType) || gridSet.domainSetup().haveMultipleDomainsPerDim[d]) { shp[d] = 0; diff --git a/src/gromacs/nbnxm/pairlist_tuning.cpp b/src/gromacs/nbnxm/pairlist_tuning.cpp index c997ba8709..c1757d87a8 100644 --- a/src/gromacs/nbnxm/pairlist_tuning.cpp +++ b/src/gromacs/nbnxm/pairlist_tuning.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020, 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. @@ -280,7 +280,7 @@ void increaseNstlist(FILE* fp, rlist_new = calcVerletBufferSize(*mtop, det(box), *ir, ir->nstlist, ir->nstlist - 1, -1, listSetup); /* Does rlist fit in the box? */ - bBox = (gmx::square(rlist_new) < max_cutoff2(ir->ePBC, box)); + bBox = (gmx::square(rlist_new) < max_cutoff2(ir->pbcType, box)); bDD = TRUE; if (bBox && DOMAINDECOMP(cr)) { diff --git a/src/gromacs/nbnxm/pairsearch.cpp b/src/gromacs/nbnxm/pairsearch.cpp index fee162cbdc..34f064b2cc 100644 --- a/src/gromacs/nbnxm/pairsearch.cpp +++ b/src/gromacs/nbnxm/pairsearch.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -103,7 +103,7 @@ PairsearchWork::~PairsearchWork() free_nblist(nbl_fep.get()); } -PairSearch::PairSearch(const int ePBC, +PairSearch::PairSearch(const PbcType pbcType, const bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* ddZones, @@ -111,7 +111,7 @@ PairSearch::PairSearch(const int ePBC, const bool haveFep, const int maxNumThreads, gmx::PinningPolicy pinningPolicy) : - gridSet_(ePBC, doTestParticleInsertion, numDDCells, ddZones, pairlistType, haveFep, maxNumThreads, pinningPolicy), + gridSet_(pbcType, doTestParticleInsertion, numDDCells, ddZones, pairlistType, haveFep, maxNumThreads, pinningPolicy), work_(maxNumThreads) { cycleCounting_.recordCycles_ = (getenv("GMX_NBNXN_CYCLE") != nullptr); diff --git a/src/gromacs/nbnxm/pairsearch.h b/src/gromacs/nbnxm/pairsearch.h index c0cb647e71..4263d9ba5b 100644 --- a/src/gromacs/nbnxm/pairsearch.h +++ b/src/gromacs/nbnxm/pairsearch.h @@ -190,13 +190,13 @@ public: /* \brief Constructor * - * \param[in] ePBC The periodic boundary conditions + * \param[in] pbcType The periodic boundary conditions * \param[in] numDDCells The number of domain decomposition cells per dimension, without DD nullptr should be passed * \param[in] zones The domain decomposition zone setup, without DD nullptr should be passed * \param[in] haveFep Tells whether non-bonded interactions are perturbed * \param[in] maxNumThreads The maximum number of threads used in the search */ - PairSearch(int ePBC, + PairSearch(PbcType pbcType, bool doTestParticleInsertion, const ivec* numDDCells, const gmx_domdec_zones_t* zones, diff --git a/src/gromacs/pbcutil/mshift.cpp b/src/gromacs/pbcutil/mshift.cpp index 61797feacd..0bd4f8e73b 100644 --- a/src/gromacs/pbcutil/mshift.cpp +++ b/src/gromacs/pbcutil/mshift.cpp @@ -706,7 +706,7 @@ static int mk_grey(egCol egc[], t_graph* g, int* AtomI, int npbcdim, const matri { if (gmx_debug_at) { - set_pbc(&pbc, -1, box); + set_pbc(&pbc, PbcType::Unset, box); pbc_dx(&pbc, x[ai], x[aj], dx); fprintf(debug, "mk_grey: shifts for atom %d due to atom %d\n" @@ -740,11 +740,11 @@ static int first_colour(int fC, egCol Col, t_graph* g, const egCol egc[]) } /* Returns the maximum length of the graph edges for coordinates x */ -static real maxEdgeLength(const t_graph g, int ePBC, const matrix box, const rvec x[]) +static real maxEdgeLength(const t_graph g, PbcType pbcType, const matrix box, const rvec x[]) { t_pbc pbc; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); real maxEdgeLength2 = 0; @@ -762,7 +762,7 @@ static real maxEdgeLength(const t_graph g, int ePBC, const matrix box, const rve return std::sqrt(maxEdgeLength2); } -void mk_mshift(FILE* log, t_graph* g, int ePBC, const matrix box, const rvec x[]) +void mk_mshift(FILE* log, t_graph* g, PbcType pbcType, const matrix box, const rvec x[]) { static int nerror_tot = 0; int npbcdim; @@ -771,9 +771,9 @@ void mk_mshift(FILE* log, t_graph* g, int ePBC, const matrix box, const rvec x[] int fW, fG; /* First of each category */ int nerror = 0; - g->bScrewPBC = (ePBC == epbcSCREW); + g->bScrewPBC = (pbcType == PbcType::Screw); - if (ePBC == epbcXY) + if (pbcType == PbcType::XY) { npbcdim = 2; } @@ -870,14 +870,14 @@ void mk_mshift(FILE* log, t_graph* g, int ePBC, const matrix box, const rvec x[] */ constexpr real c_relativeDistanceThreshold = 0.25; - int numPbcDimensions = ePBC2npbcdim(ePBC); - GMX_RELEASE_ASSERT(numPbcDimensions > 0, "Expect PBC with graph"); + int npbcdim = numPbcDimensions(pbcType); + GMX_RELEASE_ASSERT(npbcdim > 0, "Expect PBC with graph"); real minBoxSize = norm(box[XX]); - for (int d = 1; d < numPbcDimensions; d++) + for (int d = 1; d < npbcdim; d++) { minBoxSize = std::min(minBoxSize, norm(box[d])); } - real maxDistance = maxEdgeLength(*g, ePBC, box, x); + real maxDistance = maxEdgeLength(*g, pbcType, box, x); if (maxDistance >= c_relativeDistanceThreshold * minBoxSize) { std::string mesg = gmx::formatString( diff --git a/src/gromacs/pbcutil/mshift.h b/src/gromacs/pbcutil/mshift.h index bc73a6db54..db37031723 100644 --- a/src/gromacs/pbcutil/mshift.h +++ b/src/gromacs/pbcutil/mshift.h @@ -46,6 +46,7 @@ struct InteractionList; struct gmx_moltype_t; struct t_idef; +enum class PbcType : int; typedef enum { @@ -103,7 +104,7 @@ void done_graph(t_graph* g); void p_graph(FILE* log, const char* title, t_graph* g); /* Print a graph to log */ -void mk_mshift(FILE* log, t_graph* g, int ePBC, const matrix box, const rvec x[]); +void mk_mshift(FILE* log, t_graph* g, PbcType pbcType, const matrix box, const rvec x[]); /* Calculate the mshift codes, based on the connection graph in g. */ void shift_x(const t_graph* g, const matrix box, const rvec x[], rvec x_s[]); diff --git a/src/gromacs/pbcutil/pbc.cpp b/src/gromacs/pbcutil/pbc.cpp index 03a9ac7f6b..0f7a21fc5e 100644 --- a/src/gromacs/pbcutil/pbc.cpp +++ b/src/gromacs/pbcutil/pbc.cpp @@ -63,7 +63,8 @@ #include "gromacs/utility/gmxassert.h" #include "gromacs/utility/smalloc.h" -const char* epbc_names[epbcNR + 1] = { "xyz", "no", "xy", "screw", nullptr }; +const gmx::EnumerationArray c_pbcTypeNames = { { "xyz", "no", "xy", "screw", + "unset" } }; /* Skip 0 so we have more chance of detecting if we forgot to call set_pbc. */ enum @@ -85,17 +86,20 @@ enum //! Margin correction if the box is too skewed #define BOX_MARGIN_CORRECT 1.0005 -int ePBC2npbcdim(int ePBC) +int numPbcDimensions(PbcType pbcType) { int npbcdim = 0; - switch (ePBC) + switch (pbcType) { - case epbcXYZ: npbcdim = 3; break; - case epbcXY: npbcdim = 2; break; - case epbcSCREW: npbcdim = 3; break; - case epbcNONE: npbcdim = 0; break; - default: gmx_fatal(FARGS, "Unknown ePBC=%d in ePBC2npbcdim", ePBC); + case PbcType::Unset: + gmx_fatal(FARGS, "Number of PBC dimensions was requested before the PBC type set."); + case PbcType::Xyz: npbcdim = 3; break; + case PbcType::XY: npbcdim = 2; break; + case PbcType::Screw: npbcdim = 3; break; + case PbcType::No: npbcdim = 0; break; + default: + gmx_fatal(FARGS, "Unknown pbcType=%s in numPbcDimensions", c_pbcTypeNames[pbcType].c_str()); } return npbcdim; @@ -105,7 +109,7 @@ void dump_pbc(FILE* fp, t_pbc* pbc) { rvec sum_box; - fprintf(fp, "ePBCDX = %d\n", pbc->ePBCDX); + fprintf(fp, "pbcTypeDX = %d\n", pbc->pbcTypeDX); pr_rvecs(fp, 0, "box", pbc->box, DIM); pr_rvecs(fp, 0, "fbox_diag", &pbc->fbox_diag, 1); pr_rvecs(fp, 0, "hbox_diag", &pbc->hbox_diag, 1); @@ -121,16 +125,16 @@ void dump_pbc(FILE* fp, t_pbc* pbc) } } -const char* check_box(int ePBC, const matrix box) +const char* check_box(PbcType pbcType, const matrix box) { const char* ptr; - if (ePBC == -1) + if (pbcType == PbcType::Unset) { - ePBC = guess_ePBC(box); + pbcType = guessPbcType(box); } - if (ePBC == epbcNONE) + if (pbcType == PbcType::No) { return nullptr; } @@ -140,12 +144,12 @@ const char* check_box(int ePBC, const matrix box) ptr = "Only triclinic boxes with the first vector parallel to the x-axis and the second " "vector in the xy-plane are supported."; } - else if (ePBC == epbcSCREW && (box[YY][XX] != 0 || box[ZZ][XX] != 0)) + else if (pbcType == PbcType::Screw && (box[YY][XX] != 0 || box[ZZ][XX] != 0)) { ptr = "The unit cell can not have off-diagonal x-components with screw pbc"; } else if (std::fabs(box[YY][XX]) > BOX_MARGIN * 0.5 * box[XX][XX] - || (ePBC != epbcXY + || (pbcType != PbcType::XY && (std::fabs(box[ZZ][XX]) > BOX_MARGIN * 0.5 * box[XX][XX] || std::fabs(box[ZZ][YY]) > BOX_MARGIN * 0.5 * box[YY][YY]))) { @@ -172,7 +176,7 @@ void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees) std::sqrt(gmx::square(vec[ZZ]) - box[ZZ][XX] * box[ZZ][XX] - box[ZZ][YY] * box[ZZ][YY]); } -real max_cutoff2(int ePBC, const matrix box) +real max_cutoff2(PbcType pbcType, const matrix box) { real min_hv2, min_ss; const real oneFourth = 0.25; @@ -181,7 +185,7 @@ real max_cutoff2(int ePBC, const matrix box) * by half the length of the shortest box vector. */ min_hv2 = oneFourth * std::min(norm2(box[XX]), norm2(box[YY])); - if (ePBC != epbcXY) + if (pbcType != PbcType::XY) { min_hv2 = std::min(min_hv2, oneFourth * norm2(box[ZZ])); } @@ -191,7 +195,7 @@ real max_cutoff2(int ePBC, const matrix box) * in the grid search and pbc_dx is a lot faster * than checking all possible combinations. */ - if (ePBC == epbcXY) + if (pbcType == PbcType::XY) { min_ss = std::min(box[XX][XX], box[YY][YY]); } @@ -206,21 +210,21 @@ real max_cutoff2(int ePBC, const matrix box) //! Set to true if warning has been printed static gmx_bool bWarnedGuess = FALSE; -int guess_ePBC(const matrix box) +PbcType guessPbcType(const matrix box) { - int ePBC; + PbcType pbcType; if (box[XX][XX] > 0 && box[YY][YY] > 0 && box[ZZ][ZZ] > 0) { - ePBC = epbcXYZ; + pbcType = PbcType::Xyz; } else if (box[XX][XX] > 0 && box[YY][YY] > 0 && box[ZZ][ZZ] == 0) { - ePBC = epbcXY; + pbcType = PbcType::XY; } else if (box[XX][XX] == 0 && box[YY][YY] == 0 && box[ZZ][ZZ] == 0) { - ePBC = epbcNONE; + pbcType = PbcType::No; } else { @@ -232,15 +236,15 @@ int guess_ePBC(const matrix box) box[XX][XX], box[YY][YY], box[ZZ][ZZ]); bWarnedGuess = TRUE; } - ePBC = epbcNONE; + pbcType = PbcType::No; } if (debug) { - fprintf(debug, "Guessed pbc = %s from the box matrix\n", epbc_names[ePBC]); + fprintf(debug, "Guessed pbc = %s from the box matrix\n", c_pbcTypeNames[pbcType].c_str()); } - return ePBC; + return pbcType; } //! Check if the box still obeys the restrictions, if not, correct it @@ -317,18 +321,18 @@ gmx_bool correct_box(FILE* fplog, int step, tensor box, t_graph* graph) } //! Do the real arithmetic for filling the pbc struct -static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix box) +static void low_set_pbc(t_pbc* pbc, PbcType pbcType, const ivec dd_pbc, const matrix box) { int order[3] = { 0, -1, 1 }; ivec bPBC; const char* ptr; - pbc->ePBC = ePBC; - pbc->ndim_ePBC = ePBC2npbcdim(ePBC); + pbc->pbcType = pbcType; + pbc->ndim_ePBC = numPbcDimensions(pbcType); - if (pbc->ePBC == epbcNONE) + if (pbc->pbcType == PbcType::No) { - pbc->ePBCDX = epbcdxNOPBC; + pbc->pbcTypeDX = epbcdxNOPBC; return; } @@ -345,17 +349,17 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo pbc->mhbox_diag[i] = -pbc->hbox_diag[i]; } - ptr = check_box(ePBC, box); + ptr = check_box(pbcType, box); if (ptr) { fprintf(stderr, "Warning: %s\n", ptr); pr_rvecs(stderr, 0, " Box", box, DIM); fprintf(stderr, " Can not fix pbc.\n\n"); - pbc->ePBCDX = epbcdxUNSUPPORTED; + pbc->pbcTypeDX = epbcdxUNSUPPORTED; } else { - if (ePBC == epbcSCREW && nullptr != dd_pbc) + if (pbcType == PbcType::Screw && nullptr != dd_pbc) { /* This combinated should never appear here */ gmx_incons("low_set_pbc called with screw pbc and dd_nc != NULL"); @@ -364,7 +368,7 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo int npbcdim = 0; for (int i = 0; i < DIM; i++) { - if ((dd_pbc && dd_pbc[i] == 0) || (ePBC == epbcXY && i == ZZ)) + if ((dd_pbc && dd_pbc[i] == 0) || (pbcType == PbcType::XY && i == ZZ)) { bPBC[i] = 0; } @@ -380,7 +384,7 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo /* 1D pbc is not an mdp option and it is therefore only used * with single shifts. */ - pbc->ePBCDX = epbcdx1D_RECT; + pbc->pbcTypeDX = epbcdx1D_RECT; for (int i = 0; i < DIM; i++) { if (bPBC[i]) @@ -393,12 +397,12 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo { if (pbc->box[pbc->dim][i] != 0) { - pbc->ePBCDX = epbcdx1D_TRIC; + pbc->pbcTypeDX = epbcdx1D_TRIC; } } break; case 2: - pbc->ePBCDX = epbcdx2D_RECT; + pbc->pbcTypeDX = epbcdx2D_RECT; for (int i = 0; i < DIM; i++) { if (!bPBC[i]) @@ -414,41 +418,42 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo { if (pbc->box[i][j] != 0) { - pbc->ePBCDX = epbcdx2D_TRIC; + pbc->pbcTypeDX = epbcdx2D_TRIC; } } } } break; case 3: - if (ePBC != epbcSCREW) + if (pbcType != PbcType::Screw) { if (TRICLINIC(box)) { - pbc->ePBCDX = epbcdxTRICLINIC; + pbc->pbcTypeDX = epbcdxTRICLINIC; } else { - pbc->ePBCDX = epbcdxRECTANGULAR; + pbc->pbcTypeDX = epbcdxRECTANGULAR; } } else { - pbc->ePBCDX = (box[ZZ][YY] == 0 ? epbcdxSCREW_RECT : epbcdxSCREW_TRIC); - if (pbc->ePBCDX == epbcdxSCREW_TRIC) + pbc->pbcTypeDX = (box[ZZ][YY] == 0 ? epbcdxSCREW_RECT : epbcdxSCREW_TRIC); + if (pbc->pbcTypeDX == epbcdxSCREW_TRIC) { fprintf(stderr, "Screw pbc is not yet implemented for triclinic boxes.\n" "Can not fix pbc.\n"); - pbc->ePBCDX = epbcdxUNSUPPORTED; + pbc->pbcTypeDX = epbcdxUNSUPPORTED; } } break; default: gmx_fatal(FARGS, "Incorrect number of pbc dimensions with DD: %d", npbcdim); } - pbc->max_cutoff2 = max_cutoff2(ePBC, box); + pbc->max_cutoff2 = max_cutoff2(pbcType, box); - if (pbc->ePBCDX == epbcdxTRICLINIC || pbc->ePBCDX == epbcdx2D_TRIC || pbc->ePBCDX == epbcdxSCREW_TRIC) + if (pbc->pbcTypeDX == epbcdxTRICLINIC || pbc->pbcTypeDX == epbcdx2D_TRIC + || pbc->pbcTypeDX == epbcdxSCREW_TRIC) { if (debug) { @@ -571,35 +576,35 @@ static void low_set_pbc(t_pbc* pbc, int ePBC, const ivec dd_pbc, const matrix bo } } -void set_pbc(t_pbc* pbc, int ePBC, const matrix box) +void set_pbc(t_pbc* pbc, PbcType pbcType, const matrix box) { - if (ePBC == -1) + if (pbcType == PbcType::Unset) { - ePBC = guess_ePBC(box); + pbcType = guessPbcType(box); } - low_set_pbc(pbc, ePBC, nullptr, box); + low_set_pbc(pbc, pbcType, nullptr, box); } -t_pbc* set_pbc_dd(t_pbc* pbc, int ePBC, const ivec domdecCells, gmx_bool bSingleDir, const matrix box) +t_pbc* set_pbc_dd(t_pbc* pbc, PbcType pbcType, const ivec domdecCells, gmx_bool bSingleDir, const matrix box) { - if (ePBC == epbcNONE) + if (pbcType == PbcType::No) { - pbc->ePBC = ePBC; + pbc->pbcType = pbcType; return nullptr; } if (nullptr == domdecCells) { - low_set_pbc(pbc, ePBC, nullptr, box); + low_set_pbc(pbc, pbcType, nullptr, box); } else { - if (ePBC == epbcSCREW && domdecCells[XX] > 1) + if (pbcType == PbcType::Screw && domdecCells[XX] > 1) { /* The rotation has been taken care of during coordinate communication */ - ePBC = epbcXYZ; + pbcType = PbcType::Xyz; } ivec usePBC; @@ -607,7 +612,7 @@ t_pbc* set_pbc_dd(t_pbc* pbc, int ePBC, const ivec domdecCells, gmx_bool bSingle for (int i = 0; i < DIM; i++) { usePBC[i] = 0; - if (domdecCells[i] <= (bSingleDir ? 1 : 2) && !(ePBC == epbcXY && i == ZZ)) + if (domdecCells[i] <= (bSingleDir ? 1 : 2) && !(pbcType == PbcType::XY && i == ZZ)) { usePBC[i] = 1; npbcdim++; @@ -616,15 +621,15 @@ t_pbc* set_pbc_dd(t_pbc* pbc, int ePBC, const ivec domdecCells, gmx_bool bSingle if (npbcdim > 0) { - low_set_pbc(pbc, ePBC, usePBC, box); + low_set_pbc(pbc, pbcType, usePBC, box); } else { - pbc->ePBC = epbcNONE; + pbc->pbcType = PbcType::No; } } - return (pbc->ePBC != epbcNONE ? pbc : nullptr); + return (pbc->pbcType != PbcType::No ? pbc : nullptr); } void pbc_dx(const t_pbc* pbc, const rvec x1, const rvec x2, rvec dx) @@ -636,7 +641,7 @@ void pbc_dx(const t_pbc* pbc, const rvec x1, const rvec x2, rvec dx) rvec_sub(x1, x2, dx); - switch (pbc->ePBCDX) + switch (pbc->pbcTypeDX) { case epbcdxRECTANGULAR: for (i = 0; i < DIM; i++) @@ -807,7 +812,7 @@ int pbc_dx_aiuc(const t_pbc* pbc, const rvec x1, const rvec x2, rvec dx) rvec_sub(x1, x2, dx); clear_ivec(ishift); - switch (pbc->ePBCDX) + switch (pbc->pbcTypeDX) { case epbcdxRECTANGULAR: for (i = 0; i < DIM; i++) @@ -1079,7 +1084,7 @@ void pbc_dx_d(const t_pbc* pbc, const dvec x1, const dvec x2, dvec dx) dvec_sub(x1, x2, dx); - switch (pbc->ePBCDX) + switch (pbc->pbcTypeDX) { case epbcdxRECTANGULAR: case epbcdx2D_RECT: @@ -1392,16 +1397,16 @@ int* compact_unitcell_edges() return edge; } -void put_atoms_in_box(int ePBC, const matrix box, gmx::ArrayRef x) +void put_atoms_in_box(PbcType pbcType, const matrix box, gmx::ArrayRef x) { int npbcdim, m, d; - if (ePBC == epbcSCREW) + if (pbcType == PbcType::Screw) { - gmx_fatal(FARGS, "Sorry, %s pbc is not yet supported", epbc_names[ePBC]); + gmx_fatal(FARGS, "Sorry, %s pbc is not yet supported", c_pbcTypeNames[pbcType].c_str()); } - if (ePBC == epbcXY) + if (pbcType == PbcType::XY) { npbcdim = 2; } @@ -1452,7 +1457,7 @@ void put_atoms_in_box(int ePBC, const matrix box, gmx::ArrayRef x) } } -void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef x, gmx_unused int nth) +void put_atoms_in_box_omp(PbcType pbcType, const matrix box, gmx::ArrayRef x, gmx_unused int nth) { #pragma omp parallel for num_threads(nth) schedule(static) for (int t = 0; t < nth; t++) @@ -1462,7 +1467,7 @@ void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef x size_t natoms = x.size(); size_t offset = (natoms * t) / nth; size_t len = (natoms * (t + 1)) / nth - offset; - put_atoms_in_box(ePBC, box, x.subArray(offset, len)); + put_atoms_in_box(pbcType, box, x.subArray(offset, len)); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR } @@ -1525,14 +1530,14 @@ void put_atoms_in_triclinic_unitcell(int ecenter, const matrix box, gmx::ArrayRe } } -void put_atoms_in_compact_unitcell(int ePBC, int ecenter, const matrix box, gmx::ArrayRef x) +void put_atoms_in_compact_unitcell(PbcType pbcType, int ecenter, const matrix box, gmx::ArrayRef x) { t_pbc pbc; rvec box_center, dx; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); - if (pbc.ePBCDX == epbcdxUNSUPPORTED) + if (pbc.pbcTypeDX == epbcdxUNSUPPORTED) { gmx_fatal(FARGS, "Can not put atoms in compact unitcell with unsupported PBC"); } @@ -1548,13 +1553,14 @@ void put_atoms_in_compact_unitcell(int ePBC, int ecenter, const matrix box, gmx: /*! \brief Make molecules whole by shifting positions * * \param[in] fplog Log file - * \param[in] ePBC The PBC type + * \param[in] pbcType The PBC type * \param[in] box The simulation box * \param[in] mtop System topology definition * \param[in,out] x The coordinates of the atoms * \param[in] bFirst Specifier for first-time PBC removal */ -static void low_do_pbc_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[], gmx_bool bFirst) +static void +low_do_pbc_mtop(FILE* fplog, PbcType pbcType, const matrix box, const gmx_mtop_t* mtop, rvec x[], gmx_bool bFirst) { t_graph* graph; int as, mol; @@ -1580,7 +1586,7 @@ static void low_do_pbc_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_m for (mol = 0; mol < molb.nmol; mol++) { - mk_mshift(fplog, graph, ePBC, box, x + as); + mk_mshift(fplog, graph, pbcType, box, x + as); shift_self(graph, box, x + as); /* The molecule is whole now. @@ -1596,12 +1602,12 @@ static void low_do_pbc_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_m sfree(graph); } -void do_pbc_first_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[]) +void do_pbc_first_mtop(FILE* fplog, PbcType pbcType, const matrix box, const gmx_mtop_t* mtop, rvec x[]) { - low_do_pbc_mtop(fplog, ePBC, box, mtop, x, TRUE); + low_do_pbc_mtop(fplog, pbcType, box, mtop, x, TRUE); } -void do_pbc_mtop(int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[]) +void do_pbc_mtop(PbcType pbcType, const matrix box, const gmx_mtop_t* mtop, rvec x[]) { - low_do_pbc_mtop(nullptr, ePBC, box, mtop, x, FALSE); + low_do_pbc_mtop(nullptr, pbcType, box, mtop, x, FALSE); } diff --git a/src/gromacs/pbcutil/pbc.h b/src/gromacs/pbcutil/pbc.h index 38feb1d64c..d7c50ff432 100644 --- a/src/gromacs/pbcutil/pbc.h +++ b/src/gromacs/pbcutil/pbc.h @@ -40,25 +40,30 @@ #include +#include + #include "gromacs/math/vectypes.h" #include "gromacs/utility/arrayref.h" #include "gromacs/utility/basedefinitions.h" +#include "gromacs/utility/enumerationhelpers.h" #include "gromacs/utility/real.h" struct gmx_domdec_t; struct gmx_mtop_t; -enum +//! Enumeration that contains all supported periodic boundary setups. +enum class PbcType : int { - epbcXYZ, - epbcNONE, - epbcXY, - epbcSCREW, - epbcNR + Xyz = 0, //!< Periodic boundaries in all dimensions. + No = 1, //!< No periodic boundaries. + XY = 2, //!< Only two dimensions are periodic. + Screw = 3, //!< Screw. + Unset = 4, //!< The type of PBC is not set or invalid. + Count = 5 }; -//! Strings corresponding to epbc enum values. -extern const char* epbc_names[epbcNR + 1]; +//! Names for all values in PBC types enumeration +extern const gmx::EnumerationArray c_pbcTypeNames; /* Maximum number of combinations of single triclinic box vectors * required to shift atoms that are within a brick of the size of @@ -70,16 +75,16 @@ extern const char* epbc_names[epbcNR + 1]; typedef struct t_pbc { //! The PBC type - int ePBC; + PbcType pbcType; //! Number of dimensions in which PBC is exerted int ndim_ePBC; /*! \brief Determines how to compute distance vectors. * * Indicator of how to compute distance vectors, depending - * on PBC type (depends on ePBC and dimensions with(out) DD) + * on PBC type (depends on pbcType and dimensions with(out) DD) * and the box angles. */ - int ePBCDX; + int pbcTypeDX; /*! \brief Used for selecting which dimensions to use in PBC. * * In case of 1-D PBC this indicates which dimension is used, @@ -131,10 +136,10 @@ struct t_graph; /*! \brief Returns the number of dimensions that use pbc * - * \param[in] ePBC The periodic boundary condition type + * \param[in] pbcType The periodic boundary condition type * \return the number of dimensions that use pbc, starting at X */ -int ePBC2npbcdim(int ePBC); +int numPbcDimensions(PbcType pbcType); /*! \brief Dump the contents of the pbc structure to the file * @@ -145,17 +150,18 @@ void dump_pbc(FILE* fp, t_pbc* pbc); /*! \brief Check the box for consistency * - * \param[in] ePBC The pbc identifier - * \param[in] box The box matrix + * When \p pbcType=PbcTypes::Unset, the type of pbc is guessed from the box matrix. + * + * \param[in] pbcType The pbc identifier + * \param[in] box The box matrix * \return NULL if the box is supported by Gromacs. - * Otherwise returns a string with the problem. - * When ePBC=-1, the type of pbc is guessed from the box matrix. + * Otherwise returns a string with the problem. */ -const char* check_box(int ePBC, const matrix box); +const char* check_box(PbcType pbcType, const matrix box); /*! \brief Creates box matrix from edge lengths and angles. * - * \param[in,out] box The box matrix + * \param[in,out] box The box matrix * \param[in] vec The edge lengths * \param[in] angleInDegrees The angles */ @@ -166,24 +172,27 @@ void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees); * Returns the square of the maximum cut-off allowed for the box, * taking into account that the grid neighborsearch code and pbc_dx * only check combinations of single box-vector shifts. - * \param[in] ePBC The pbc identifier + * + * \param[in] pbcType The pbc identifier * \param[in] box The box matrix * \return the maximum cut-off. */ -real max_cutoff2(int ePBC, const matrix box); +real max_cutoff2(PbcType pbcType, const matrix box); -/*! \brief Guess PBC typr +/*! \brief Guess PBC type * * Guesses the type of periodic boundary conditions using the box + * * \param[in] box The box matrix - * \return The pbc identifier + * \return The pbc type identifier */ -int guess_ePBC(const matrix box); +PbcType guessPbcType(const matrix box); /*! \brief Corrects the box if necessary * * Checks for un-allowed box angles and corrects the box - * and the integer shift vectors in the graph (if graph!=NULL) if necessary. + * and the integer shift vectors in the graph (if \p graph!=NULL) if necessary. + * * \param[in] fplog File for debug output * \param[in] step The MD step number * \param[in] box The simulation cell @@ -196,12 +205,13 @@ gmx_bool correct_box(FILE* fplog, int step, tensor box, struct t_graph* graph); * * pbc_dx will not use pbc and return the normal difference vector * when one or more of the diagonal elements of box are zero. - * When ePBC=-1, the type of pbc is guessed from the box matrix. + * When \p pbcType=PbcType::Unset, the type of pbc is guessed from the box matrix. + * * \param[in,out] pbc The pbc information structure - * \param[in] ePBC The PBC identifier - * \param[in] box The box tensor + * \param[in] pbcType The PBC identifier + * \param[in] box The box tensor */ -void set_pbc(t_pbc* pbc, int ePBC, const matrix box); +void set_pbc(t_pbc* pbc, PbcType pbcType, const matrix box); /*! \brief Initiate the periodic boundary condition algorithms. * @@ -211,17 +221,18 @@ void set_pbc(t_pbc* pbc, int ePBC, const matrix box); * If domdecCells!=NULL pbc is not used for directions * with dd->nc[i]==1 with bSingleDir==TRUE or * with dd->nc[i]<=2 with bSingleDir==FALSE. - * Note that when no PBC is required only pbc->ePBC is set, + * Note that when no PBC is required only pbc->pbcType is set, * the rest of the struct will be invalid. - * \param[in,out] pbc The pbc information structure - * \param[in] ePBC The PBC identifier + * + * \param[in,out] pbc The pbc information structure + * \param[in] pbcType The PBC identifier * \param[in] domdecCells 3D integer vector describing the number of DD cells * or nullptr if not using DD. * \param[in] bSingleDir TRUE if DD communicates only in one direction along dimensions * \param[in] box The box tensor * \return the pbc structure when pbc operations are required, NULL otherwise. */ -t_pbc* set_pbc_dd(t_pbc* pbc, int ePBC, const ivec domdecCells, gmx_bool bSingleDir, const matrix box); +t_pbc* set_pbc_dd(t_pbc* pbc, PbcType pbcType, const ivec domdecCells, gmx_bool bSingleDir, const matrix box); /*! \brief Compute distance with PBC * @@ -311,23 +322,25 @@ int* compact_unitcell_edges(); * These routines puts ONE or ALL atoms in the box, not caring * about charge groups! * Also works for triclinic cells. - * \param[in] ePBC The pbc type - * \param[in] box The simulation box - * \param[in,out] x The coordinates of the atoms + * + * \param[in] pbcType The pbc type + * \param[in] box The simulation box + * \param[in,out] x The coordinates of the atoms */ -void put_atoms_in_box(int ePBC, const matrix box, gmx::ArrayRef x); +void put_atoms_in_box(PbcType pbcType, const matrix box, gmx::ArrayRef x); /*! \brief Parallellizes put_atoms_in_box() * * This wrapper function around put_atoms_in_box() with the ugly manual * workload splitting is needed to avoid silently introducing multithreading * in tools. - * \param[in] ePBC The pbc type + * + * \param[in] pbcType The pbc type * \param[in] box The simulation box * \param[in,out] x The coordinates of the atoms * \param[in] nth number of threads to be used in the given module */ -void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef x, gmx_unused int nth); +void put_atoms_in_box_omp(PbcType pbcType, const matrix box, gmx::ArrayRef x, gmx_unused int nth); /*! \brief Put atoms inside triclinic box * @@ -343,31 +356,32 @@ void put_atoms_in_triclinic_unitcell(int ecenter, const matrix box, gmx::ArrayRe * * This puts ALL atoms at the closest distance for the center of the box * as calculated by calc_box_center. - * When ePBC=-1, the type of pbc is guessed from the box matrix. - * \param[in] ePBC The pbc type + * When \p pbcType=PbcType::Unset, the type of pbc is guessed from the box matrix. + * + * \param[in] pbcType The pbc type * \param[in] ecenter The pbc center type * \param[in] box The simulation box - * \param[in,out] x The coordinates of the atoms + * \param[in,out] x The coordinates of the atoms */ -void put_atoms_in_compact_unitcell(int ePBC, int ecenter, const matrix box, gmx::ArrayRef x); +void put_atoms_in_compact_unitcell(PbcType pbcType, int ecenter, const matrix box, gmx::ArrayRef x); /*! \brief Make all molecules whole by shifting positions * * \param[in] fplog Log file - * \param[in] ePBC The PBC type + * \param[in] pbcType The PBC type * \param[in] box The simulation box * \param[in] mtop System topology definition * \param[in,out] x The coordinates of the atoms */ -void do_pbc_first_mtop(FILE* fplog, int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[]); +void do_pbc_first_mtop(FILE* fplog, PbcType pbcType, const matrix box, const gmx_mtop_t* mtop, rvec x[]); /*! \brief Make molecules consisting of multiple charge groups whole by shifting positions * - * \param[in] ePBC The PBC type + * \param[in] pbcType The PBC type * \param[in] box The simulation box * \param[in] mtop System topology definition * \param[in,out] x The coordinates of the atoms */ -void do_pbc_mtop(int ePBC, const matrix box, const gmx_mtop_t* mtop, rvec x[]); +void do_pbc_mtop(PbcType pbcType, const matrix box, const gmx_mtop_t* mtop, rvec x[]); #endif diff --git a/src/gromacs/pbcutil/pbc_simd.cpp b/src/gromacs/pbcutil/pbc_simd.cpp index d27661821c..fa824891a7 100644 --- a/src/gromacs/pbcutil/pbc_simd.cpp +++ b/src/gromacs/pbcutil/pbc_simd.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2019,2020, 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 @@ using namespace gmx; // TODO: Remove when this file is moved into gmx namespace void set_pbc_simd(const t_pbc gmx_unused* pbc, real gmx_unused* pbc_simd) { #if GMX_SIMD_HAVE_REAL - if (pbc != nullptr && pbc->ePBC != epbcNONE) + if (pbc != nullptr && pbc->pbcType != PbcType::No) { rvec inv_box_diag = { 0, 0, 0 }; diff --git a/src/gromacs/pbcutil/pbcmethods.cpp b/src/gromacs/pbcutil/pbcmethods.cpp index 7cdd4e1ca7..3b8f887fee 100644 --- a/src/gromacs/pbcutil/pbcmethods.cpp +++ b/src/gromacs/pbcutil/pbcmethods.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -44,7 +44,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/smalloc.h" -void calc_pbc_cluster(int ecenter, int nrefat, t_topology* top, int ePBC, rvec x[], const int index[], matrix box) +void calc_pbc_cluster(int ecenter, int nrefat, t_topology* top, PbcType pbcType, rvec x[], const int index[], matrix box) { int m, i, j, j0, j1, jj, ai, aj; int imin, jmin; @@ -64,7 +64,7 @@ void calc_pbc_cluster(int ecenter, int nrefat, t_topology* top, int ePBC, rvec x /* Initiate the pbc structure */ std::memset(&pbc, 0, sizeof(pbc)); - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); /* Convert atom index to molecular */ nmol = top->mols.nr; @@ -242,7 +242,7 @@ void put_molecule_com_in_box(int unitcell_enum, t_block* mols, int natoms, t_atom atom[], - int ePBC, + PbcType pbcType, matrix box, rvec x[]) { @@ -254,7 +254,7 @@ void put_molecule_com_in_box(int unitcell_enum, t_pbc pbc; calc_box_center(ecenter, box, box_center); - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); if (mols->nr <= 0) { gmx_fatal(FARGS, @@ -283,10 +283,10 @@ void put_molecule_com_in_box(int unitcell_enum, auto newComArrayRef = gmx::arrayRefFromArray(&newCom, 1); switch (unitcell_enum) { - case euRect: put_atoms_in_box(ePBC, box, newComArrayRef); break; + case euRect: put_atoms_in_box(pbcType, box, newComArrayRef); break; case euTric: put_atoms_in_triclinic_unitcell(ecenter, box, newComArrayRef); break; case euCompact: - put_atoms_in_compact_unitcell(ePBC, ecenter, box, newComArrayRef); + put_atoms_in_compact_unitcell(pbcType, ecenter, box, newComArrayRef); break; } rvec_sub(newCom, com, shift); @@ -307,7 +307,13 @@ void put_molecule_com_in_box(int unitcell_enum, } } -void put_residue_com_in_box(int unitcell_enum, int ecenter, int natoms, t_atom atom[], int ePBC, matrix box, rvec x[]) +void put_residue_com_in_box(int unitcell_enum, + int ecenter, + int natoms, + t_atom atom[], + PbcType pbcType, + matrix box, + rvec x[]) { int i, j, res_start, res_end; int d, presnr; @@ -335,10 +341,10 @@ void put_residue_com_in_box(int unitcell_enum, int ecenter, int natoms, t_atom a auto newComArrayRef = gmx::arrayRefFromArray(&newCom, 1); switch (unitcell_enum) { - case euRect: put_atoms_in_box(ePBC, box, newComArrayRef); break; + case euRect: put_atoms_in_box(pbcType, box, newComArrayRef); break; case euTric: put_atoms_in_triclinic_unitcell(ecenter, box, newComArrayRef); break; case euCompact: - put_atoms_in_compact_unitcell(ePBC, ecenter, box, newComArrayRef); + put_atoms_in_compact_unitcell(pbcType, ecenter, box, newComArrayRef); break; } rvec_sub(newCom, com, shift); diff --git a/src/gromacs/pbcutil/pbcmethods.h b/src/gromacs/pbcutil/pbcmethods.h index ff796c5c9b..262d32a862 100644 --- a/src/gromacs/pbcutil/pbcmethods.h +++ b/src/gromacs/pbcutil/pbcmethods.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -38,6 +38,7 @@ struct t_topology; struct t_block; struct t_atom; +enum class PbcType : int; #include "gmxpre.h" @@ -52,7 +53,7 @@ enum euNR }; -void calc_pbc_cluster(int ecenter, int nrefat, t_topology* top, int ePBC, rvec x[], const int index[], matrix box); +void calc_pbc_cluster(int ecenter, int nrefat, t_topology* top, PbcType pbcType, rvec x[], const int index[], matrix box); void put_molecule_com_in_box(int unitcell_enum, @@ -60,11 +61,17 @@ void put_molecule_com_in_box(int unitcell_enum, t_block* mols, int natoms, t_atom atom[], - int ePBC, + PbcType pbcType, matrix box, rvec x[]); -void put_residue_com_in_box(int unitcell_enum, int ecenter, int natoms, t_atom atom[], int ePBC, matrix box, rvec x[]); +void put_residue_com_in_box(int unitcell_enum, + int ecenter, + int natoms, + t_atom atom[], + PbcType pbcType, + matrix box, + rvec x[]); void center_x(int ecenter, rvec x[], matrix box, int n, int nc, const int ci[]); diff --git a/src/gromacs/pbcutil/rmpbc.cpp b/src/gromacs/pbcutil/rmpbc.cpp index a973e729c2..92792d4df2 100644 --- a/src/gromacs/pbcutil/rmpbc.cpp +++ b/src/gromacs/pbcutil/rmpbc.cpp @@ -64,17 +64,17 @@ struct gmx_rmpbc { const t_idef* idef; int natoms_init; - int ePBC; + PbcType pbcType; int ngraph; rmpbc_graph_t* graph; }; -static t_graph* gmx_rmpbc_get_graph(gmx_rmpbc_t gpbc, int ePBC, int natoms) +static t_graph* gmx_rmpbc_get_graph(gmx_rmpbc_t gpbc, PbcType pbcType, int natoms) { int i; rmpbc_graph_t* gr; - if (ePBC == epbcNONE || nullptr == gpbc || nullptr == gpbc->idef || gpbc->idef->ntypes <= 0) + if (pbcType == PbcType::No || nullptr == gpbc || nullptr == gpbc->idef || gpbc->idef->ntypes <= 0) { return nullptr; } @@ -110,7 +110,7 @@ static t_graph* gmx_rmpbc_get_graph(gmx_rmpbc_t gpbc, int ePBC, int natoms) return gr->gr; } -gmx_rmpbc_t gmx_rmpbc_init(const t_idef* idef, int ePBC, int natoms) +gmx_rmpbc_t gmx_rmpbc_init(const t_idef* idef, PbcType pbcType, int natoms) { gmx_rmpbc_t gpbc; @@ -121,7 +121,7 @@ gmx_rmpbc_t gmx_rmpbc_init(const t_idef* idef, int ePBC, int natoms) /* This sets pbc when we now it, * otherwise we guess it from the instantaneous box in the trajectory. */ - gpbc->ePBC = ePBC; + gpbc->pbcType = pbcType; gpbc->idef = idef; if (gpbc->idef->ntypes <= 0) @@ -156,43 +156,43 @@ void gmx_rmpbc_done(gmx_rmpbc_t gpbc) } } -static int gmx_rmpbc_ePBC(gmx_rmpbc_t gpbc, const matrix box) +static PbcType gmx_rmpbc_ePBC(gmx_rmpbc_t gpbc, const matrix box) { - if (nullptr != gpbc && gpbc->ePBC >= 0) + if (nullptr != gpbc && gpbc->pbcType != PbcType::Unset) { - return gpbc->ePBC; + return gpbc->pbcType; } else { - return guess_ePBC(box); + return guessPbcType(box); } } void gmx_rmpbc(gmx_rmpbc_t gpbc, int natoms, const matrix box, rvec x[]) { - int ePBC; + PbcType pbcType; t_graph* gr; - ePBC = gmx_rmpbc_ePBC(gpbc, box); - gr = gmx_rmpbc_get_graph(gpbc, ePBC, natoms); + pbcType = gmx_rmpbc_ePBC(gpbc, box); + gr = gmx_rmpbc_get_graph(gpbc, pbcType, natoms); if (gr != nullptr) { - mk_mshift(stdout, gr, ePBC, box, x); + mk_mshift(stdout, gr, pbcType, box, x); shift_self(gr, box, x); } } void gmx_rmpbc_copy(gmx_rmpbc_t gpbc, int natoms, const matrix box, rvec x[], rvec x_s[]) { - int ePBC; + PbcType pbcType; t_graph* gr; int i; - ePBC = gmx_rmpbc_ePBC(gpbc, box); - gr = gmx_rmpbc_get_graph(gpbc, ePBC, natoms); + pbcType = gmx_rmpbc_ePBC(gpbc, box); + gr = gmx_rmpbc_get_graph(gpbc, pbcType, natoms); if (gr != nullptr) { - mk_mshift(stdout, gr, ePBC, box, x); + mk_mshift(stdout, gr, pbcType, box, x); shift_x(gr, box, x, x_s); } else @@ -206,16 +206,16 @@ void gmx_rmpbc_copy(gmx_rmpbc_t gpbc, int natoms, const matrix box, rvec x[], rv void gmx_rmpbc_trxfr(gmx_rmpbc_t gpbc, t_trxframe* fr) { - int ePBC; + PbcType pbcType; t_graph* gr; if (fr->bX && fr->bBox) { - ePBC = gmx_rmpbc_ePBC(gpbc, fr->box); - gr = gmx_rmpbc_get_graph(gpbc, ePBC, fr->natoms); + pbcType = gmx_rmpbc_ePBC(gpbc, fr->box); + gr = gmx_rmpbc_get_graph(gpbc, pbcType, fr->natoms); if (gr != nullptr) { - mk_mshift(stdout, gr, ePBC, fr->box, fr->x); + mk_mshift(stdout, gr, pbcType, fr->box, fr->x); shift_self(gr, fr->box, fr->x); } } diff --git a/src/gromacs/pbcutil/rmpbc.h b/src/gromacs/pbcutil/rmpbc.h index 0feb096495..1b93ae538e 100644 --- a/src/gromacs/pbcutil/rmpbc.h +++ b/src/gromacs/pbcutil/rmpbc.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2016,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2016,2018,2019,2020, 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. @@ -42,10 +42,11 @@ struct t_atoms; struct t_idef; struct t_trxframe; +enum class PbcType : int; typedef struct gmx_rmpbc* gmx_rmpbc_t; -gmx_rmpbc_t gmx_rmpbc_init(const t_idef* idef, int ePBC, int natoms); +gmx_rmpbc_t gmx_rmpbc_init(const t_idef* idef, PbcType pbcType, int natoms); void gmx_rmpbc_done(gmx_rmpbc_t gpbc); @@ -54,7 +55,7 @@ void gmx_rmpbc(gmx_rmpbc_t gpbc, int natoms, const matrix box, rvec x[]); * boundary conditions such that every molecule is whole. * natoms is the size x and can be smaller than the number * of atoms in idef, but should only contain complete molecules. - * When ePBC=-1, the type of pbc is guessed from the box matrix. + * When pbcType=PbcType::Unset, the type of pbc is guessed from the box matrix. */ void gmx_rmpbc_copy(gmx_rmpbc_t gpbc, int natoms, const matrix box, rvec x[], rvec x_s[]); diff --git a/src/gromacs/pulling/pull.cpp b/src/gromacs/pulling/pull.cpp index 157d7f9779..712399a7f1 100644 --- a/src/gromacs/pulling/pull.cpp +++ b/src/gromacs/pulling/pull.cpp @@ -2053,11 +2053,11 @@ struct pull_t* init_pull(FILE* fplog, pull->numUnregisteredExternalPotentials = pull->numCoordinatesWithExternalPotential; pull->numExternalPotentialsStillToBeAppliedThisStep = 0; - pull->ePBC = ir->ePBC; - switch (pull->ePBC) + pull->pbcType = ir->pbcType; + switch (pull->pbcType) { - case epbcNONE: pull->npbcdim = 0; break; - case epbcXY: pull->npbcdim = 2; break; + case PbcType::No: pull->npbcdim = 0; break; + case PbcType::XY: pull->npbcdim = 2; break; default: pull->npbcdim = 3; break; } @@ -2321,7 +2321,7 @@ void preparePrevStepPullCom(const t_inputrec* ir, else { t_pbc pbc; - set_pbc(&pbc, ir->ePBC, state->box); + set_pbc(&pbc, ir->pbcType, state->box); initPullComFromPrevStep(cr, pull_work, md, &pbc, state->x.rvec_array()); updatePrevStepPullCom(pull_work, state); } diff --git a/src/gromacs/pulling/pull_internal.h b/src/gromacs/pulling/pull_internal.h index 1a8f500fb8..1973e5f116 100644 --- a/src/gromacs/pulling/pull_internal.h +++ b/src/gromacs/pulling/pull_internal.h @@ -71,6 +71,7 @@ static const int c_pullMaxNumLocalAtomsSingleThreaded = 1; #endif class PullHistory; +enum class PbcType : int; enum { @@ -227,7 +228,7 @@ struct pull_t gmx_bool bConstraint; /* Are there constrained coordinates? */ gmx_bool bAngle; /* Are there angle geometry coordinates? */ - int ePBC; /* the boundary conditions */ + PbcType pbcType; /* the boundary conditions */ int npbcdim; /* do pbc in dims 0 <= dim < npbcdim */ gmx_bool bRefAt; /* do we need reference atoms for a group COM ? */ int cosdim; /* dimension for cosine weighting, -1 if none */ diff --git a/src/gromacs/pulling/pull_rotation.cpp b/src/gromacs/pulling/pull_rotation.cpp index 1ae8f45edd..641ffcf528 100644 --- a/src/gromacs/pulling/pull_rotation.cpp +++ b/src/gromacs/pulling/pull_rotation.cpp @@ -3678,7 +3678,7 @@ std::unique_ptr init_rot(FILE* fplo * 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->ePBC, globalState->box, mtop, x_pbc); + do_pbc_first_mtop(nullptr, ir->pbcType, globalState->box, mtop, x_pbc); /* All molecules will be whole now, but not necessarily in the home box. * Additionally, if a rotation group consists of more than one molecule * (e.g. two strands of DNA), each one of them can end up in a different diff --git a/src/gromacs/pulling/pullutil.cpp b/src/gromacs/pulling/pullutil.cpp index 2b75b64ca6..44620e5382 100644 --- a/src/gromacs/pulling/pullutil.cpp +++ b/src/gromacs/pulling/pullutil.cpp @@ -906,7 +906,7 @@ static bool pullGroupObeysPbcRestrictions(const pull_group_work_t& group, int pullCheckPbcWithinGroups(const pull_t& pull, const rvec* x, const t_pbc& pbc, real pbcMargin) { - if (pbc.ePBC == epbcNONE) + if (pbc.pbcType == PbcType::No) { return -1; } @@ -948,7 +948,7 @@ bool pullCheckPbcWithinGroup(const pull_t& pull, int groupNr, real pbcMargin) { - if (pbc.ePBC == epbcNONE) + if (pbc.pbcType == PbcType::No) { return true; } diff --git a/src/gromacs/pulling/tests/pull.cpp b/src/gromacs/pulling/tests/pull.cpp index 416f02deb1..21956445be 100644 --- a/src/gromacs/pulling/tests/pull.cpp +++ b/src/gromacs/pulling/tests/pull.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2016,2018,2019,2020, 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. @@ -70,12 +70,12 @@ class PullTest : public ::testing::Test protected: PullTest() {} - void test(int epbc, matrix box) + void test(PbcType pbcType, matrix box) { t_pbc pbc; // PBC stuff - set_pbc(&pbc, epbc, box); + set_pbc(&pbc, pbcType, box); GMX_ASSERT(pbc.ndim_ePBC >= 1 && pbc.ndim_ePBC <= DIM, "Tests only support PBC along at least x and at most x, y, and z"); @@ -161,35 +161,35 @@ TEST_F(PullTest, MaxPullDistanceXyzScrewBox) { matrix box = { { 10, 0, 0 }, { 0, 10, 0 }, { 0, 0, 10 } }; - test(epbcSCREW, box); + test(PbcType::Screw, box); } TEST_F(PullTest, MaxPullDistanceXyzCubicBox) { matrix box = { { 10, 0, 0 }, { 0, 10, 0 }, { 0, 0, 10 } }; - test(epbcXYZ, box); + test(PbcType::Xyz, box); } TEST_F(PullTest, MaxPullDistanceXyzTricBox) { matrix box = { { 10, 0, 0 }, { 3, 10, 0 }, { 3, 4, 10 } }; - test(epbcXYZ, box); + test(PbcType::Xyz, box); } TEST_F(PullTest, MaxPullDistanceXyzLongBox) { matrix box = { { 10, 0, 0 }, { 0, 10, 0 }, { 0, 0, 30 } }; - test(epbcXYZ, box); + test(PbcType::Xyz, box); } TEST_F(PullTest, MaxPullDistanceXySkewedBox) { matrix box = { { 10, 0, 0 }, { 5, 8, 0 }, { 0, 0, 0 } }; - test(epbcXY, box); + test(PbcType::XY, box); } } // namespace diff --git a/src/gromacs/restraint/restraintmdmodule.cpp b/src/gromacs/restraint/restraintmdmodule.cpp index e1e7f65a88..a6ba84eeee 100644 --- a/src/gromacs/restraint/restraintmdmodule.cpp +++ b/src/gromacs/restraint/restraintmdmodule.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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. @@ -72,9 +72,9 @@ void RestraintForceProvider::calculateForces(const ForceProviderInput& forceProv GMX_ASSERT(mdatoms.homenr >= 0, "number of home atoms must be non-negative."); const auto& box = forceProviderInput.box_; - GMX_ASSERT(check_box(-1, box) == nullptr, "Invalid box."); + GMX_ASSERT(check_box(PbcType::Unset, box) == nullptr, "Invalid box."); t_pbc pbc{}; - set_pbc(&pbc, -1, box); + set_pbc(&pbc, PbcType::Unset, box); const auto& x = forceProviderInput.x_; const auto& cr = forceProviderInput.cr_; diff --git a/src/gromacs/selection/nbsearch.cpp b/src/gromacs/selection/nbsearch.cpp index 96686d6849..96443c208d 100644 --- a/src/gromacs/selection/nbsearch.cpp +++ b/src/gromacs/selection/nbsearch.cpp @@ -561,19 +561,19 @@ bool AnalysisNeighborhoodSearchImpl::initGrid(const t_pbc& pbc, int posCount, co // or remove throughout. GMX_UNUSED_VALUE(bForce); - switch (pbc.ePBC) + switch (pbc.pbcType) { - case epbcNONE: + case PbcType::No: bGridPBC_[XX] = false; bGridPBC_[YY] = false; bGridPBC_[ZZ] = false; break; - case epbcXY: + case PbcType::XY: bGridPBC_[XX] = true; bGridPBC_[YY] = true; bGridPBC_[ZZ] = false; break; - case epbcXYZ: + case PbcType::Xyz: bGridPBC_[XX] = true; bGridPBC_[YY] = true; bGridPBC_[ZZ] = true; @@ -867,16 +867,16 @@ void AnalysisNeighborhoodSearchImpl::init(AnalysisNeighborhood::SearchMode m GMX_RELEASE_ASSERT(positions.index_ == -1, "Individual indexed positions not supported as reference"); bXY_ = bXY; - if (bXY_ && pbc != nullptr && pbc->ePBC != epbcNONE) + if (bXY_ && pbc != nullptr && pbc->pbcType != PbcType::No) { - if (pbc->ePBC != epbcXY && pbc->ePBC != epbcXYZ) + if (pbc->pbcType != PbcType::XY && pbc->pbcType != PbcType::Xyz) { std::string message = formatString( "Computations in the XY plane are not supported with PBC type '%s'", - epbc_names[pbc->ePBC]); + c_pbcTypeNames[pbc->pbcType].c_str()); GMX_THROW(NotImplementedError(message)); } - if (pbc->ePBC == epbcXYZ + if (pbc->pbcType == PbcType::Xyz && (std::fabs(pbc->box[ZZ][XX]) > GMX_REAL_EPS * pbc->box[ZZ][ZZ] || std::fabs(pbc->box[ZZ][YY]) > GMX_REAL_EPS * pbc->box[ZZ][ZZ])) { @@ -888,7 +888,7 @@ void AnalysisNeighborhoodSearchImpl::init(AnalysisNeighborhood::SearchMode m matrix box; copy_mat(pbc->box, box); clear_rvec(box[ZZ]); - set_pbc(&pbc_, epbcXY, box); + set_pbc(&pbc_, PbcType::XY, box); } else if (pbc != nullptr) { @@ -896,7 +896,7 @@ void AnalysisNeighborhoodSearchImpl::init(AnalysisNeighborhood::SearchMode m } else { - pbc_.ePBC = epbcNONE; + pbc_.pbcType = PbcType::No; clear_mat(pbc_.box); } nref_ = positions.count_; @@ -1119,7 +1119,7 @@ bool AnalysisNeighborhoodPairSearchImpl::searchNext(Action action) continue; } rvec dx; - if (search_.pbc_.ePBC != epbcNONE) + if (search_.pbc_.pbcType != PbcType::No) { pbc_dx(&search_.pbc_, search_.xref_[i], xtest_, dx); } diff --git a/src/gromacs/selection/tests/nbsearch.cpp b/src/gromacs/selection/tests/nbsearch.cpp index 1caa6ff603..ab8d19566e 100644 --- a/src/gromacs/selection/tests/nbsearch.cpp +++ b/src/gromacs/selection/tests/nbsearch.cpp @@ -199,7 +199,7 @@ NeighborhoodSearchTestData::NeighborhoodSearchTestData(uint64_t seed, real cutof refPosCount_(0) { clear_mat(box_); - set_pbc(&pbc_, epbcNONE, box_); + set_pbc(&pbc_, PbcType::No, box_); } gmx::RVec NeighborhoodSearchTestData::generateRandomPosition() @@ -661,7 +661,7 @@ public: data_.box_[ZZ][ZZ] = 3.0; data_.generateRandomRefPositions(10); data_.generateRandomTestPositions(5); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -685,7 +685,7 @@ public: data_.box_[ZZ][ZZ] = 3.0; data_.generateRandomRefPositions(20); data_.useRefPositionsAsTestPositions(); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -731,7 +731,7 @@ public: // test coverage. data_.generateRandomRefPositions(1000); data_.generateRandomTestPositions(100); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -755,7 +755,7 @@ public: data_.box_[ZZ][ZZ] = 7.0; data_.generateRandomRefPositions(1000); data_.useRefPositionsAsTestPositions(); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -781,7 +781,7 @@ public: // test coverage. data_.generateRandomRefPositions(1000); data_.generateRandomTestPositions(100); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferencesXY(&data_.pbc_); } @@ -810,7 +810,7 @@ public: // test coverage. data_.generateRandomRefPositions(1000); data_.generateRandomTestPositions(100); - set_pbc(&data_.pbc_, epbcXYZ, data_.box_); + set_pbc(&data_.pbc_, PbcType::Xyz, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -836,7 +836,7 @@ public: // test coverage. data_.generateRandomRefPositions(1000); data_.generateRandomTestPositions(100); - set_pbc(&data_.pbc_, epbcXY, data_.box_); + set_pbc(&data_.pbc_, PbcType::XY, data_.box_); data_.computeReferences(&data_.pbc_); } @@ -862,7 +862,7 @@ public: // test coverage. data_.generateRandomRefPositions(1000); data_.generateRandomTestPositions(100); - set_pbc(&data_.pbc_, epbcNONE, data_.box_); + set_pbc(&data_.pbc_, PbcType::No, data_.box_); data_.computeReferences(nullptr); } diff --git a/src/gromacs/selection/tests/toputils.cpp b/src/gromacs/selection/tests/toputils.cpp index 053403afd7..77885f7913 100644 --- a/src/gromacs/selection/tests/toputils.cpp +++ b/src/gromacs/selection/tests/toputils.cpp @@ -119,15 +119,15 @@ void TopologyManager::requestForces() void TopologyManager::loadTopology(const char* filename) { - bool fullTopology; - int ePBC; - rvec* xtop = nullptr; - matrix box; + bool fullTopology; + PbcType pbcType; + rvec* xtop = nullptr; + matrix box; GMX_RELEASE_ASSERT(mtop_ == nullptr, "Topology initialized more than once"); mtop_ = std::make_unique(); readConfAndTopology(gmx::test::TestFileManager::getInputFilePath(filename).c_str(), &fullTopology, - mtop_.get(), &ePBC, frame_ != nullptr ? &xtop : nullptr, nullptr, box); + mtop_.get(), &pbcType, frame_ != nullptr ? &xtop : nullptr, nullptr, box); if (frame_ != nullptr) { diff --git a/src/gromacs/swap/swapcoords.cpp b/src/gromacs/swap/swapcoords.cpp index f28a9734b8..a9290efe65 100644 --- a/src/gromacs/swap/swapcoords.cpp +++ b/src/gromacs/swap/swapcoords.cpp @@ -1209,7 +1209,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, int ePBC, const matrix box) +static void outputStartStructureIfWanted(gmx_mtop_t* mtop, rvec* x, PbcType pbcType, const matrix box) { char* env = getenv("GMX_COMPELDUMP"); @@ -1223,7 +1223,7 @@ static void outputStartStructureIfWanted(gmx_mtop_t* mtop, rvec* x, int ePBC, co SwS, SwSEmpty); write_sto_conf_mtop("CompELAssumedWholeConfiguration.pdb", *mtop->name, mtop, x, nullptr, - ePBC, box); + pbcType, box); } } @@ -1289,10 +1289,10 @@ static void init_swapstate(swaphistory_t* swapstate, copy_rvecn(x, x_pbc, 0, mtop->natoms); /* This can only make individual molecules whole, not multimers */ - do_pbc_mtop(ir->ePBC, box, mtop, x_pbc); + do_pbc_mtop(ir->pbcType, box, mtop, x_pbc); /* Output the starting structure? */ - outputStartStructureIfWanted(mtop, x_pbc, ir->ePBC, box); + outputStartStructureIfWanted(mtop, x_pbc, ir->pbcType, box); /* If this is the first run (i.e. no checkpoint present) we assume * that the starting positions give us the correct PBC representation */ @@ -1944,7 +1944,7 @@ gmx_bool do_swapcoords(t_commrec* cr, sc = ir->swap; - set_pbc(s->pbc, ir->ePBC, box); + set_pbc(s->pbc, ir->pbcType, box); /* Assemble the positions of the split groups, i.e. the channels. * Here we also pass a shifts array to communicate_group_positions(), so that it can make diff --git a/src/gromacs/tools/check.cpp b/src/gromacs/tools/check.cpp index ce0b41544a..03e4ffd85e 100644 --- a/src/gromacs/tools/check.cpp +++ b/src/gromacs/tools/check.cpp @@ -233,14 +233,14 @@ static void chk_forces(int frame, int natoms, rvec* f) } } -static void chk_bonds(t_idef* idef, int ePBC, rvec* x, matrix box, real tol) +static void chk_bonds(t_idef* idef, PbcType pbcType, rvec* x, matrix box, real tol) { int ftype, k, ai, aj, type; real b0, blen, deviation; t_pbc pbc; rvec dx; - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); for (ftype = 0; (ftype < F_NRE); ftype++) { if ((interaction_function[ftype].flags & IF_CHEMBOND) == IF_CHEMBOND) @@ -359,7 +359,7 @@ static void chk_trj(const gmx_output_env_t* oenv, const char* fn, const char* tp natoms = new_natoms; if (tpr) { - chk_bonds(&top.idef, ir.ePBC, fr.x, fr.box, tol); + chk_bonds(&top.idef, ir.pbcType, fr.x, fr.box, tol); } if (fr.bX) { @@ -429,7 +429,7 @@ static void chk_tps(const char* fn, real vdw_fac, real bon_lo, real bon_hi) { int natom, i, j, k; t_topology top; - int ePBC; + PbcType pbcType; t_atoms* atoms; rvec * x, *v; rvec dx; @@ -440,7 +440,7 @@ static void chk_tps(const char* fn, real vdw_fac, real bon_lo, real bon_hi) real* atom_vdw; fprintf(stderr, "Checking coordinate file %s\n", fn); - read_tps_conf(fn, &top, &ePBC, &x, &v, box, TRUE); + read_tps_conf(fn, &top, &pbcType, &x, &v, box, TRUE); atoms = &top.atoms; natom = atoms->nr; fprintf(stderr, "%d atoms in file\n", atoms->nr); @@ -517,7 +517,7 @@ static void chk_tps(const char* fn, real vdw_fac, real bon_lo, real bon_hi) } if (bB) { - set_pbc(&pbc, ePBC, box); + set_pbc(&pbc, pbcType, box); } bFirst = TRUE; diff --git a/src/gromacs/tools/make_ndx.cpp b/src/gromacs/tools/make_ndx.cpp index 45c0383797..34ecf81798 100644 --- a/src/gromacs/tools/make_ndx.cpp +++ b/src/gromacs/tools/make_ndx.cpp @@ -1535,7 +1535,7 @@ int gmx_make_ndx(int argc, char* argv[]) int j; t_atoms atoms; rvec * x, *v; - int ePBC; + PbcType pbcType; matrix box; t_blocka * block, *block2; char ** gnames, **gnames2; @@ -1564,7 +1564,7 @@ int gmx_make_ndx(int argc, char* argv[]) { bool haveFullTopology = false; fprintf(stderr, "\nReading structure file\n"); - readConfAndTopology(stxfile, &haveFullTopology, &mtop, &ePBC, &x, &v, box); + readConfAndTopology(stxfile, &haveFullTopology, &mtop, &pbcType, &x, &v, box); atoms = gmx_mtop_global_atoms(&mtop); if (atoms.pdbinfo == nullptr) { diff --git a/src/gromacs/tools/trjconv.cpp b/src/gromacs/tools/trjconv.cpp index ed19c7df18..43274a7522 100644 --- a/src/gromacs/tools/trjconv.cpp +++ b/src/gromacs/tools/trjconv.cpp @@ -484,10 +484,10 @@ int gmx_trjconv(int argc, char* argv[]) real* w_rls = nullptr; int m, i, d, frame, outframe, natoms, nout, ncent, newstep = 0, model_nr; #define SKIP 10 - t_topology* top = nullptr; - gmx_conect gc = nullptr; - int ePBC = -1; - t_atoms * atoms = nullptr, useatoms; + t_topology* top = nullptr; + gmx_conect gc = nullptr; + PbcType pbcType = PbcType::Unset; + t_atoms * atoms = nullptr, useatoms; matrix top_box; int * index = nullptr, *cindex = nullptr; char* grpnm = nullptr; @@ -669,7 +669,7 @@ int gmx_trjconv(int argc, char* argv[]) if (bTPS) { snew(top, 1); - read_tps_conf(top_file, top, &ePBC, &xp, nullptr, top_box, bReset || bPBCcomRes); + read_tps_conf(top_file, top, &pbcType, &xp, nullptr, top_box, bReset || bPBCcomRes); std::strncpy(top_title, *top->name, 255); top_title[255] = '\0'; atoms = &top->atoms; @@ -702,7 +702,7 @@ int gmx_trjconv(int argc, char* argv[]) } if (bRmPBC) { - gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr); + gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr); } } @@ -898,7 +898,7 @@ int gmx_trjconv(int argc, char* argv[]) read_first_frame(oenv, &trxin, in_file, &fr, flags); } - set_trxframe_ePBC(&fr, ePBC); + setTrxFramePbcType(&fr, pbcType); natoms = fr.natoms; if (bSetTime) @@ -1078,7 +1078,7 @@ int gmx_trjconv(int argc, char* argv[]) } else if (bCluster) { - calc_pbc_cluster(ecenter, ifit, top, ePBC, fr.x, ind_fit, fr.box); + calc_pbc_cluster(ecenter, ifit, top, pbcType, fr.x, ind_fit, fr.box); } if (bPFit) @@ -1237,25 +1237,26 @@ int gmx_trjconv(int argc, char* argv[]) switch (unitcell_enum) { case euRect: - put_atoms_in_box(ePBC, fr.box, positionsArrayRef); + put_atoms_in_box(pbcType, fr.box, positionsArrayRef); break; case euTric: put_atoms_in_triclinic_unitcell(ecenter, fr.box, positionsArrayRef); break; case euCompact: - put_atoms_in_compact_unitcell(ePBC, ecenter, fr.box, positionsArrayRef); + put_atoms_in_compact_unitcell(pbcType, ecenter, fr.box, + positionsArrayRef); break; } } if (bPBCcomRes) { put_residue_com_in_box(unitcell_enum, ecenter, natoms, atoms->atom, - ePBC, fr.box, fr.x); + pbcType, fr.box, fr.x); } if (bPBCcomMol) { put_molecule_com_in_box(unitcell_enum, ecenter, &top->mols, natoms, - atoms->atom, ePBC, fr.box, fr.x); + atoms->atom, pbcType, fr.box, fr.x); } /* Copy the input trxframe struct to the output trxframe struct */ frout = fr; @@ -1389,7 +1390,7 @@ int gmx_trjconv(int argc, char* argv[]) model_nr++; } write_pdbfile(out, title.c_str(), &useatoms, frout.x, - frout.ePBC, frout.box, ' ', model_nr, gc); + frout.pbcType, frout.box, ' ', model_nr, gc); break; case efG96: const char* outputTitle = ""; diff --git a/src/gromacs/trajectory/trajectoryframe.cpp b/src/gromacs/trajectory/trajectoryframe.cpp index 7baabd02a5..c45a3b7878 100644 --- a/src/gromacs/trajectory/trajectoryframe.cpp +++ b/src/gromacs/trajectory/trajectoryframe.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018,2019,2020, 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. @@ -147,9 +147,9 @@ double TrajectoryFrame::time() const return frame_.time; } -int TrajectoryFrame::pbc() const +PbcType TrajectoryFrame::pbc() const { - return frame_.ePBC; + return frame_.pbcType; } ArrayRef TrajectoryFrame::x() const diff --git a/src/gromacs/trajectory/trajectoryframe.h b/src/gromacs/trajectory/trajectoryframe.h index f0e77d69ea..0adc4dbfad 100644 --- a/src/gromacs/trajectory/trajectoryframe.h +++ b/src/gromacs/trajectory/trajectoryframe.h @@ -53,6 +53,7 @@ #include "gromacs/utility/real.h" struct t_atoms; +enum class PbcType : int; typedef struct t_trxframe // NOLINT (clang-analyzer-optin.performance.Padding) { @@ -80,7 +81,7 @@ typedef struct t_trxframe // NOLINT (clang-analyzer-optin.performance.Padding) gmx_bool bBox; matrix box; /* the 3 box vectors */ gmx_bool bPBC; - int ePBC; /* the type of pbc */ + PbcType pbcType; /* the type of pbc */ gmx_bool bIndex; int* index; /* atom indices of contained coordinates */ } t_trxframe; @@ -127,7 +128,7 @@ public: //! Time read from the trajectory file frame. double time() const; //! The PBC characteristics of the box. - int pbc() const; + PbcType pbc() const; //! Get a view of position coordinates of the frame (which could be empty). ArrayRef x() const; //! Get a view of velocity coordinates of the frame (which could be empty). diff --git a/src/gromacs/trajectoryanalysis/cmdlinerunner.cpp b/src/gromacs/trajectoryanalysis/cmdlinerunner.cpp index 755782d827..fb0d2e17bf 100644 --- a/src/gromacs/trajectoryanalysis/cmdlinerunner.cpp +++ b/src/gromacs/trajectoryanalysis/cmdlinerunner.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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 @@ int RunnerModule::run() t_trxframe& frame = common_.frame(); if (ppbc != nullptr) { - set_pbc(ppbc, topology.ePBC(), frame.box); + set_pbc(ppbc, topology.pbcType(), frame.box); } selections_.evaluate(&frame, ppbc); diff --git a/src/gromacs/trajectoryanalysis/modules/rdf.cpp b/src/gromacs/trajectoryanalysis/modules/rdf.cpp index 6dd388f3ad..bb2f624919 100644 --- a/src/gromacs/trajectoryanalysis/modules/rdf.cpp +++ b/src/gromacs/trajectoryanalysis/modules/rdf.cpp @@ -409,7 +409,7 @@ void Rdf::initAfterFirstFrame(const TrajectoryAnalysisSettings& settings, const { box[ZZ][ZZ] = 2 * std::max(box[XX][XX], box[YY][YY]); } - rmax_ = std::sqrt(0.99 * 0.99 * max_cutoff2(bXY_ ? epbcXY : epbcXYZ, box)); + rmax_ = std::sqrt(0.99 * 0.99 * max_cutoff2(bXY_ ? PbcType::XY : PbcType::Xyz, box)); } else { diff --git a/src/gromacs/trajectoryanalysis/modules/sasa.cpp b/src/gromacs/trajectoryanalysis/modules/sasa.cpp index ca14fcb520..9b581dad9d 100644 --- a/src/gromacs/trajectoryanalysis/modules/sasa.cpp +++ b/src/gromacs/trajectoryanalysis/modules/sasa.cpp @@ -205,7 +205,7 @@ void connolly_plot(const char* fn, rvec x[], t_atoms* atoms, t_symtab* symtab, - int ePBC, + PbcType pbcType, const matrix box, gmx_bool bIncludeSolute) { @@ -254,7 +254,7 @@ void connolly_plot(const char* fn, } atoms->nr = i0 + ndots; atoms->nres = r0 + 1; - write_sto_conf(fn, title, atoms, xnew, nullptr, ePBC, const_cast(box)); + write_sto_conf(fn, title, atoms, xnew, nullptr, pbcType, const_cast(box)); atoms->nres = r0; atoms->nr = i0; } @@ -278,7 +278,7 @@ void connolly_plot(const char* fn, aaa.pdbinfo[ii0].occup = 0.0; } aaa.nr = ndots; - write_sto_conf(fn, title, &aaa, xnew, nullptr, ePBC, const_cast(box)); + write_sto_conf(fn, title, &aaa, xnew, nullptr, pbcType, const_cast(box)); do_conect(fn, ndots, xnew); done_atom(&aaa); } @@ -549,7 +549,7 @@ void Sasa::initAnalysis(const TrajectoryAnalysisSettings& settings, const Topolo } please_cite(stderr, "Eisenhaber95"); - // if ((top.ePBC() != epbcXYZ) || (TRICLINIC(fr.box))) + // if ((top.pbcType() != PbcType::Xyz) || (TRICLINIC(fr.box))) //{ // fprintf(stderr, "\n\nWARNING: non-rectangular boxes may give erroneous results or crashes.\n" // "Analysis based on vacuum simulations (with the possibility of evaporation)\n" @@ -986,7 +986,7 @@ void Sasa::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAn // one else uses the topology after initialization, it may just work // even with future parallelization. connolly_plot(fnConnolly_.c_str(), nsurfacedots, surfacedots, fr.x, atoms_.get(), - &mtop_->symtab, fr.ePBC, fr.box, bIncludeSolute_); + &mtop_->symtab, fr.pbcType, fr.box, bIncludeSolute_); } ah.startFrame(frnr, fr.time); diff --git a/src/gromacs/trajectoryanalysis/runnercommon.cpp b/src/gromacs/trajectoryanalysis/runnercommon.cpp index 7496d39102..92d9e52ebe 100644 --- a/src/gromacs/trajectoryanalysis/runnercommon.cpp +++ b/src/gromacs/trajectoryanalysis/runnercommon.cpp @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2010-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -262,7 +262,7 @@ void TrajectoryAnalysisRunnerCommon::Impl::initFirstFrame() copy_mat(topInfo_.boxtop_, fr->box); } - set_trxframe_ePBC(fr, topInfo_.ePBC()); + setTrxFramePbcType(fr, topInfo_.pbcType()); if (topInfo_.hasTopology() && settings_.hasRmPBC()) { gpbc_ = gmx_rmpbc_init(topInfo_); diff --git a/src/gromacs/trajectoryanalysis/tests/surfacearea.cpp b/src/gromacs/trajectoryanalysis/tests/surfacearea.cpp index c855d658c0..cc144da4ed 100644 --- a/src/gromacs/trajectoryanalysis/tests/surfacearea.cpp +++ b/src/gromacs/trajectoryanalysis/tests/surfacearea.cpp @@ -142,7 +142,7 @@ public: t_pbc pbc; if (bPBC) { - set_pbc(&pbc, epbcXYZ, box_); + set_pbc(&pbc, PbcType::Xyz, box_); } ASSERT_NO_THROW_GMX({ gmx::SurfaceAreaCalculator calculator; diff --git a/src/gromacs/trajectoryanalysis/tests/topologyinformation.cpp b/src/gromacs/trajectoryanalysis/tests/topologyinformation.cpp index 7124600ac9..4728ed6d96 100644 --- a/src/gromacs/trajectoryanalysis/tests/topologyinformation.cpp +++ b/src/gromacs/trajectoryanalysis/tests/topologyinformation.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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. @@ -47,6 +47,7 @@ #include "gromacs/gmxpreprocess/grompp.h" #include "gromacs/math/vectypes.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/topology/topology.h" #include "gromacs/utility/arrayref.h" #include "gromacs/utility/exceptions.h" @@ -77,7 +78,7 @@ TEST(TopologyInformation, CantWorkWithoutReadingAFile) ASSERT_TRUE(atoms2); EXPECT_NE(atoms1.get(), atoms2.get()); EXPECT_EQ(0, atoms1->nr); - EXPECT_EQ(-1, topInfo.ePBC()); + EXPECT_EQ(PbcType::Unset, topInfo.pbcType()); EXPECT_THROW(topInfo.x().size(), gmx::APIError); EXPECT_THROW(topInfo.v().size(), gmx::APIError); matrix box{ { -2 } }; @@ -135,7 +136,7 @@ TEST(TopologyInformation, WorksWithGroFile) topInfo.fillFromInputFile(TestFileManager::getInputFilePath("lysozyme.gro")); EXPECT_FALSE(topInfo.hasFullTopology()); runCommonTests(topInfo, numAtoms); - EXPECT_EQ(-1, topInfo.ePBC()); + EXPECT_EQ(PbcType::Unset, topInfo.pbcType()); // Check the per-atom data auto atoms = topInfo.copyAtoms(); @@ -168,7 +169,7 @@ TEST(TopologyInformation, WorksWithPdbFile) EXPECT_FALSE(topInfo.hasFullTopology()); runCommonTests(topInfo, numAtoms); // TODO why does this differ from .gro? - EXPECT_EQ(0, topInfo.ePBC()); + EXPECT_EQ(PbcType::Xyz, topInfo.pbcType()); // Check the per-atom data auto atoms = topInfo.copyAtoms(); @@ -220,7 +221,7 @@ TEST(TopologyInformation, WorksWithTprFromPdbFile) EXPECT_TRUE(topInfo.hasFullTopology()); runCommonTests(topInfo, numAtoms); // TODO why does this differ from .gro? - EXPECT_EQ(0, topInfo.ePBC()); + EXPECT_EQ(PbcType::Xyz, topInfo.pbcType()); // Check the per-atom data auto atoms = topInfo.copyAtoms(); diff --git a/src/gromacs/trajectoryanalysis/topologyinformation.cpp b/src/gromacs/trajectoryanalysis/topologyinformation.cpp index 74f1609e51..d3086056c0 100644 --- a/src/gromacs/trajectoryanalysis/topologyinformation.cpp +++ b/src/gromacs/trajectoryanalysis/topologyinformation.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, 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. @@ -47,6 +47,7 @@ #include "gromacs/fileio/confio.h" #include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" #include "gromacs/pbcutil/rmpbc.h" #include "gromacs/topology/mtop_util.h" #include "gromacs/topology/topology.h" @@ -64,7 +65,7 @@ TopologyInformation::TopologyInformation() : expandedTopology_(nullptr), atoms_(nullptr), bTop_(false), - ePBC_(-1) + pbcType_(PbcType::Unset) { } @@ -81,7 +82,7 @@ void TopologyInformation::fillFromInputFile(const std::string& filename) // TODO Once there are fewer callers of the file-reading // functionality, make them read directly into std::vector. rvec *x, *v; - readConfAndTopology(filename.c_str(), &bTop_, mtop_.get(), &ePBC_, &x, &v, boxtop_); + readConfAndTopology(filename.c_str(), &bTop_, mtop_.get(), &pbcType_, &x, &v, boxtop_); xtop_.assign(x, x + mtop_->natoms); vtop_.assign(v, v + mtop_->natoms); sfree(x); @@ -188,7 +189,7 @@ gmx_rmpbc_t gmx_rmpbc_init(const gmx::TopologyInformation& topInfo) { GMX_RELEASE_ASSERT(topInfo.hasTopology(), "Cannot remove PBC without a topology"); - return gmx_rmpbc_init(&topInfo.expandedTopology()->idef, topInfo.ePBC(), topInfo.mtop()->natoms); + return gmx_rmpbc_init(&topInfo.expandedTopology()->idef, topInfo.pbcType(), topInfo.mtop()->natoms); } } // namespace gmx diff --git a/src/gromacs/trajectoryanalysis/topologyinformation.h b/src/gromacs/trajectoryanalysis/topologyinformation.h index e9f9d5374d..2f353d0007 100644 --- a/src/gromacs/trajectoryanalysis/topologyinformation.h +++ b/src/gromacs/trajectoryanalysis/topologyinformation.h @@ -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,2020, 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. @@ -55,6 +55,7 @@ //! Forward declaration typedef struct gmx_rmpbc* gmx_rmpbc_t; +enum class PbcType : int; namespace gmx { @@ -134,8 +135,8 @@ public: /*! \brief Copies the fully expanded atom data arrays, which * might be valid but empty if no topology is available. */ AtomsDataPtr copyAtoms() const; - //! Returns the ePBC field from the topology. - int ePBC() const { return ePBC_; } + //! Returns the pbcType field from the topology. + PbcType pbcType() const { return pbcType_; } /*! \brief * Gets the configuration positions from the topology file. * @@ -186,8 +187,8 @@ private: std::vector vtop_; //! The box loaded from the topology file. matrix boxtop_{}; - //! The ePBC field loaded from the topology file. - int ePBC_; + //! The pbcType field loaded from the topology file. + PbcType pbcType_; // TODO This type is probably movable if we need that. GMX_DISALLOW_COPY_AND_ASSIGN(TopologyInformation); diff --git a/src/gromacs/utility/mdmodulenotification.h b/src/gromacs/utility/mdmodulenotification.h index c56160420d..891ec575c2 100644 --- a/src/gromacs/utility/mdmodulenotification.h +++ b/src/gromacs/utility/mdmodulenotification.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, 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. @@ -49,6 +49,7 @@ #include struct t_commrec; +enum class PbcType : int; namespace gmx { @@ -203,7 +204,7 @@ struct MdModulesCheckpointReadingBroadcast; struct MdModulesWriteCheckpointData; struct PeriodicBoundaryConditionType { - int pbcType; + PbcType pbcType; }; struct MdModulesEnergyOutputToDensityFittingRequestChecker diff --git a/src/programs/view/manager.cpp b/src/programs/view/manager.cpp index 528939813c..d5fbd842f3 100644 --- a/src/programs/view/manager.cpp +++ b/src/programs/view/manager.cpp @@ -227,7 +227,7 @@ void set_file(t_x11* x11, t_manager* man, const char* trajectory, const char* st snew(man->bHydro, sh.natoms); snew(bB, sh.natoms); read_tpx_top(status, nullptr, man->box, &man->natom, nullptr, nullptr, &man->top); - man->gpbc = gmx_rmpbc_init(&man->top.idef, -1, man->natom); + man->gpbc = gmx_rmpbc_init(&man->top.idef, PbcType::Unset, man->natom); man->natom = read_first_x(man->oenv, &man->status, trajectory, &(man->time), &(man->x), man->box); man->trajfile = gmx_strdup(trajectory); @@ -364,7 +364,7 @@ static bool step_man(t_manager* man, int* nat) put_atoms_in_triclinic_unitcell(ecenterDEF, man->box, atomsArrayRef); break; case esbTrunc: - put_atoms_in_compact_unitcell(man->molw->ePBC, ecenterDEF, man->box, atomsArrayRef); + put_atoms_in_compact_unitcell(man->molw->pbcType, ecenterDEF, man->box, atomsArrayRef); break; case esbRect: case esbNone: @@ -622,7 +622,7 @@ t_manager* init_man(t_x11* x11, int height, unsigned long fg, unsigned long bg, - int ePBC, + PbcType pbcType, matrix box, gmx_output_env_t* oenv) { @@ -641,7 +641,7 @@ t_manager* init_man(t_x11* x11, /* The order of creating windows is important for the stacking order */ /* Mol Window */ - man->molw = init_mw(x11, man->wd.self, 0, 0, 1, 1, WHITE, BLUE, ePBC, box); + man->molw = init_mw(x11, man->wd.self, 0, 0, 1, 1, WHITE, BLUE, pbcType, box); /* Title Window */ InitWin(&(man->title), 0, 0, 1, 1, 0, nullptr); diff --git a/src/programs/view/manager.h b/src/programs/view/manager.h index d0461104d0..bdd7727b3d 100644 --- a/src/programs/view/manager.h +++ b/src/programs/view/manager.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2019,2020, 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. @@ -52,6 +52,7 @@ #include "xutil.h" struct gmx_output_env_t; +enum class PbcType : int; /* Some window sizes */ #define EWIDTH 200 @@ -98,7 +99,7 @@ typedef struct t_windata wd; /* Mol window structure */ bool bShowHydrogen; /* Show Hydrogens? */ int bond_type; /* Show one of the above bondtypes */ - int ePBC; /* PBC type */ + PbcType pbcType; /* PBC type */ int boxtype; /* Rectangular, Tric, TruncOct (display)*/ int realbox; /* Property of the real box */ } t_molwin; @@ -178,7 +179,7 @@ extern t_manager* init_man(t_x11* x11, int height, unsigned long fg, unsigned long bg, - int ePBC, + PbcType pbcType, matrix box, gmx_output_env_t* oenv); /* Initiate the display manager */ diff --git a/src/programs/view/nmol.cpp b/src/programs/view/nmol.cpp index 12a7a9e421..1c1123ea6c 100644 --- a/src/programs/view/nmol.cpp +++ b/src/programs/view/nmol.cpp @@ -98,11 +98,11 @@ static bool MWCallBack(t_x11* x11, XEvent* event, Window /*w*/, void* data) return false; } -static void set_def(t_molwin* mw, int ePBC, matrix box) +static void set_def(t_molwin* mw, PbcType pbcType, matrix box) { mw->bShowHydrogen = true; mw->bond_type = eBFat; - mw->ePBC = ePBC; + mw->pbcType = pbcType; mw->boxtype = esbRect; mw->realbox = TRICLINIC(box) ? esbTri : esbRect; } @@ -115,13 +115,13 @@ t_molwin* init_mw(t_x11* x11, int height, unsigned long fg, unsigned long bg, - int ePBC, + PbcType pbcType, matrix box) { t_molwin* mw; snew(mw, 1); - set_def(mw, ePBC, box); + set_def(mw, pbcType, box); InitWin(&mw->wd, x, y, width, height, 1, "Mol Window"); diff --git a/src/programs/view/nmol.h b/src/programs/view/nmol.h index ab92eda497..4ce99f45ff 100644 --- a/src/programs/view/nmol.h +++ b/src/programs/view/nmol.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2019,2020, 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. @@ -50,7 +50,7 @@ extern t_molwin* init_mw(t_x11* x11, int height, unsigned long fg, unsigned long bg, - int ePBC, + PbcType pbcType, matrix box); /* Create the molecule window using the x,y etc. */ diff --git a/src/programs/view/view.cpp b/src/programs/view/view.cpp index f3c5b5ce84..15395ab090 100644 --- a/src/programs/view/view.cpp +++ b/src/programs/view/view.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2017,2019,2020, 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. @@ -130,7 +130,7 @@ static bool HandleClient(t_x11* x11, int ID, t_gmx* gmx) case IDEXPORT: ShowDlg(gmx->dlgs[edExport]); break; case IDDOEXPORT: write_sto_conf(gmx->confout, *gmx->man->top.name, &(gmx->man->top.atoms), gmx->man->x, - nullptr, gmx->man->molw->ePBC, gmx->man->box); + nullptr, gmx->man->molw->pbcType, gmx->man->box); break; case IDQUIT: show_mb(gmx, emQuit); break; case IDTERM: done_gmx(x11, gmx); return true; @@ -241,7 +241,7 @@ static void init_gmx(t_x11* x11, char* program, int nfile, t_filenm fnm[], gmx_o int w0, h0; int natom, natom_trx; t_topology top; - int ePBC; + PbcType pbcType; matrix box; t_trxframe fr; t_trxstatus* status; @@ -249,7 +249,7 @@ static void init_gmx(t_x11* x11, char* program, int nfile, t_filenm fnm[], gmx_o snew(gmx, 1); snew(gmx->wd, 1); - ePBC = read_tpx_top(ftp2fn(efTPR, nfile, fnm), nullptr, box, &natom, nullptr, nullptr, &top); + pbcType = read_tpx_top(ftp2fn(efTPR, nfile, fnm), nullptr, box, &natom, nullptr, nullptr, &top); read_first_frame(oenv, &status, ftp2fn(efTRX, nfile, fnm), &fr, TRX_DONT_SKIP); close_trx(status); @@ -275,7 +275,7 @@ static void init_gmx(t_x11* x11, char* program, int nfile, t_filenm fnm[], gmx_o /* The order of creating windows is important here! */ /* Manager */ - gmx->man = init_man(x11, gmx->wd->self, 0, 0, 1, 1, WHITE, BLACK, ePBC, box, oenv); + gmx->man = init_man(x11, gmx->wd->self, 0, 0, 1, 1, WHITE, BLACK, pbcType, box, oenv); gmx->logo = init_logo(x11, gmx->wd->self, false); /* Now put all windows in the proper place */ -- 2.22.0