Make PBC type enumeration into PbcType enum class
authorArtem Zhmurov <zhmurov@gmail.com>
Wed, 20 Nov 2019 15:18:56 +0000 (16:18 +0100)
committerArtem Zhmurov <zhmurov@gmail.com>
Thu, 9 Jan 2020 19:55:21 +0000 (20:55 +0100)
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

173 files changed:
src/gromacs/applied_forces/densityfitting.cpp
src/gromacs/applied_forces/densityfitting.h
src/gromacs/applied_forces/densityfittingforceprovider.cpp
src/gromacs/applied_forces/densityfittingforceprovider.h
src/gromacs/awh/awh.cpp
src/gromacs/awh/awh.h
src/gromacs/awh/read_params.cpp
src/gromacs/awh/read_params.h
src/gromacs/coordinateio/coordinatefile.cpp
src/gromacs/domdec/box.cpp
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec.h
src/gromacs/domdec/domdec_setup.cpp
src/gromacs/domdec/domdec_topology.cpp
src/gromacs/domdec/dump.cpp
src/gromacs/domdec/mdsetup.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/ewald/pme.cpp
src/gromacs/ewald/pme_load_balancing.cpp
src/gromacs/ewald/tests/pmetestcommon.cpp
src/gromacs/fileio/confio.cpp
src/gromacs/fileio/confio.h
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/pdbio.h
src/gromacs/fileio/tests/confio.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/fileio/tpxio.h
src/gromacs/fileio/trxio.cpp
src/gromacs/fileio/trxio.h
src/gromacs/gmxana/anadih.cpp
src/gromacs/gmxana/gmx_anaeig.cpp
src/gromacs/gmxana/gmx_bundle.cpp
src/gromacs/gmxana/gmx_chi.cpp
src/gromacs/gmxana/gmx_cluster.cpp
src/gromacs/gmxana/gmx_clustsize.cpp
src/gromacs/gmxana/gmx_confrms.cpp
src/gromacs/gmxana/gmx_covar.cpp
src/gromacs/gmxana/gmx_current.cpp
src/gromacs/gmxana/gmx_density.cpp
src/gromacs/gmxana/gmx_densmap.cpp
src/gromacs/gmxana/gmx_densorder.cpp
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_disre.cpp
src/gromacs/gmxana/gmx_do_dssp.cpp
src/gromacs/gmxana/gmx_dos.cpp
src/gromacs/gmxana/gmx_dyecoupl.cpp
src/gromacs/gmxana/gmx_filter.cpp
src/gromacs/gmxana/gmx_gyrate.cpp
src/gromacs/gmxana/gmx_h2order.cpp
src/gromacs/gmxana/gmx_hbond.cpp
src/gromacs/gmxana/gmx_helix.cpp
src/gromacs/gmxana/gmx_helixorient.cpp
src/gromacs/gmxana/gmx_hydorder.cpp
src/gromacs/gmxana/gmx_make_edi.cpp
src/gromacs/gmxana/gmx_mdmat.cpp
src/gromacs/gmxana/gmx_mindist.cpp
src/gromacs/gmxana/gmx_msd.cpp
src/gromacs/gmxana/gmx_nmens.cpp
src/gromacs/gmxana/gmx_nmtraj.cpp
src/gromacs/gmxana/gmx_order.cpp
src/gromacs/gmxana/gmx_polystat.cpp
src/gromacs/gmxana/gmx_potential.cpp
src/gromacs/gmxana/gmx_principal.cpp
src/gromacs/gmxana/gmx_rms.cpp
src/gromacs/gmxana/gmx_rmsdist.cpp
src/gromacs/gmxana/gmx_rmsf.cpp
src/gromacs/gmxana/gmx_rotacf.cpp
src/gromacs/gmxana/gmx_rotmat.cpp
src/gromacs/gmxana/gmx_saltbr.cpp
src/gromacs/gmxana/gmx_sans.cpp
src/gromacs/gmxana/gmx_sorient.cpp
src/gromacs/gmxana/gmx_spatial.cpp
src/gromacs/gmxana/gmx_spol.cpp
src/gromacs/gmxana/gmx_tcaf.cpp
src/gromacs/gmxana/gmx_traj.cpp
src/gromacs/gmxana/gmx_trjorder.cpp
src/gromacs/gmxana/gmx_vanhove.cpp
src/gromacs/gmxana/gmx_velacc.cpp
src/gromacs/gmxana/nrama.cpp
src/gromacs/gmxana/nrama.h
src/gromacs/gmxana/sfactor.cpp
src/gromacs/gmxpreprocess/editconf.cpp
src/gromacs/gmxpreprocess/genconf.cpp
src/gromacs/gmxpreprocess/genion.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/insert_molecules.cpp
src/gromacs/gmxpreprocess/pdb2gmx.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/readpull.cpp
src/gromacs/gmxpreprocess/solvate.cpp
src/gromacs/gmxpreprocess/x2top.cpp
src/gromacs/imd/imd.cpp
src/gromacs/listed_forces/gpubondedkernels.cu
src/gromacs/listed_forces/listed_forces.cpp
src/gromacs/listed_forces/pairs.cpp
src/gromacs/listed_forces/position_restraints.cpp
src/gromacs/listed_forces/tests/bonded.cpp
src/gromacs/mdlib/constr.cpp
src/gromacs/mdlib/coupling.cpp
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/membed.cpp
src/gromacs/mdlib/nsgrid.cpp
src/gromacs/mdlib/qmmm.cpp
src/gromacs/mdlib/settle.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/tests/constr.cpp
src/gromacs/mdlib/tests/settle.cpp
src/gromacs/mdlib/trajectory_writing.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdlib/vcm.cpp
src/gromacs/mdlib/vsite.cpp
src/gromacs/mdlib/vsite.h
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/shellfc.cpp
src/gromacs/mdrun/tpi.cpp
src/gromacs/mdtypes/forcerec.h
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h
src/gromacs/modularsimulator/statepropagatordata.cpp
src/gromacs/modularsimulator/statepropagatordata.h
src/gromacs/nbnxm/benchmark/bench_setup.cpp
src/gromacs/nbnxm/benchmark/bench_system.cpp
src/gromacs/nbnxm/gridset.cpp
src/gromacs/nbnxm/gridset.h
src/gromacs/nbnxm/nbnxm_setup.cpp
src/gromacs/nbnxm/pairlist.cpp
src/gromacs/nbnxm/pairlist_tuning.cpp
src/gromacs/nbnxm/pairsearch.cpp
src/gromacs/nbnxm/pairsearch.h
src/gromacs/pbcutil/mshift.cpp
src/gromacs/pbcutil/mshift.h
src/gromacs/pbcutil/pbc.cpp
src/gromacs/pbcutil/pbc.h
src/gromacs/pbcutil/pbc_simd.cpp
src/gromacs/pbcutil/pbcmethods.cpp
src/gromacs/pbcutil/pbcmethods.h
src/gromacs/pbcutil/rmpbc.cpp
src/gromacs/pbcutil/rmpbc.h
src/gromacs/pulling/pull.cpp
src/gromacs/pulling/pull_internal.h
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/pulling/pullutil.cpp
src/gromacs/pulling/tests/pull.cpp
src/gromacs/restraint/restraintmdmodule.cpp
src/gromacs/selection/nbsearch.cpp
src/gromacs/selection/tests/nbsearch.cpp
src/gromacs/selection/tests/toputils.cpp
src/gromacs/swap/swapcoords.cpp
src/gromacs/tools/check.cpp
src/gromacs/tools/make_ndx.cpp
src/gromacs/tools/trjconv.cpp
src/gromacs/trajectory/trajectoryframe.cpp
src/gromacs/trajectory/trajectoryframe.h
src/gromacs/trajectoryanalysis/cmdlinerunner.cpp
src/gromacs/trajectoryanalysis/modules/rdf.cpp
src/gromacs/trajectoryanalysis/modules/sasa.cpp
src/gromacs/trajectoryanalysis/runnercommon.cpp
src/gromacs/trajectoryanalysis/tests/surfacearea.cpp
src/gromacs/trajectoryanalysis/tests/topologyinformation.cpp
src/gromacs/trajectoryanalysis/topologyinformation.cpp
src/gromacs/trajectoryanalysis/topologyinformation.h
src/gromacs/utility/mdmodulenotification.h
src/programs/view/manager.cpp
src/programs/view/manager.h
src/programs/view/nmol.cpp
src/programs/view/nmol.h
src/programs/view/view.cpp

index 28ead0fcfa1b5398876e0b3766a5f9f373683d18..d5d8ea90afbaabeb1b494866f8af9e21e14607ac 100644 (file)
@@ -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<int>(pbc.pbcType);
+        pbcType_ = std::make_unique<PbcType>(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> localAtomSet_;
     //! The type of periodic boundary conditions in the simulation
-    std::unique_ptr<int> pbcType_;
+    std::unique_ptr<PbcType> pbcType_;
     //! The simulation time step
     double simulationTimeStep_ = 1;
 
index c453027137292abefd7bdbda08b62d9a4176002f..389e4144c5149f1317b3b9eb23f082e9b94b48fd 100644 (file)
@@ -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 <memory>
 #include <string>
 
+enum class PbcType : int;
+
 namespace gmx
 {
 
index 57f9e5a6a962d167d81cb120578fd0bd6f0bb7c7..3a404fb544d82240604b1dbc162ab4f1296883ab 100644 (file)
@@ -96,7 +96,7 @@ public:
          basic_mdspan<const float, dynamicExtents3D> 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<ExponentialMovingAverage> expAverageSimilarity_;
@@ -133,7 +133,7 @@ DensityFittingForceProvider::Impl::Impl(const DensityFittingParameters&
                                         basic_mdspan<const float, dynamicExtents3D> 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<const float, dynamicExtents3D> 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))
index 16a121ba3432d21ee32dc30e9393bac563b80678..5ceb11501dc06b6b17765b8b87bee0c4dc0f6267 100644 (file)
@@ -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<const float, dynamicExtents3D> referenceDensity,
                                 const TranslateAndScale& transformationToDensityLattice,
                                 const LocalAtomSet&      localAtomSet,
-                                int                      pbcType,
+                                PbcType                  pbcType,
                                 double                   simulationTimeStep,
                                 const DensityFittingForceProviderState& state);
     ~DensityFittingForceProvider();
index 76046ff09bca60337681b77b5aa22ea9642a829b..610f67470c89593975ac0304dfc87caf7666ba50 100644 (file)
@@ -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
index 5c57dfabe137574859c1e32cdeaa1b7a23a9c97f..e7e537f4cd3a5e1d92d8d5f9b4078e83b57eaf58 100644 (file)
@@ -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,
index 6427b48e38cf50877602170772f7aaf37d1c0595..916bd7d45d9c86efea71b554dedcef5fffd3f44a 100644 (file)
@@ -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++)
     {
index 5cdb9000c62275719c22a643a8f9bd0b7033afa7..9ba8e282eb899a620069e0c17451a66ea34f0fd3 100644 (file)
@@ -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<t_inpfile>* 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);
index 4c245b12725c4d706422dbb3681d65ec01be4fc8..8bc9224ac27e3bd76695fe51e597e7a082eb11b2 100644 (file)
@@ -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
index 68825bbf90eebecc78b98a22ff12b6e3a1f57337..03b0e9f69a33258bb6fe1eea00303e5726a89c80 100644 (file)
@@ -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);
index 3e8a3d87c93875c503752b948cea37c965a1d786..49460d9493e09f1d5367cf655203557864173afe 100644 (file)
@@ -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<double>(dd->nnodes);
     }
index 6608dc7d4e678cd36e0fd93192fa81efc45b90c9..b7d4fb56ddd45aa099c7e7f8370ed71f13f90a1b 100644 (file)
@@ -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.
  *
index ce77acd4190e22dda3fd2630f78876b465971d1f..3889a62043d2631425cc1ec46d05a820fd80f85d 100644 (file)
@@ -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))
         {
index a8424c8a6c1764fd28d2871cc017a10f56804fc4..8cc5430000bd636be847a151888b6d2a0a040a87 100644 (file)
@@ -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);
index e0e1a549e7c0b527911402facb53b54421943e72..c3f7eaad13a8d541419432038697c88943cb1055 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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++)
     {
index 5ba8445574178006543567d247fee4c76597d196..24edea6acbebd39a4a6b61e66bb9ac4de94151c3 100644 (file)
@@ -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");
 
index 3c701a279b5a09ad4c03c03a5d2dd0e1aa3181cf..ba16e34d72453923d7713a3ea09d7341823f5d17 100644 (file)
@@ -2774,7 +2774,7 @@ std::unique_ptr<gmx::EssentialDynamics> 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();
index fbb59bdf92f978a4f0c466a75e7e7ecbef1fc270..d6cd44b346b0708f15cdc3588aebf3fbf3d46d14 100644 (file)
@@ -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;
index 33924d5565db1f0b38886e5a56fc5334315770d2..f48a9556b568e5a030571a3d973bcb12398169fe 100644 (file)
@@ -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;
index 543dff85ff7c38e5e0a9b5c62e89b70e611056ce..198c77cadd8eb9d1e01883f4f5f28f97b85b69a2 100644 (file)
@@ -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)
index 8b3236c2e103ac4589d91e0e363662a7a9b77a32..7114d54c6d7e56862080fd25fcaaddc440d98e1b 100644 (file)
@@ -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);
 
index 5640f50637262664b98be857a072a13d3e31120d..08af69c205ef465e727c040d8a9b9fa2e8bcaa8c 100644 (file)
@@ -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,
index 115a556804ac97c0e7418f35df92b1aabadfdb26..74f776ed90bb112aa382bd4f5b4e6dfe9083619a 100644 (file)
@@ -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);
index a45f17bad6bd07f96cd3ac0c27cd3c1e3c2f7060..d9e918c27590854c3ef0086c73e44cf8a3059c60 100644 (file)
@@ -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. */
 
index e0f6c7231f271214ca7ffcc3b600a1786975b506..53a1216ff3352abfbdd0008996f0ac1f1dd15fc2 100644 (file)
@@ -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_);
     }
 
index 7b11b7c065ebda74e19d91d3aadd29c66fa53bb6..c39d7f0edbd4f80ad27645ad0ea4fe38cc6ab27a 100644 (file)
@@ -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<int*>(&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)
index a925caba91258d1ab41e33503e636a732636c814..b3633a7c792522272fade48177b8430095c4f896 100644 (file)
@@ -43,6 +43,7 @@
 #include <vector>
 
 #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<char> 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);
index 4deccda3738dc1948ea17c8509151e37cc052dbd..06ff8bcf12af59313c64b003711044a002f27726 100644 (file)
@@ -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;
index d1b8ad1b06e679c334cae6f09fcf4485ad338208..8940bc5903027568551415478dfbb5eb4544c819 100644 (file)
@@ -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
index bdacdd2fa44a4aab389ececbc01f82be534dbebc..a015a329b8ef12d36a8ff9c92c9820f3ea0ddad7 100644 (file)
@@ -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)
index ce282f7b6fe12aa79994ecb0426f185e27f50cfa..448640c2d45b7e910ff4ba7b013048971ba9f240 100644 (file)
@@ -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);
index be9c6f4be60f30e0303121338a1052a129ea8315..a55cde5f9596dcfa5865a0457f8f074bdbde9f93 100644 (file)
@@ -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
     {
index 03e50be5d9621d8105310346410b9672cc67dd77..21be848c9861e8f7a2459cdfdc7aaf2bd43a0f8d 100644 (file)
@@ -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)
index 160ddc64b3f15d8f4cb30df45a05ece90236a631..751c62f6d0f6515f428c441674a812634f64ffc0 100644 (file)
@@ -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");
index 69c815c130db669ab2162c4bbcd38953d71ebd6f..fd64ddf7f9e8c59a4d11f76f86d5f25a90ad0051 100644 (file)
@@ -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;
index 40d756f8f0f73554a4fd852674ccb9323c4e5e3f..213aaf11304477045b1329da1721281a2920a46e 100644 (file)
@@ -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;
     }
 
index 9fa548e9bde4f929f8448b364c80c9488ebc2ccb..5fa50372bf70a467c0642d32076df33cc5b1f655 100644 (file)
@@ -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<int>(ndim),
index 4010e2751db547e7f3a6e53d92e6b6f44c2c1903..067f46c797df0162caf343c1733dd9b0304cfa5c 100644 (file)
@@ -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);
index b750f13e0abc1a4be655815d05611d1b64db650d..1a15db384e0c55c3b19b18d5d0909fc41c072c7d 100644 (file)
@@ -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);
     }
 
index f9bca9de09560ba2f0c228c1576b4b67cd8ab281..f9c838b2a723f28db2e0c8245be4be1a8494c358 100644 (file)
@@ -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)
index 194a3b4a3519e3858f0869ccccbadfd2a1983b85..0942cda75c196793ee994a10f7347ede56e58994 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, 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)
     {
index 0ba82617c66ecda0e1a383192281f9db315745e5..4f5e8f2d001ef1d82abbd07f52557b97f55f59fc 100644 (file)
@@ -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,
index 57d58981ea36bdd3ac8e832ce65dd008f59f661f..5aee92a34824153f0b7c1e13d6bdfccc362d9d78 100644 (file)
@@ -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);
index a52ced5734830512a6d6f455d9d04b4f1fab1de0..f030505f71cb9762239b1ac66f586337b1002e87 100644 (file)
@@ -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 */
index 344ad272ea00bb5650a2dacccd0fe6c8c9e8c5d0..2c1a9717c4e8f6817d4a0b5320c5f81dd951453a 100644 (file)
@@ -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);
index 2391009e845e51bf00d44fcaddf2d34226771922..301ca77e8ee8da3abecf420d2a35eae848faf289 100644 (file)
@@ -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
index 45505439f4efac51fc25319a1e5700fe88e6c137..c9567a806b3c9a39195219fdc9ebe8ee9b432c2a 100644 (file)
@@ -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);
         }
     }
index 4a723ef3994755476dfb23241f1d100d75b57780..6df19ae6fefeb385c95e1a13455e2c4b519df7d2 100644 (file)
@@ -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
     {
index f3abed6da444b5267e2afd33e542ee97dad36172..1e52fe0b491ac09cc4d5024cae6931318e39455b 100644 (file)
@@ -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);
 
index 2c614d1a445c2ac53791a36bfcae3fb3c1a314ed..2348ef122a07fe9ff3b5cf23d381c59d803fd78e 100644 (file)
@@ -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<int>(acut / abin);
     nrbin = static_cast<int>(rcut / rbin);
index 44959544345e67e2f9af81c8ed717c39b37c38ad..0b9399ae094ec89db859d024e4b06bf4a98b2f3e 100644 (file)
@@ -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);
index fef5d10ae4b7412eec6c64d30e69095f2c380682..c5651ce84ae7d0e38f686ff007ff2aaf06915d5a 100644 (file)
@@ -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);
 
index c7f81a1ee47eedacd2b344a7260e5bf9ca80b7ac..9e45a5ba7d157842597cdb64ab9d28dde809a6f1 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, 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<int>(box[XX][XX] / binw + onehalf); /*Calculate slicenr from binwidth*/
     *nslicey = static_cast<int>(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++)
index e3dbfe1906c20c7b69d79969e318cc2ac8cd269b..288cff7feddf509f77bce3d1c9f3b1487e841d78 100644 (file)
@@ -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;
 
 
index 9667fb4a2179f2025072d12d844ad4b06fec71ab..a6a9058d7aeb6878ad564bc9b8309adc7fdad4b3 100644 (file)
@@ -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++)
index 6619826f8b597af0bff1837a08952a41241e4eb3..ed51f851d9a415b1f73a8feec5181a1d4a6896ee 100644 (file)
@@ -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");
index fedacb0c3182b81468fc08f9168e019c5709eed7..deb0ac25391c0c9e3a07147c30819bc12cc734c4 100644 (file)
@@ -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<t_corr>(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);
index d031be69019a67a7c5a3401526cf19611d573390..78859917b490e235375a61b168d584d730a4ebef 100644 (file)
@@ -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);
index 7c4557cec0c350845ff1b4660143176ab6900a19..c752308e9217b59df0f8758f17a159e64e6db284 100644 (file)
@@ -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 */
 
index 31f4d27d43b6a575709a4986e1c02f9bd0c05f9e..aa97af5f97d8b4a63cc17e1f475a8eef32838a6b 100644 (file)
@@ -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)
index 9cbaf1ec962740d2ee214e0f0a462f9fc6443520..ee1cfe1af4e367e400a820bcde332bd361fc6ad9 100644 (file)
@@ -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
     {
index 943ab872ee76f7d075a2a48b21d29eb240b124a4..fb417b0f8f5815b63625efa4faf85b129eb60c7e 100644 (file)
@@ -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);
index 8201b3ee70dda8fc5b838715aa1bb2ab4255123a..40092a218fa8188db069a20b35768dfa40d08d86 100644 (file)
@@ -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
     {
index 6efc874ce057552316cd9ffc26e1d3f1c4ace45c..43c3419d25c2e3ffa14ec82c3c2fdc63f3f92f8b 100644 (file)
@@ -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)
index 65b1e2bdba165bc8381ed490f7bd65585beeddf4..af6235491905e7c1e5ea5f31562bc0c976375e1a 100644 (file)
 #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);
index 1884a9f6a7853f8f5f8772b66f6d9399cbfd0bb1..c0c439afd6af2c7174b364df59c64825402f4914 100644 (file)
@@ -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)
index 5c1af316685c765708e855425276d52903532466..048c663158d1d9159c38c548c70d82e78d5d2d50 100644 (file)
@@ -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;
index 9aa0fd82cae26e4f836794288d922253429ef3f1..6bc93086afa5c94e42dda1c545480e5843f78482 100644 (file)
@@ -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);
index e7980d845bcbace3c1c1b26a6be20422ec310338..e82a4a365f4a98a943bd3320dd93adef36a0411f 100644 (file)
@@ -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++)
         {
index c9edbbc6e7496c64520ece8f608ad680acf2cfe6..ab77d08a1cf938135939bbaa950ae93a6eb278b0 100644 (file)
@@ -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);
     }
 
index 3d8d922cb9ce4a0b95c8e574636861f7f8a9c81b..4561a28a807b66c01ed2c4d7621823bcb8e310a7 100644 (file)
@@ -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++)
index 694df6790ec8f09615d90768d83522e0c6bcbe8e..0ec43ffafda9f4a68fdc4bbe948b17d00c0755d8 100644 (file)
@@ -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++)
index c52f4ab7a50b40ff533033e023b1324b41c9ee4f..d67045be907debdfe1c247d4f380ea00665b474d 100644 (file)
@@ -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++)
index 734ad4c0ea4f8beea3b08986dc6f9d3c8a556839..03e9f2c6ad4d7f0022bcbbf6bf941b21563e0ad9 100644 (file)
@@ -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)
index 7a6f5d5a9cf044b78995dbcb53317b9049726ecd..93c811bb5a223ab7d2032910864ba7564630cfb5 100644 (file)
@@ -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 */
index c0f8fe28cd7cb47636343c3df0ee7f1424335ac9..96966c9a00ab73368617ba7a440d798eda65cfbf 100644 (file)
@@ -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)
         {
index eed02c0dcb924d21b6cb609bc93adfd6a114ae90..44edc6539d9f985ecc044f0a04e5909e107305c5 100644 (file)
@@ -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);
index dd94814e2e9bcbfd699e0fe0450cf456afc06246..48a0ee567f4001618c9445a0bd8394db0f73fcf5 100644 (file)
@@ -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
index 412fdce66e09d47175953a199b6c9e00bac5a67b..1c92c76e1fd2497bb8d8cad4390b135db99457a6 100644 (file)
@@ -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));
index 6aee0a3e94c95ba101fa9d62d0044e5b025c471c..71c00fded00fa8081d4c8131b10c96d108c0d089 100644 (file)
@@ -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;
 
index c9249c2e9f9ba3aed58e0a3dbf628f024950f392..87b08d6e84fdac5856b32ba5e8ef67770593968a 100644 (file)
@@ -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... */
index 72d398d52bf4069ec4ea8377113a60511209d170..45f02a99ccc937e1ed5ef6771b395b8d136fbb77 100644 (file)
@@ -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);
index 1e0897899984da17176fc5e78659c2dbe54af01a..37d6384f6e7847d06df60e54475ec7ae6052da29 100644 (file)
@@ -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);
index 96519dbfe4dffc873032ec02768472963f74e825..165e115e8df6de5b6692d441b8935f09a36000d6 100644 (file)
@@ -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);
index 854db40b50c40a077f58b95bceff16457417fdad..28562ffeb4904b5d305e5decd32a893e363fb8c0 100644 (file)
@@ -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);
     }
 
index 209abf3e0947bbfa81fdcee66b9077f4502e8469..6afabf9da4a36ffb54c28906c3a28569e70cda7b 100644 (file)
@@ -175,7 +175,7 @@ static void insert_mols(int                  nmol_insrt,
                         const std::set<int>& removableAtoms,
                         const t_atoms&       atoms_insrt,
                         gmx::ArrayRef<RVec>  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<RVec> 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<RVec> 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);
index eb9da92af512420b7b8531104c4b48674a2bdd64..f3885d21edd3934862df84308a7384f2ea8959fc 100644 (file)
@@ -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);
index 9a5e6908edd86719bdd72c7e05852f5b64bb6d77..657fcea1e64c1251cf396c72933b5454799c5c3c 100644 (file)
@@ -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<const char*> pbcTypesNamesChar;
+    for (const auto& pbcTypeName : c_pbcTypeNames)
+    {
+        pbcTypesNamesChar.push_back(pbcTypeName.c_str());
+    }
+    ir->pbcType       = static_cast<PbcType>(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 "
index f45a0e4d692d9f00df83e4b2c99bba144dc6295e..6aae234fa7d13d1c1aec8ae95763a40f78eb8104 100644 (file)
@@ -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;
 
index 3a6ee40ecf407a8dc38ff64d85cfcb5b92a8d22d..054d5b223ac1f3dff596ecd101c6de159c960903 100644 (file)
@@ -608,7 +608,7 @@ static void add_solv(const char*        filename,
                      t_symtab*          symtab,
                      std::vector<RVec>* x,
                      std::vector<RVec>* 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<RVec> 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<RVec> 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);
index 960e6252c2d185da1e91dfe97fa0978c036a9858..4aff04ce7c84dda1a5540dfe8031eafb0b7e0473 100644 (file)
@@ -110,7 +110,7 @@ static void mk_bonds(int                 nnm,
     std::array<real, MAXFORCEPARAM> 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)
index 9dc5c3d876433300c3da8bcf68d91cdf24fb3dfb..6126e65fee3b1a9a6780b72b5278a62d52733822 100644 (file)
@@ -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);
     }
 }
 
index fbb6baee1f5e85caeeef6444da5eb22499f78e1b..a1c81514af0db6272a55b138c312db1fd66afa9f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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];
 
index a64cdc02372777eb0fa30f750368df8267b556d8..2d1797f1d76b69a79495e198e0a7a2068f562de1 100644 (file)
@@ -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);
index 9a5a401db73e789dd7ea63e7921d8414a5a1bfcf..c3fee5885fdedea0ce10946799e3a007daafa47c 100644 (file)
@@ -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;
             }
 
index 84359236cb5a3052e27dc4cf09fbd719e325d2ea..36482d071239191eca072af68550b25b83a073c9 100644 (file)
@@ -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<true>(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<false>(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));
 }
index 4447cced8c34eaa9f2950ad5a5fa9e8d4f4ad5e5..c67f0c6563b55d26573534128d0083cc55b9367d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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<t_iatom>* iatoms)
 }
 
 class ListedForcesTest :
-    public ::testing::TestWithParam<std::tuple<iListInput, std::vector<gmx::RVec>, int>>
+    public ::testing::TestWithParam<std::tuple<iListInput, std::vector<gmx::RVec>, PbcType>>
 {
 protected:
     matrix                     box_;
     t_pbc                      pbc_;
     std::vector<gmx::RVec>     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<t_iatom>& iatoms, const real lambda)
     {
-        SCOPED_TRACE(std::string("Testing PBC ") + epbc_names[epbc_]);
+        SCOPED_TRACE(std::string("Testing PBC ") + c_pbcTypeNames[pbcType_]);
         std::vector<int>  ddgatindex = { 0, 1, 2, 3 };
         std::vector<real> chargeA    = { 1.5, -2.0, 1.5, -1.0 };
         t_mdatoms         mdatoms    = { 0 };
@@ -661,7 +661,7 @@ std::vector<std::vector<gmx::RVec>> c_coordinatesForTests = {
 };
 
 //! PBC values for testing
-std::vector<int> c_pbcForTests = { epbcNONE, epbcXY, epbcXYZ };
+std::vector<PbcType> 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
index 2fdb1dddaedf6dc4ee07a14353104f56f935ef1c..e17685d74c2ed56f3f1fa101d5a8909baf61aaa8 100644 (file)
@@ -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)
index ffcc4ca76a8f950049ba91d38c9271d9269e0e89..4281a845362041a08a99a77820f45e799d0fb365 100644 (file)
@@ -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);
     }
index 937b33b7ecc9bed6ac9f04ac781cd1e03560cef9..0bc7b13c8cc9ebf7b6b027296549361db50dea37 100644 (file)
@@ -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,
index adfb6caf090e7a8d97387b39fc1585f9440f08bb..1aa3402e78804208734ebb2168d01985f8d24304 100644 (file)
@@ -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))
             {
index 897c784d476b34aa5e27f4fd33c352fe84608b50..7a37bdfef1137a52473f73434f40cac0c9871ec3 100644 (file)
@@ -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))
index aa6ebecd6c7754d981f049e9064b1c9d786e5875..06266039e6f9a7a1aafdf681f9d9b465e0e6d548 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, 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,
index 82173e7edc00151459bfdf9353025fb50d8f7f3b..e9f7f0c9735036ad769dc4acedd1e4477ce4c4dd 100644 (file)
@@ -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;
     }
index 07306e4aee8988b7dbab3c2011f1c01ed471f689..5de20a019e9d9c8a1b892af8d58e86e472f3bf98 100644 (file)
@@ -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.
index d381e65d2d54ae934a2bea6ab6236a85fb575cd1..f8f183bd46e8502c4400fa186e64e4824459e7bd 100644 (file)
@@ -848,7 +848,7 @@ void csettle(settledata*  settled,
         }
         else
         {
-            set_pbc(&pbcNo, epbcNONE, nullptr);
+            set_pbc(&pbcNo, PbcType::No, nullptr);
             pbcNonNull = &pbcNo;
         }
 
index 23f13f66110b5272514dd0770da0bf94a0cacf5e..934714a2a00f194c2018aaf1e38970ef559a1dfe 100644 (file)
@@ -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);
         }
     }
 
index 5883fd926188246ec63401b254effa22f20f8aa1..5316e0c849b9f7a1488955107f0aaab601f0edae 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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);
index a97a13157257ab6014cb58a4c3ae4376e54e94f8..bc7025c5b1e77667114c3e85b0921af4704ed8fc 100644 (file)
@@ -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;
 
         //
index 225c8844e1d8f863b4b8f2125a00026bce13cdd8..9c87f46c4c237a84cbf8c13ef33ae17b91915c51 100644 (file)
@@ -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);
index 86632a604a3f88b2c3440e79da000e3a5e4eadd8..5b9607b2aa37a18122fc5bac6b122c960287ea2e 100644 (file)
@@ -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.
  */
index a2d998d8ae6655d8098625442026f0f913da38b1..b6997b6e089425bc63702d44db2ce9008adf0887 100644 (file)
@@ -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)
index a2b7f73659f5efbcfa5412eaddb295fa8d3d21ad..5d8d19ef21e83b579974f3e7b476570e7ef255ee 100644 (file)
@@ -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<gmx::RVec> 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
     {
index 84e33aaa88336ccca14911b555e084f92e43e5bc..8069b6250c7ea87d17f57d2fc9885db171793203 100644 (file)
@@ -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,
index 15cf25ac1d98cc77284db1ab5d500c655f91e82c..f7d0e0f644e2bf479b99610d72acdbb6af21e35f 100644 (file)
@@ -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);
         }
 
index a934bdbffa7801971ed8c208d4ff203efcc34512..5430e6e83ffa1cc00441db5dccd1838d84b8e3e0 100644 (file)
@@ -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)
             {
index 93cf1c19e1fdc3593c3f9772af5165c25c9b8082..593d432b37000b8bb3830c2f9f879a904e764ced 100644 (file)
@@ -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.) */
index 6b57ab32cda213b42f989f68523c3b85f6f9db28..c5e3fcf0b25490e137ccac6b26bc0223c1fef121 100644 (file)
@@ -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)
             {
index deb9c503dd636310f84a9a204c1fce96927ef08a..cf2d8a96631f504a4fcf32be1ecc635e0f02e512 100644 (file)
@@ -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)
             {
index 357dbe1c268b7c0a743439288d70889cceff0218..8f27d7f6ac5ecc98a3cd05a20abd5250d442c390 100644 (file)
@@ -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)
index 4c808700fe5724721552dd7d96de899176ed21ff..9b1dd8f7e6137c9a475606b8f249146ee7804915 100644 (file)
@@ -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<int>(step));
                 sprintf(str2, "t: %f step %d ener: %f", t, static_cast<int>(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++;
index 0ef5d43f1e72c968379498b42066328f3766e75f..20ef5e32d088db5bf64e1408e537e5b9f1e45a98 100644 (file)
@@ -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.
index ec77f940f08ad37b2d16cda57a69a3e11ee16cd5..c7a4ea7096b384c4a5ab41d77035d554c4edba51 100644 (file)
@@ -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<int>(ir1->pbcType), static_cast<int>(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");
     }
 
index bf1a003f4f2e503f3b9b872aeed5067e886cfa3c..4659516b558fb08d469f7bb7768ecb13405ec12a 100644 (file)
@@ -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)
index c0ed27be688ca93c6e298b743f84ac6291224b6a..0a02f40a0d9706dc991ed72cf0b9aa98cdfc0bd6 100644 (file)
@@ -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),
index 71a3d269f30799543d668331aa77564c77dcc920..3236adf61c11526bfdcf173cfd2ac0e0637f859d 100644 (file)
@@ -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)
index c2c2328f66508dda20d36da78c8cfa96777c1e63..eb29b2092fd8a56409f4c0aab1e8ec273f2aa3b0 100644 (file)
@@ -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<nonbonded_verlet_t> 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<PairlistSets>(pairlistParams, false, 0);
 
-    auto pairSearch = std::make_unique<PairSearch>(
-            epbcXYZ, false, nullptr, nullptr, pairlistParams.pairlistType, false, numThreads, pinPolicy);
+    auto pairSearch =
+            std::make_unique<PairSearch>(PbcType::Xyz, false, nullptr, nullptr,
+                                         pairlistParams.pairlistType, false, numThreads, pinPolicy);
 
     auto atomData = std::make_unique<nbnxn_atomdata_t>(pinPolicy);
 
index bf2768b4146da30b8670dae73867d2f78a50a991..553f4cafd26df838b92570d1e4187bfe4bc5bc98 100644 (file)
@@ -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,
index f171317019f93533ec40d4605343cbb9d38f7931..1adcff76a67218b481c024f88107ed8ee352144c 100644 (file)
@@ -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),
index 3980a37c6852246909cc8111a995d02070838fec..3e9ffe4c8a9ff7a856a1c50a543b13f16d664f79 100644 (file)
@@ -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,
index 686179accd91db4e7399a735afc04febf3499792..cb3a2309297efe4fb00406e14d32d9ea4ef706d4 100644 (file)
@@ -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<nonbonded_verlet_t> init_nb_verlet(const gmx::MDLogger&     mdlo
                                                        minimumIlistCountForGpuBalancing);
 
     auto pairSearch = std::make_unique<PairSearch>(
-            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);
 
index c3e29ab205a6a88d6e941404eb8cf5a8b0dd1c5d..955c0967e6c4a273fdaacefcb9a321d107326079 100644 (file)
@@ -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;
index c997ba8709124ef8b4b23344d2cdab4e70851593..c1757d87a8d5c179ac286fe7f2c11a62880b9161 100644 (file)
@@ -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))
         {
index fee162cbdcddf3e4788a41069554c06f88886244..34f064b2cc1a47244265de78e1c6040ea9923616 100644 (file)
@@ -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);
index c0cb647e7190d6032b9f2b7a7a8cbdd6a62e2de0..4263d9ba5bbe484d7c8779a346da97db7999a68c 100644 (file)
@@ -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,
index 61797feacd5c606a80fa121235a46d2edfd4c166..0bd4f8e73be83f42d7fff310f5b41e204a9c9fbe 100644 (file)
@@ -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(
index bc73a6db54081e8b5fd45716c01e97740cefe014..db370317230acf329f7ae3a1c6e138a1c79ff228 100644 (file)
@@ -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[]);
index 03a9ac7f6beaa6c63b4e7e2cf7288b29d0b51d4e..0f7a21fc5ed5cb65eb400387151d7955f6a4432f 100644 (file)
@@ -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<PbcType, std::string> 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<gmx::RVec> x)
+void put_atoms_in_box(PbcType pbcType, const matrix box, gmx::ArrayRef<gmx::RVec> 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<gmx::RVec> x)
     }
 }
 
-void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef<gmx::RVec> x, gmx_unused int nth)
+void put_atoms_in_box_omp(PbcType pbcType, const matrix box, gmx::ArrayRef<gmx::RVec> 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<gmx::RVec> 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<gmx::RVec> x)
+void put_atoms_in_compact_unitcell(PbcType pbcType, int ecenter, const matrix box, gmx::ArrayRef<gmx::RVec> 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);
 }
index 38feb1d64ce9843ea4fe5a91a318bc6935c68554..d7c50ff4325c47c69a859fb81c26c76fdfd45727 100644 (file)
 
 #include <stdio.h>
 
+#include <string>
+
 #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<PbcType, std::string> 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<gmx::RVec> x);
+void put_atoms_in_box(PbcType pbcType, const matrix box, gmx::ArrayRef<gmx::RVec> 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<gmx::RVec> x, gmx_unused int nth);
+void put_atoms_in_box_omp(PbcType pbcType, const matrix box, gmx::ArrayRef<gmx::RVec> 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<gmx::RVec> x);
+void put_atoms_in_compact_unitcell(PbcType pbcType, int ecenter, const matrix box, gmx::ArrayRef<gmx::RVec> 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
index d27661821c31bef364b3c831389a7df423b6a365..fa824891a7b514b89b1e444b30dec63defd120d6 100644 (file)
@@ -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 };
 
index 7cdd4e1ca72097eec26def9bb201eae12f693919..3b8f887feed3c4c2a19fa0a85717992f67f0a2ac 100644 (file)
@@ -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);
index ff796c5c9b5c49bbbacd0f79f35b17efee89d743..262d32a8629370cb3784062f33a3dae25c9971e1 100644 (file)
@@ -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[]);
 
index a973e729c25bec5b76e25e0788820c2e533f9be0..92792d4df261ec3ff9d20f41de5a418ab7ed6906 100644 (file)
@@ -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);
         }
     }
index 0feb096495a13e1541502761f2e5d4925f60ef53..1b93ae538efd5f5a9aa8215df57a7e9851a75094 100644 (file)
@@ -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.
 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[]);
index 157d7f9779b8c5678e20d0716fa0b0a628d2a77b..712399a7f19f755f5de12f832bbcbe21df9ec7f0 100644 (file)
@@ -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);
     }
index 1a8f500fb8c318e897ec3990a042d8d855ed36a3..1973e5f116034ecdb0c190e1b487ace9b6e22610 100644 (file)
@@ -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 */
index 1ae8f45edda3309d9d9efcfaa2a90ca19e9b2a83..641ffcf52877ee238f38f21d95079df78f770a56 100644 (file)
@@ -3678,7 +3678,7 @@ std::unique_ptr<gmx::EnforcedRotation> 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
index 2b75b64ca60dacf3cee7847e6afaf31c5bd1da4e..44620e53824044e21b4467841a5f44d7c9470c14 100644 (file)
@@ -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;
     }
index 416f02deb152424eb7d63543aa63582db17eb624..21956445bef1ea8203785a8eb4b925efbd1af736 100644 (file)
@@ -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
index e1e7f65a88f77d346fdf55813cb9fbefa56af324..a6ba84eeee54eddb1d16d3d3bf38d1a416058771 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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_;
index 96686d6849ef3a2f41cc650e476fe40761a30a72..96443c208da233a26f60c0cc009cad3e5f18fb74 100644 (file)
@@ -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);
                 }
index 1caa6ff6039155c02883eddda6ba903d2b18ef79..ab8d19566ecbba58a3d6cbf52575fe8cb7441968 100644 (file)
@@ -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);
     }
 
index 053403afd70d698e1669237f398c00d3223291bf..77885f791336dc78de1de1ba24560bcdf2529af7 100644 (file)
@@ -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<gmx_mtop_t>();
     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)
     {
index f28a9734b8f8c9468c9526a1099c7f6eded0d7bf..a9290efe6504f9eff0a331f35fb9a0ecac49b1ed 100644 (file)
@@ -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
index ce0b41544a33280dd3391306e400bc74bc4e1473..03e4ffd85e9b08fe730234c24e641d8280f7559b 100644 (file)
@@ -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;
index 45c0383797ba3d6e084f8d3fc5e95ee969a45458..34ecf8179847b002e30cef56fc4f7724f5753521 100644 (file)
@@ -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)
         {
index ed19c7df189ad734157fba59fb37313fe67a11df..43274a7522d4cfdb496383daa71bb10959466e5e 100644 (file)
@@ -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 = "";
index 7baabd02a5a4e9e3933a39271de7fa96ed746868..c45a3b7878908fcf456eb7641d4a754c349115b4 100644 (file)
@@ -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<const RVec> TrajectoryFrame::x() const
index f0e77d69ea11a021b2c876c930a7461dd6ba9223..0adc4dbfad36fff25714edad40dc738d3ebef170 100644 (file)
@@ -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<const RVec> x() const;
     //! Get a view of velocity coordinates of the frame (which could be empty).
index 755782d8270a2aabdfe376922121b46e184b9336..fb0d2e17bf538ae4b596e22257edc54338f674e6 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, 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);
index 6dd388f3ad60207eb77a78146efaf246cc1457b2..bb2f6249198ee86fafcefdebb7dc20bfe6c9a9ae 100644 (file)
@@ -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
         {
index ca14fcb5206ab2b9b7c549b042127fe664d42ed0..9b581dad9d0a453ebb80d01b21432ddba5beafdc 100644 (file)
@@ -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<rvec*>(box));
+        write_sto_conf(fn, title, atoms, xnew, nullptr, pbcType, const_cast<rvec*>(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<rvec*>(box));
+        write_sto_conf(fn, title, &aaa, xnew, nullptr, pbcType, const_cast<rvec*>(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);
index 7496d39102097565003ed6cc36bd61a8b0a85da7..92d9e52ebe9fe99e8be9f04e5b9c77b223d02452 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, 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_);
index c855d658c0e8578cb54248aecb2c0f82ffe21c39..cc144da4ed9bb4d536795af8c4a0d9a95cbadbe2 100644 (file)
@@ -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;
index 7124600ac93fce4b5bd1f3dea512ca1ccd88d147..4728ed6d9652557b3f19c706c621f1bf41a452af 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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();
index 74f1609e51235feea3a2c6c6c33630d42c9cfbae..d3086056c0857f10997868dad8add1433febeec6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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
index e9f9d5374d47be1e683ade016c4402e0d1595192..2f353d000720a445dfaae5bc6b49b575677e927b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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<RVec> 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);
index c56160420d3457ae8bf6886ab386666d2895f79f..891ec575c24164bcfdf90574838f89cc4663e9db 100644 (file)
@@ -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 <vector>
 
 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
index 528939813ca4c1c98005fbbf32e4d067cce05d77..d5fbd842f365399b8f8365728134d6093229a1e5 100644 (file)
@@ -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);
index d0461104d045781888d9321ec700d0f31c965fd7..bdd7727b3da62273fb60400f67c3b5fda23c7f4e 100644 (file)
@@ -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 */
index 12a7a9e421e5a9bbf32053d24949b3d592e2ef49..1c1123ea6cc1e17de1e47703ee0483626be380b4 100644 (file)
@@ -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");
 
index ab92eda497dbdceb63e3f6c2aaf02ea3004881b2..4ce99f45ff4a49f5f2598f51c1ec8bf4777432b8 100644 (file)
@@ -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. */
 
index f3c5b5ce84669f7e8e03f6afb191901093ada1b4..15395ab0903629eb4ce50398b60866db74ad6180 100644 (file)
@@ -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 */