/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2014,2015,2017,2018,2019, 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::ArrayRef<const gmx::RVec> xRef =
constArrayRefFromArray(x.data(), masterRankHasTheSystemState ? x.size() : dd.comm->atomRanges.numHomeAtoms());
- low_set_ddbox(dd.npbcdim, dd.numBoundedDimensions,
+ low_set_ddbox(dd.unitCellInfo.npbcdim, dd.unitCellInfo.numBoundedDimensions,
&dd.nc, box, calculateUnboundedSize, xRef,
needToReduceCoordinateData ? &dd.mpi_comm_all : nullptr,
ddbox);
gmx_bcast(sizeof(gmx_ddbox_t), ddbox, &cr);
}
-
-bool dynamic_dd_box(const gmx_domdec_t &dd)
-{
- return (dd.numBoundedDimensions < DIM || dd.haveDynamicBox);
-}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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::ArrayRef<const gmx::RVec> x,
gmx_ddbox_t *ddbox);
-//! Returns whether the DD box can change size.
-bool dynamic_dd_box(const gmx_domdec_t &dd);
-
#endif
for (int d = DIM - 1; d >= 0; d--)
{
real pos_d = cog[d];
- if (d < dd.npbcdim)
+ if (d < dd.unitCellInfo.npbcdim)
{
- bool bScrew = (dd.bScrewPBC && d == XX);
+ bool bScrew = (dd.unitCellInfo.haveScrewPBC && d == XX);
if (ddbox.tric_dir[d] && dd.nc[d] > 1)
{
/* Use triclinic coordinates for this dimension */
}
matrix triclinicCorrectionMatrix;
- make_tric_corr_matrix(dd->npbcdim, box, triclinicCorrectionMatrix);
+ make_tric_corr_matrix(dd->unitCellInfo.npbcdim, box, triclinicCorrectionMatrix);
ivec npulse;
const auto cellBoundaries =
{
GMX_ASSERT(box && pos, "box or pos not set on master");
- if (dd->bScrewPBC)
+ if (dd->unitCellInfo.haveScrewPBC)
{
check_screw_box(box);
}
for (int d = 0; d < dd->ndim; d++)
{
bPBC = (dd->ci[dd->dim[d]] == 0);
- bScrew = (bPBC && dd->bScrewPBC && dd->dim[d] == XX);
+ bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dd->dim[d] == XX);
if (bPBC)
{
copy_rvec(box[dd->dim[d]], shift);
/* Only forces in domains near the PBC boundaries need to
consider PBC in the treatment of fshift */
const bool shiftForcesNeedPbc = (forceWithShiftForces->computeVirial() && dd->ci[dd->dim[d]] == 0);
- const bool applyScrewPbc = (shiftForcesNeedPbc && dd->bScrewPBC && dd->dim[d] == XX);
+ const bool applyScrewPbc = (shiftForcesNeedPbc && dd->unitCellInfo.haveScrewPBC && dd->dim[d] == XX);
/* Determine which shift vector we need */
ivec vis = { 0, 0, 0 };
vis[dd->dim[d]] = 1;
}
}
+UnitCellInfo::UnitCellInfo(const t_inputrec &ir) :
+ npbcdim(ePBC2npbcdim(ir.ePBC)),
+ numBoundedDimensions(inputrec2nboundeddim(&ir)),
+ ddBoxIsDynamic(numBoundedDimensions < DIM || inputrecDynamicBox(&ir)),
+ haveScrewPBC(ir.ePBC == epbcSCREW)
+{
+}
+
/*! \brief Set the cell size and interaction limits, as well as the DD grid */
static void set_dd_limits_and_grid(const gmx::MDLogger &mdlog,
t_commrec *cr, gmx_domdec_t *dd,
const real tenPercentMargin = 1.1;
gmx_domdec_comm_t *comm = dd->comm;
- dd->npbcdim = ePBC2npbcdim(ir->ePBC);
- dd->numBoundedDimensions = inputrec2nboundeddim(ir);
- dd->haveDynamicBox = inputrecDynamicBox(ir);
- dd->bScrewPBC = (ir->ePBC == epbcSCREW);
-
dd->pme_recv_f_alloc = 0;
dd->pme_recv_f_buf = nullptr;
}
else
{
- if (dynamic_dd_box(*dd))
+ if (dd->unitCellInfo.ddBoxIsDynamic)
{
log->writeLine("(the following are initial values, they could change due to box deformation)");
}
}
}
+gmx_domdec_t::gmx_domdec_t(const t_inputrec &ir) :
+ unitCellInfo(ir)
+{
+}
+
gmx_domdec_t *init_domain_decomposition(const gmx::MDLogger &mdlog,
t_commrec *cr,
const DomdecOptions &options,
GMX_LOG(mdlog.info).appendTextFormatted(
"\nInitializing Domain Decomposition on %d ranks", cr->nnodes);
- dd = new gmx_domdec_t;
+ dd = new gmx_domdec_t(*ir);
dd->comm = init_dd_comm();
dim = dd->dim[d];
inv_cell_size = DD_CELL_MARGIN*dd->nc[dim]/ddbox.box_size[dim];
- if (dynamic_dd_box(*dd))
+ if (dd->unitCellInfo.ddBoxIsDynamic)
{
inv_cell_size *= DD_PRES_SCALE_MARGIN;
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2006,2007,2008,2009,2010,2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2006,2007,2008,2009,2010,2012,2013,2014,2015,2017,2018,2019, 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.
{
bPBC = ((dir == 0 && dd->ci[dim] == 0) ||
(dir == 1 && dd->ci[dim] == dd->nc[dim]-1));
- bScrew = (bPBC && dd->bScrewPBC && dim == XX);
+ bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dim == XX);
spas = &spac->spas[d][dir];
/* Sum the buffer into the required forces */
f + n, spas->nrecv,
as_rvec_array(spac->vbuf.data()), spas->a.size());
/* Sum the buffer into the required forces */
- if (dd->bScrewPBC && dim == XX &&
+ if (dd->unitCellInfo.haveScrewPBC && dim == XX &&
(dd->ci[dim] == 0 ||
dd->ci[dim] == dd->nc[dim]-1))
{
if (dir == 0 && dd->ci[dim] == 0)
{
bPBC = TRUE;
- bScrew = (dd->bScrewPBC && dim == XX);
+ bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX);
copy_rvec(box[dim], shift);
}
else if (dir == 1 && dd->ci[dim] == dd->nc[dim]-1)
{
bPBC = TRUE;
- bScrew = (dd->bScrewPBC && dim == XX);
+ bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX);
for (i = 0; i < DIM; i++)
{
shift[i] = -box[dim][i];
for (v = 0; v < nvec; v++)
{
rvec *x = (v == 0 ? x0 : x1);
- if (dd->bScrewPBC && dim == XX &&
+ if (dd->unitCellInfo.haveScrewPBC && dim == XX &&
(dd->ci[XX] == 0 || dd->ci[XX] == dd->nc[XX]-1))
{
/* Here we only perform the rotation, the rest of the pbc
{
/* Pulse the grid forward and backward */
dim = dd->dim[d];
- bPBC = (dim < dd->npbcdim);
+ bPBC = (dim < dd->unitCellInfo.npbcdim);
if (dd->nc[dim] == 2)
{
/* Only 2 cells, so we only need to communicate once */
for (int d = 0; d < dd->ndim; d++)
{
/* Pulse the grid forward and backward */
- if (dd->dim[d] >= dd->npbcdim || dd->nc[dd->dim[d]] > 2)
+ if (dd->dim[d] >= dd->unitCellInfo.npbcdim || dd->nc[dd->dim[d]] > 2)
{
ndir = 2;
}
class gmx_ga2la_t;
struct gmx_pme_comm_n_box_t;
struct gmx_reverse_top_t;
+struct t_inputrec;
namespace gmx
{
rvec normal[DIM];
};
+/*! \internal \brief Provides information about properties of the unit cell */
+struct UnitCellInfo
+{
+ //! Constructor
+ UnitCellInfo(const t_inputrec &ir);
+
+ //! We have PBC from dim 0 (X) up to npbcdim
+ int npbcdim;
+ //! The system is bounded from 0 (X) to numBoundedDimensions
+ int numBoundedDimensions;
+ //! Tells whether the box bounding the atoms is dynamic
+ bool ddBoxIsDynamic;
+ //! Screw PBC?
+ bool haveScrewPBC;
+};
struct gmx_domdec_t { //NOLINT(clang-analyzer-optin.performance.Padding)
+ //! Constructor, only partial for now
+ gmx_domdec_t(const t_inputrec &ir);
+
/* The DD particle-particle nodes only */
/* The communication setup within the communicator all
* defined in dd->comm in domdec.c
int nreq_pme = 0;
MPI_Request req_pme[8];
+ /* Properties of the unit cell */
+ UnitCellInfo unitCellInfo;
/* The communication setup, identical for each cell, cartesian index */
ivec nc;
int ndim;
ivec dim; /* indexed by 0 to ndim */
- /* TODO: Move the next 4, and more from domdec_internal.h, to a simulation system */
-
- /* PBC from dim 0 (X) to npbcdim */
- int npbcdim;
- /* The system is bounded from 0 (X) to numBoundedDimensions */
- int numBoundedDimensions;
- /* Does the box size change during the simulaton? */
- bool haveDynamicBox;
-
- /* Screw PBC? */
- gmx_bool bScrewPBC;
-
/* Forward and backward neighboring cells, indexed by 0 to ndim */
int neighbor[DIM][2];
}
sprintf(fname, "%s_%s.pdb", fn, gmx_step_str(step, buf));
out = gmx_fio_fopen(fname, "w");
- gmx_write_pdb_box(out, dd->bScrewPBC ? epbcSCREW : epbcXYZ, box);
+ gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? epbcSCREW : epbcXYZ, 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->bScrewPBC ? epbcSCREW : epbcXYZ, box);
+ gmx_write_pdb_box(out, dd->unitCellInfo.haveScrewPBC ? epbcSCREW : epbcXYZ, box);
int molb = 0;
for (int i = 0; i < natoms; i++)
{
comm = dd->comm;
- bScrew = (dd->bScrewPBC && dim == XX);
+ bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX);
bDistMB_pulse = (bDistMB && bDistBonded);
{
corner[ZZ] = zones->size[z].x1[ZZ];
}
- if (dd->ndim == 1 && dd->dim[0] < ZZ && ZZ < dd->npbcdim &&
+ if (dd->ndim == 1 && dd->dim[0] < ZZ && ZZ < dd->unitCellInfo.npbcdim &&
box[ZZ][1 - dd->dim[0]] != 0)
{
/* With 1D domain decomposition the cg's are not in
copy_rvec(ddbox.box0, comm->box0 );
copy_rvec(ddbox.box_size, comm->box_size);
- set_dd_cell_sizes(dd, &ddbox, dynamic_dd_box(*dd), bMasterState, bDoDLB,
+ set_dd_cell_sizes(dd, &ddbox, dd->unitCellInfo.ddBoxIsDynamic, bMasterState, bDoDLB,
step, wcycle);
if (comm->nstDDDumpGrid > 0 && step % comm->nstDDDumpGrid == 0)
{
np[dd->dim[i]] = comm->cd[i].numPulses();
}
- dd_make_local_top(dd, &comm->zones, dd->npbcdim, state_local->box,
+ dd_make_local_top(dd, &comm->zones, dd->unitCellInfo.npbcdim, state_local->box,
comm->cellsize_min, np,
fr,
state_local->x.rvec_array(),
int cg_start, int cg_end,
gmx::ArrayRef<int> move)
{
- const int npbcdim = dd->npbcdim;
+ const int npbcdim = dd->unitCellInfo.npbcdim;
auto x = makeArrayRef(state->x);
for (int a = cg_start; a < cg_end; a++)
{
if (dd->nc[d] > 1)
{
- bool bScrew = (dd->bScrewPBC && d == XX);
+ bool bScrew = (dd->unitCellInfo.haveScrewPBC && d == XX);
/* Determine the location of this cg in lattice coordinates */
real pos_d = cm_new[d];
if (tric_dir[d])
int groupBegin, int groupEnd,
gmx::ArrayRef<PbcAndFlag> pbcAndFlags)
{
- GMX_RELEASE_ASSERT(!dd->bScrewPBC, "Screw PBC is not supported here");
+ GMX_RELEASE_ASSERT(!dd->unitCellInfo.haveScrewPBC, "Screw PBC is not supported here");
- const int npbcdim = dd->npbcdim;
+ const int npbcdim = dd->unitCellInfo.npbcdim;
gmx::UpdateGroupsCog *updateGroupsCog = dd->comm->updateGroupsCog.get();
{
gmx_domdec_comm_t *comm = dd->comm;
- if (dd->bScrewPBC)
+ if (dd->unitCellInfo.haveScrewPBC)
{
check_screw_box(state->box);
}
DDBufferAccess<int> moveBuffer(comm->intBuffer, dd->ncg_home);
gmx::ArrayRef<int> move = moveBuffer.buffer;
- const int npbcdim = dd->npbcdim;
+ const int npbcdim = dd->unitCellInfo.npbcdim;
rvec cell_x0, cell_x1;
MoveLimits moveLimits;