/*
* 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.
*/
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)
{
//! 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;
/*
* 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.
#include <memory>
#include <string>
+enum class PbcType : int;
+
namespace gmx
{
basic_mdspan<const float, dynamicExtents3D> referenceDensity,
const TranslateAndScale& transformationToDensityLattice,
const LocalAtomSet& localAtomSet,
- int pbcType,
+ PbcType pbcType,
double simulationTimeStep,
const DensityFittingForceProviderState& state);
~Impl();
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_;
basic_mdspan<const float, dynamicExtents3D> referenceDensity,
const TranslateAndScale& transformationToDensityLattice,
const LocalAtomSet& localAtomSet,
- int pbcType,
+ PbcType pbcType,
double simulationTimeStep,
const DensityFittingForceProviderState& state) :
parameters_(parameters),
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))
/*
* 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.
#include "gromacs/mdtypes/iforceprovider.h"
#include "gromacs/utility/classhelpers.h"
+enum class PbcType : int;
+
namespace gmx
{
basic_mdspan<const float, dynamicExtents3D> referenceDensity,
const TranslateAndScale& transformationToDensityLattice,
const LocalAtomSet& localAtomSet,
- int pbcType,
+ PbcType pbcType,
double simulationTimeStep,
const DensityFittingForceProviderState& state);
~DensityFittingForceProvider();
/*
* 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.
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,
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
/*
* 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.
struct t_enxframe;
struct t_inputrec;
struct t_mdatoms;
+enum class PbcType : int;
namespace gmx
{
* 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.
* \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,
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)
}
t_pbc pbc;
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
for (int k = 0; k < awhParams->numBias; k++)
{
struct t_inputrec;
struct pull_params_t;
struct pull_t;
+enum class PbcType : int;
namespace gmx
{
* \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.
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);
/*
* 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.
}
}
copy_mat(input.box, copy->box);
- copy->bPBC = input.bPBC;
- copy->ePBC = input.ePBC;
+ copy->bPBC = input.bPBC;
+ copy->pbcType = input.pbcType;
}
/*! \brief
{
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);
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)
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(
}
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)
{
}
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);
}
}
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)
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 */
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);
}
struct t_mdatoms;
struct t_nrnb;
struct gmx_wallcycle;
+enum class PbcType : int;
class t_state;
namespace gmx
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.
*
/*! \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);
}
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;
}
/* 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))
{
* 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.
{
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
{
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++)
{
//! 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,
{
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
* 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
{
}
}
- 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);
}
}
}
else
{
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
mk_graph_moltype(molt, &graph);
}
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 };
at_offset += molt.atoms.nr;
}
sfree(xs);
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
done_graph(&graph);
}
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);
/*
* 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.
}
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++)
{
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++)
{
/*
* 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.
}
}
- 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");
/* 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();
}
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");
}
// 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;
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;
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)
const t_atoms* atoms,
const rvec x[],
const rvec* v,
- int ePBC,
+ PbcType pbcType,
const matrix box,
int nindex,
int index[])
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:
const t_atoms* atoms,
const rvec x[],
const rvec* v,
- int ePBC,
+ PbcType pbcType,
const matrix box)
{
FILE* out;
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:
const gmx_mtop_t* mtop,
const rvec x[],
const rvec* v,
- int ePBC,
+ PbcType pbcType,
const matrix box)
{
int ftp;
*/
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;
t_atoms* atoms,
rvec x[],
rvec* v,
- int* ePBC,
+ PbcType* pbcType,
matrix box)
{
FILE* in;
gmx_mem("Uninitialized array atom");
}
- if (ePBC)
+ if (pbcType)
{
- *ePBC = -1;
+ *pbcType = PbcType::Unset;
}
ftp = fn2ftp(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");
}
t_symtab* symtab,
char** name,
t_atoms* atoms,
- int* ePBC,
+ PbcType* pbcType,
rvec** x,
rvec** v,
matrix box)
{
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);
{
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);
}
}
-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);
{
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
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);
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[]);
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 */
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 */
* \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
void readConfAndTopology(const char* infile,
bool* haveTopology,
gmx_mtop_t* mtop,
- int* ePBC,
+ PbcType* pbcType,
rvec** x,
rvec** v,
matrix box);
* \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
t_symtab* symtab,
char** name,
t_atoms* atoms,
- int* ePBC,
+ PbcType* pbcType,
rvec** x,
rvec** v,
matrix box);
*
* \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
*/
gmx_bool read_tps_conf(const char* infile,
struct t_topology* top,
- int* ePBC,
+ PbcType* pbcType,
rvec** x,
rvec** v,
matrix box,
}
-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;
}
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);
}
}
-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);
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)
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;
}
const char* title,
const t_atoms* atoms,
const rvec x[],
- int ePBC,
+ PbcType pbcType,
const matrix box,
char chainid,
int model_nr,
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)
{
const char* title,
const t_atoms* atoms,
const rvec x[],
- int ePBC,
+ PbcType pbcType,
const matrix box,
char chainid,
int model_nr,
{
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);
}
t_atoms* atoms,
t_symtab* symtab,
rvec x[],
- int* ePBC,
+ PbcType* pbcType,
matrix box,
gmx_bool bChange,
gmx_conect conect)
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)
{
}
break;
- case epdbCRYST1: read_cryst1(line, ePBC, box); break;
+ case epdbCRYST1: read_cryst1(line, pbcType, box); break;
case epdbTITLE:
case epdbHEADER:
}
}
-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);
struct t_atoms;
struct t_symtab;
struct t_topology;
+enum class PbcType : int;
typedef struct gmx_conect_t* gmx_conect;
/* 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.
*/
const char* title,
const t_atoms* atoms,
const rvec x[],
- int ePBC,
+ PbcType pbcType,
const matrix box,
char chain,
int model_nr,
const char* title,
const t_atoms* atoms,
const rvec x[],
- int ePBC,
+ PbcType pbcType,
const matrix box,
char chain,
int model_nr,
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. */
/*
* 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.
#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"
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()
void writeTestFileAndTest()
{
write_sto_conf(testFilename_.c_str(), *testTop_->name, &testTop_->atoms, testX_, nullptr,
- -1, testBox_);
+ PbcType::Unset, testBox_);
testFilesEqual(referenceFilename_, testFilename_);
}
* \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
*
*
*/
- ePBC = -1;
+ pbcType = PbcType::Unset;
bPeriodicMols = FALSE;
do_test(serializer, tpx->bIr, ir);
/* 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)
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
* \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)
{
{
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
* \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);
}
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,
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
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);
}
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;
{
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)
#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"
//! The file body.
std::vector<char> body;
//! Flag for PBC needed by legacy implementation.
- int ePBC = -1;
+ PbcType pbcType = PbcType::Unset;
};
/*
*
* \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.
* \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);
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)
}
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:
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;
// 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;
/* 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);
/***** 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;
* 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 */
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
if (pbc)
{
- set_pbc(pbc, -1, box);
+ set_pbc(pbc, PbcType::Unset, box);
}
if (bAngles)
static void project(const char* trajfile,
const t_topology* top,
- int ePBC,
+ PbcType pbcType,
matrix topbox,
const char* projfile,
const char* twodplotfile,
if (top)
{
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, nat);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, nat);
}
for (i = 0; i < nat; i++)
}
else
{
- write_sto_conf(threedplotfile, str, &atoms, x, nullptr, ePBC, box);
+ write_sto_conf(threedplotfile, str, &atoms, x, nullptr, pbcType, box);
}
done_atom(&atoms);
}
#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;
}
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)
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);
t_trxstatus* status;
t_trxstatus* fpdb;
t_topology top;
- int ePBC;
+ PbcType pbcType;
rvec* xtop;
matrix box;
t_trxframe fr;
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)
}
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
{
real bfac_init,
t_atoms* atoms,
const rvec x[],
- int ePBC,
+ PbcType pbcType,
matrix box,
gmx_bool bPhi,
gmx_bool bPsi,
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++)
{
FILE* log;
int nlist, idum, nbin;
rvec* x;
- int ePBC;
+ PbcType pbcType;
matrix box;
char grpname[256];
t_dlist* dlist;
/* 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)
{
/* 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)
t_mat * rms, *orig = nullptr;
real* eigenvalues;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms useatoms;
real* eigenvectors;
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");
/* 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) */
{
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)
{
{
if (bPBC)
{
- set_pbc(&pbc, ePBC, fr.box);
+ set_pbc(&pbc, pbcType, fr.box);
}
max_clust_size = 1;
max_clust_ind = -1;
FILE* fp;
char * name1, *name2;
t_topology *top1, *top2;
- int ePBC1, ePBC2;
+ PbcType pbcType1, pbcType2;
t_atoms * atoms1, *atoms2;
int warn = 0;
int at;
/* 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);
/* 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);
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:
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;
}
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;
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)
/* 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)
}
}
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),
}
static void calc_mj(t_topology top,
- int ePBC,
+ PbcType pbcType,
matrix box,
gmx_bool bNoJump,
int isize,
if (!bNoJump)
{
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
}
clear_rvec(tmp);
gmx_bool bNoJump,
gmx_bool bACF,
gmx_bool bINT,
- int ePBC,
+ PbcType pbcType,
t_topology top,
t_trxframe fr,
real temp,
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
{
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++)
{
int flags = 0;
gmx_bool bACF;
gmx_bool bINT;
- int ePBC = -1;
+ PbcType pbcType = PbcType::Unset;
int nmols;
int i;
real* qmol;
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);
/* 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);
double*** slDensity,
int* nslices,
t_topology* top,
- int ePBC,
+ PbcType pbcType,
int axis,
int nr_grps,
real* slWidth,
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
{
double*** slDensity,
int* nslices,
t_topology* top,
- int ePBC,
+ PbcType pbcType,
int axis,
int nr_grps,
real* slWidth,
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);
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 */
/* 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);
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);
}
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;
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)
{
}
else
{
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
for (i = 0; i < 2; i++)
{
if (gnx[i] == 1)
* 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.
int* zslices,
int* tblock,
const t_topology* top,
- int ePBC,
+ PbcType pbcType,
int axis,
gmx_bool bCenter,
gmx_bool bps1d,
/****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;
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;
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);
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)
{
const int mindex[],
rvec x[],
rvec mu[],
- int ePBC,
+ PbcType pbcType,
const matrix box,
const t_atom* atom,
const int* nAtom)
}
}
}
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
grp0 = 0;
grp1 = ncos - 1;
for (i = 0; i < ngrp[grp0]; i++)
}
static void do_dip(const t_topology* top,
- int ePBC,
+ PbcType pbcType,
real volume,
const char* fn,
const char* out_mtot,
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;
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)
int npargs;
t_pargs* ppa;
t_topology* top;
- int ePBC;
+ PbcType pbcType;
int k, natoms;
matrix box;
}
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);
}
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,
g = nullptr;
pbc_null = nullptr;
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
if (ir->bPeriodicMols)
{
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
{
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);
}
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);
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;
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);
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);
}
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 */
* 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.
#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"
};
FILE * fp, *fplog;
t_topology top;
- int ePBC = -1;
+ PbcType pbcType = PbcType::Unset;
t_trxframe fr;
matrix box;
int gnx;
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);
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;
if (bPBCdist)
{
- set_pbc(pbc, ePBC, fr.box);
+ set_pbc(pbc, pbcType, fr.box);
pbc_dx(pbc, donpos, accpos, dist);
}
else
*
* 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.
#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"
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;
}
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);
}
}
FILE* out;
t_trxstatus* status;
t_topology top;
- int ePBC;
+ PbcType pbcType;
rvec * x, *x_s;
rvec xcm, gvec, gvec1;
matrix box, trans;
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)
}
if (nz == 0)
{
- gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top.idef, pbcType, natoms);
}
do
{
real* slWidth,
int* nslices,
const t_topology* top,
- int ePBC,
+ PbcType pbcType,
int axis,
gmx_bool bMicel,
int micel[],
teller = 0;
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
/*********** Start processing trajectory ***********/
do
{
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 */
}
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);
}
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);
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);
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;
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);
pr_bb(stdout, nres, bb);
}
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
teller = 0;
do
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);
*
* 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.
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;
return 0;
}
- top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC);
+ top = read_top(ftp2fn(efTPR, NFILE, fnm), &pbcType);
for (i = 0; i < 3; i++)
{
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);
* 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.
#include "gromacs/utility/smalloc.h"
static void find_tetra_order_grid(t_topology top,
- int ePBC,
+ PbcType pbcType,
int natoms,
matrix box,
rvec x[],
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;
{
FILE * fpsg = nullptr, *fpsk = nullptr;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_trxstatus* status;
int natoms;
real t;
* 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);
}
}
- 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++)
/*to read topology file*/
t_topology top;
- int ePBC;
+ PbcType pbcType;
matrix topbox;
rvec* xtop;
gmx_bool bFit1;
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;
real trunc,
real** mdmat,
int** nmat,
- int ePBC,
+ PbcType pbcType,
matrix box)
{
int i, j, resi, resj;
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++)
{
FILE * out = nullptr, *fp;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms useatoms;
int isize;
int* index;
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);
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)
{
{
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++)
#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;
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;
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,
if (nullptr != top)
{
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
}
bFirst = TRUE;
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;
static void calc_dist(real rcut,
gmx_bool bPBC,
- int ePBC,
+ PbcType pbcType,
matrix box,
rvec x[],
int nx1,
/* Must init pbc every step because of pressure coupling */
if (bPBC)
{
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
}
if (index2)
{
int nres,
int* residue,
gmx_bool bPBC,
- int ePBC,
+ PbcType pbcType,
gmx_bool bGroup,
gmx_bool bEachResEachTime,
gmx_bool bPrintResName,
{
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)
{
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)
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)
{
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);
{ "-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;
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 "
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");
const int* molindex,
const t_topology* top,
rvec* x,
- int ePBC,
+ PbcType pbcType,
matrix box,
const gmx_output_env_t* oenv)
{
{
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);
}
}
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[],
if (bMol)
{
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
}
/* the loop over all frames */
real t_pdb,
int nrgrp,
t_topology* top,
- int ePBC,
+ PbcType pbcType,
gmx_bool bTen,
gmx_bool bMW,
gmx_bool bRmCOMM,
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);
{
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;
}
#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;
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);
t_trxstatus* out;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms* atoms;
rvec * xtop, *xref, *xav, *xout1, *xout2;
gmx_bool bDMR, bDMA, bFit;
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);
*
* 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.
t_trxstatus* out;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms* atoms;
rvec * xtop, *xref, *xav, *xout;
int nvec, *eignr = nullptr;
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 */
/* 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[],
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);
{
FILE * fpsg = nullptr, *fpsk = nullptr;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_trxstatus* status;
int natoms;
real t;
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);
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++)
{
gmx_bool bSliced,
gmx_bool bUnsat,
const t_topology* top,
- int ePBC,
+ PbcType pbcType,
int ngrps,
int axis,
gmx_bool permolecule,
teller = 0;
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
/*********** Start processing trajectory ***********/
do
{
}
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
}
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);
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 */
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 */
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)
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;
}
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);
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
{
double*** slField,
int* nslices,
const t_topology* top,
- int ePBC,
+ PbcType pbcType,
int axis,
int nr_grps,
double* slWidth,
}
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, natoms);
/*********** Start processing trajectory ***********/
do
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 */
/* 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);
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);
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;
}
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
{
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 } };
}
}
- 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);
/* 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)
#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]];
static void calc_dist_tot(int nind,
const int index[],
rvec x[],
- int ePBC,
+ PbcType pbcType,
matrix box,
real** d,
real** dtot,
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]];
real t;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms* atoms;
matrix box;
rvec* x;
}
/* 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);
}
/*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*/
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);
real t, *w_rls;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms * pdbatoms, *refatoms;
matrix box, pdbbox;
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);
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 */
{
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))
}
}
/* 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)
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 },
"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++)
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;
* 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.
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;
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
{
FILE* out;
t_trxstatus* status;
t_topology top;
- int ePBC;
+ PbcType pbcType;
rvec * x_ref, *x;
matrix box, R;
real t;
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);
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);
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;
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);
srenew(time, teller + 1);
time[teller] = t;
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
for (i = 0; (i < ncg); i++)
{
#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"
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;
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);
/* 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);
}
int gmx_sorient(int argc, char* argv[])
{
t_topology top;
- int ePBC = -1;
+ PbcType pbcType = PbcType::Unset;
t_trxstatus* status;
int natoms;
real t;
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 */
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;
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
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++)
double MINBIN[3];
double MAXBIN[3];
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_trxframe fr;
rvec* xtop;
matrix box, box_pbc;
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);
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
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++)
#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;
}
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
}
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);
/* 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;
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
/* 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++)
};
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_trxframe fr;
matrix box;
gmx_bool bTop;
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)
const char* xname,
const char* title,
t_atoms* atoms,
- int ePBC,
+ PbcType pbcType,
matrix box,
int isize,
int* index,
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);
}
}
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;
}
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)
if (bCom && bPBC)
{
- gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms);
+ gpbc = gmx_rmpbc_init(&top.idef, pbcType, fr.natoms);
}
do
{
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"
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 */
t_trxstatus* status;
gmx_bool bNShell, bPDBout;
t_topology top;
- int ePBC;
+ PbcType pbcType;
rvec * x, *xsol, xcom, dx;
matrix box;
t_pbc pbc;
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 */
}
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)
{
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;
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;
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);
#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"
};
t_topology top;
- int ePBC = -1;
+ PbcType pbcType = PbcType::Unset;
t_trxframe fr;
matrix box;
gmx_bool bTPS = FALSE, bTop = FALSE;
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
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);
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));
*
* 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.
rvec* x;
matrix box;
t_idef* idef;
- int ePBC;
+ PbcType pbcType;
gmx_output_env_t* oenv;
} t_xrama;
char** grpname;
int** index;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_trxframe fr;
reduced_atom_t** red;
structure_factor* sf;
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... */
}
}
-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;
}
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);
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;
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)
{
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,
}
else if (visbox[0] == -1)
{
- visualize_images("images.pdb", ePBC, box);
+ visualize_images("images.pdb", pbcType, box);
}
/* remove pbc */
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++)
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')
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);
{
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)
{
}
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);
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 */
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? */
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++)
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*/
}
}
- 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);
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 },
}
/* 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 */
}
snew(repl, nw);
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
if (seed == 0)
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);
gmx_bool bTopB,
const char* fn,
int rc_scaling,
- int ePBC,
+ PbcType pbcType,
rvec com,
warninp* wi)
{
warning(wi, warn_buf);
}
- npbcdim = ePBC2npbcdim(ePBC);
+ npbcdim = numPbcDimensions(pbcType);
GMX_RELEASE_ASSERT(npbcdim <= DIM, "Invalid npbcdim");
clear_rvec(com);
if (rc_scaling != erscNO)
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)
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)));
}
}
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 */
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]);
}
{
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);
}
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,
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;
gmx_mtop_t top_;
std::vector<RVec> x_;
matrix box_;
- int ePBC_;
+ PbcType pbcType_;
};
void InsertMolecules::initOptions(IOptionsContainer* options, ICommandLineOptionsModuleSettings* settings)
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);
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();
// 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];
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);
/* 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);
char** title,
t_atoms* atoms,
rvec** x,
- int* ePBC,
+ PbcType* pbcType,
matrix box,
bool bRemoveH,
t_symtab* symtab,
/* 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)
{
}
if (bOutput)
{
- write_sto_conf(outf, *title, atoms, *x, nullptr, *ePBC, box);
+ write_sto_conf(outf, *title, atoms, *x, nullptr, *pbcType, box);
}
return natom;
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)
{
{
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);
/* 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");
}
/* 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)
{
}
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);
}
"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)
{
"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, "
}
}
- 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 "
{
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))
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,");
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);
ir->LincsWarnAngle = 90.0;
}
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
if (ir->nstlist == 0)
{
"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 "
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;
t_symtab* symtab,
std::vector<RVec>* x,
std::vector<RVec>* v,
- int ePBC,
+ PbcType pbcType,
matrix box,
AtomProperties* aps,
real defaultDistance,
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);
/* 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))
/* 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);
}
/* 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)
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);
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];
"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);
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++)
{
if (bPBC)
{
- set_pbc(&pbc, epbcXYZ, box);
+ set_pbc(&pbc, PbcType::Xyz, box);
}
for (auto& angle : ang->interactionTypes)
{
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;
/* 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)
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);
}
}
/*
* 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.
"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];
* 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);
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);
}
else
{
- set_pbc(&pbc_no, epbcNONE, nullptr);
+ set_pbc(&pbc_no, PbcType::No, nullptr);
pbc_nonnull = &pbc_no;
}
gmx::ForceWithVirial* forceWithVirial,
const t_pbc* pbc,
int refcoord_scaling,
- int ePBC,
+ PbcType pbcType,
const rvec com)
/* compute flat-bottomed positions restraints */
{
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);
real lambda,
real* dvdlambda,
int refcoord_scaling,
- int ePBC,
+ PbcType pbcType,
const rvec comA,
const rvec comB)
{
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);
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.
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);
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));
}
/*
* 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.
}
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(
}
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 };
};
//! 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
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++)
{
* 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
{
{
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)
/* 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 */
*
*/
-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);
}
/* 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,
/* 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 ? */
/* 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;
}
}
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))
{
* 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 ###### */
}
state->nnhpres = 0;
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
state->flags |= (1 << estBOX);
if (inputrecPreserveShape(ir))
* 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.
/* 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,
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;
}
/* 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.
}
else
{
- set_pbc(&pbcNo, epbcNONE, nullptr);
+ set_pbc(&pbcNo, PbcType::No, nullptr);
pbcNonNull = &pbcNo;
}
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.
* 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);
*/
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);
}
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);
}
}
}
}
- if (fr->ePBC != epbcNONE)
+ if (fr->pbcType != PbcType::No)
{
/* Compute shift vectors every step,
* because of pressure coupling or box deformation!
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);
}
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
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);
}
}
/*
* 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.
// 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;
//
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);
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);
/*
* 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.
// 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;
//
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);
class ekinstate_t;
struct gmx_ekindata_t;
struct gmx_enerdata_t;
+enum class PbcType;
struct t_extmass;
struct t_fcdata;
struct t_graph;
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.
*/
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)
rvec* v,
const t_iparams ip[],
const t_ilist ilist[],
- int ePBC,
+ PbcType pbcType,
gmx_bool bMolPBC,
const t_commrec* cr,
const matrix box)
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;
* 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
*/
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
{
}
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;
}
}
matrix vir,
t_nrnb* nrnb,
const t_idef* idef,
- int ePBC,
+ PbcType pbcType,
gmx_bool bMolPBC,
const t_graph* g,
const matrix box,
/* 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
{
struct t_nrnb;
struct gmx_wallcycle;
struct VsiteThread;
+enum class PbcType : int;
namespace gmx
{
/*! \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[],
rvec v[],
const t_iparams ip[],
const t_ilist ilist[],
- int ePBC,
+ PbcType pbcType,
gmx_bool bMolPBC,
const t_commrec* cr,
const matrix box);
matrix vir,
t_nrnb* nrnb,
const t_idef* idef,
- int ePBC,
+ PbcType pbcType,
gmx_bool bMolPBC,
const t_graph* g,
const matrix box,
*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);
}
{
/* 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);
}
}
if (useGpuForUpdate)
{
t_pbc pbc;
- set_pbc(&pbc, epbcXYZ, state->box);
+ set_pbc(&pbc, PbcType::Xyz, state->box);
integrator->setPbc(&pbc);
}
}
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)
{
{
integrator->scaleCoordinates(pressureCouplingMu);
t_pbc pbc;
- set_pbc(&pbc, epbcXYZ, state->box);
+ set_pbc(&pbc, PbcType::Xyz, state->box);
integrator->setPbc(&pbc);
}
}
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)
{
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);
}
}
}
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)
}
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);
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.) */
/* 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)
{
rerun_fr.natoms, top_global->natoms);
}
- if (ir->ePBC != epbcNONE)
+ if (ir->pbcType != PbcType::No)
{
if (!rerun_fr.bBox)
{
"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
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.
}
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)
{
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");
}
{
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;
/* 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)
{
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);
}
}
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)
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)
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 };
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++;
#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"
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.
/* 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);
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);
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)
}
else
{
- return ePBC2npbcdim(ir->ePBC);
+ return numPbcDimensions(ir->pbcType);
}
}
{
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");
}
class KeyValueTreeObject;
} // namespace gmx
+enum class PbcType;
+
struct t_grpopts
{
//! Number of T-Coupl groups
//! 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)
lastStep_(-1),
canMoleculesBeDistributedOverPBC_(canMoleculesBeDistributedOverPBC),
systemHasPeriodicMolecules_(inputrec->bPeriodicMols),
- pbcType_(inputrec->ePBC),
+ pbcType_(inputrec->pbcType),
topologyHolder_(topologyHolder),
lastPlannedStep_(inputrec->nsteps + inputrec->init_step),
writeFinalConfiguration_(writeFinalConfiguration),
#include "topologyholder.h"
struct gmx_mdoutf;
+enum class PbcType : int;
struct t_commrec;
struct t_inputrec;
class t_state;
//! 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)
/*
* 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.
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);
/*
* 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.
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,
/*
* 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.
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)
}
}
-GridSet::GridSet(const int ePBC,
+GridSet::GridSet(const PbcType pbcType,
const bool doTestParticleInsertion,
const ivec* numDDCells,
const gmx_domdec_zones_t* ddZones,
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),
/*
* 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.
struct nbnxn_atomdata_t;
enum class PairlistType;
+enum class PbcType : int;
namespace gmx
{
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?
};
//! 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,
/*
* 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.
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);
/* 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;
/*
* 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.
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))
{
/*
* 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.
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,
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);
/* \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,
{
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"
}
/* 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;
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;
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;
}
*/
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(
struct InteractionList;
struct gmx_moltype_t;
struct t_idef;
+enum class PbcType : int;
typedef enum
{
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[]);
#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
//! 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;
{
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);
}
}
-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;
}
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])))
{
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;
* 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]));
}
* 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]);
}
//! 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
{
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
}
//! 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;
}
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");
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;
}
/* 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])
{
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])
{
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)
{
}
}
-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;
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++;
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)
rvec_sub(x1, x2, dx);
- switch (pbc->ePBCDX)
+ switch (pbc->pbcTypeDX)
{
case epbcdxRECTANGULAR:
for (i = 0; i < DIM; i++)
rvec_sub(x1, x2, dx);
clear_ivec(ishift);
- switch (pbc->ePBCDX)
+ switch (pbc->pbcTypeDX)
{
case epbcdxRECTANGULAR:
for (i = 0; i < DIM; i++)
dvec_sub(x1, x2, dx);
- switch (pbc->ePBCDX)
+ switch (pbc->pbcTypeDX)
{
case epbcdxRECTANGULAR:
case epbcdx2D_RECT:
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;
}
}
}
-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++)
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
}
}
}
-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");
}
/*! \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;
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.
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);
}
#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
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,
/*! \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
*
/*! \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
*/
* 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
*
* 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.
*
* 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
*
* 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
*
*
* 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
/*
* 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.
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 };
/*
* 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.
#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;
/* 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;
t_block* mols,
int natoms,
t_atom atom[],
- int ePBC,
+ PbcType pbcType,
matrix box,
rvec x[])
{
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,
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);
}
}
-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;
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);
/*
* 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.
struct t_topology;
struct t_block;
struct t_atom;
+enum class PbcType : int;
#include "gmxpre.h"
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,
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[]);
{
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;
}
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;
/* 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)
}
}
-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
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);
}
}
*
* 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);
* 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[]);
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;
}
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);
}
#endif
class PullHistory;
+enum class PbcType : int;
enum
{
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 */
* 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
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;
}
int groupNr,
real pbcMargin)
{
- if (pbc.ePBC == epbcNONE)
+ if (pbc.pbcType == PbcType::No)
{
return true;
}
/*
* 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.
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");
{
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
/*
* 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.
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_;
// 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;
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]))
{
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)
{
}
else
{
- pbc_.ePBC = epbcNONE;
+ pbc_.pbcType = PbcType::No;
clear_mat(pbc_.box);
}
nref_ = positions.count_;
continue;
}
rvec dx;
- if (search_.pbc_.ePBC != epbcNONE)
+ if (search_.pbc_.pbcType != PbcType::No)
{
pbc_dx(&search_.pbc_, search_.xref_[i], xtest_, dx);
}
refPosCount_(0)
{
clear_mat(box_);
- set_pbc(&pbc_, epbcNONE, box_);
+ set_pbc(&pbc_, PbcType::No, box_);
}
gmx::RVec NeighborhoodSearchTestData::generateRandomPosition()
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_);
}
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_);
}
// 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_);
}
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_);
}
// 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_);
}
// 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_);
}
// 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_);
}
// 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);
}
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)
{
* 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");
SwS, SwSEmpty);
write_sto_conf_mtop("CompELAssumedWholeConfiguration.pdb", *mtop->name, mtop, x, nullptr,
- ePBC, box);
+ pbcType, box);
}
}
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 */
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
}
}
-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)
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)
{
{
int natom, i, j, k;
t_topology top;
- int ePBC;
+ PbcType pbcType;
t_atoms* atoms;
rvec * x, *v;
rvec dx;
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);
}
if (bB)
{
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, pbcType, box);
}
bFirst = TRUE;
int j;
t_atoms atoms;
rvec * x, *v;
- int ePBC;
+ PbcType pbcType;
matrix box;
t_blocka * block, *block2;
char ** gnames, **gnames2;
{
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)
{
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;
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;
}
if (bRmPBC)
{
- gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr);
+ gpbc = gmx_rmpbc_init(&top->idef, pbcType, top->atoms.nr);
}
}
read_first_frame(oenv, &trxin, in_file, &fr, flags);
}
- set_trxframe_ePBC(&fr, ePBC);
+ setTrxFramePbcType(&fr, pbcType);
natoms = fr.natoms;
if (bSetTime)
}
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)
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;
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 = "";
/*
* 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.
return frame_.time;
}
-int TrajectoryFrame::pbc() const
+PbcType TrajectoryFrame::pbc() const
{
- return frame_.ePBC;
+ return frame_.pbcType;
}
ArrayRef<const RVec> TrajectoryFrame::x() const
#include "gromacs/utility/real.h"
struct t_atoms;
+enum class PbcType : int;
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;
//! 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).
* 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.
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);
{
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
{
rvec x[],
t_atoms* atoms,
t_symtab* symtab,
- int ePBC,
+ PbcType pbcType,
const matrix box,
gmx_bool bIncludeSolute)
{
}
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;
}
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);
}
}
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"
// 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);
* 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.
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_);
t_pbc pbc;
if (bPBC)
{
- set_pbc(&pbc, epbcXYZ, box_);
+ set_pbc(&pbc, PbcType::Xyz, box_);
}
ASSERT_NO_THROW_GMX({
gmx::SurfaceAreaCalculator calculator;
/*
* 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.
#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"
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 } };
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();
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();
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();
/*
* 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.
#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"
expandedTopology_(nullptr),
atoms_(nullptr),
bTop_(false),
- ePBC_(-1)
+ pbcType_(PbcType::Unset)
{
}
// 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);
{
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
/*
* 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.
//! Forward declaration
typedef struct gmx_rmpbc* gmx_rmpbc_t;
+enum class PbcType : int;
namespace gmx
{
/*! \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.
*
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);
/*
* 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.
#include <vector>
struct t_commrec;
+enum class PbcType : int;
namespace gmx
{
struct MdModulesWriteCheckpointData;
struct PeriodicBoundaryConditionType
{
- int pbcType;
+ PbcType pbcType;
};
struct MdModulesEnergyOutputToDensityFittingRequestChecker
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);
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:
int height,
unsigned long fg,
unsigned long bg,
- int ePBC,
+ PbcType pbcType,
matrix box,
gmx_output_env_t* oenv)
{
/* 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);
*
* 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.
#include "xutil.h"
struct gmx_output_env_t;
+enum class PbcType : int;
/* Some window sizes */
#define EWIDTH 200
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;
int height,
unsigned long fg,
unsigned long bg,
- int ePBC,
+ PbcType pbcType,
matrix box,
gmx_output_env_t* oenv);
/* Initiate the display manager */
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;
}
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");
*
* 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.
int height,
unsigned long fg,
unsigned long bg,
- int ePBC,
+ PbcType pbcType,
matrix box);
/* Create the molecule window using the x,y etc. */
*
* 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.
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;
int w0, h0;
int natom, natom_trx;
t_topology top;
- int ePBC;
+ PbcType pbcType;
matrix box;
t_trxframe fr;
t_trxstatus* status;
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);
/* 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 */