From bb379f7ec7042e20d14da6d0186970277a642439 Mon Sep 17 00:00:00 2001 From: Magnus Lundborg Date: Tue, 25 Sep 2018 13:33:05 +0200 Subject: [PATCH] Added pullCheckPbcWithinGroup() to check one group This function checks if a single group obeys PBC restrictions. Change-Id: I26e99335c9d127ada1a229597bce489416b21408 --- src/gromacs/pulling/pull.h | 27 ++++++++++++++++++++ src/gromacs/pulling/pullutil.cpp | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/src/gromacs/pulling/pull.h b/src/gromacs/pulling/pull.h index 9ea3eefe20..89a9039bba 100644 --- a/src/gromacs/pulling/pull.h +++ b/src/gromacs/pulling/pull.h @@ -54,6 +54,7 @@ #include "gromacs/math/vectypes.h" #include "gromacs/mdtypes/pull-params.h" +#include "gromacs/utility/arrayref.h" #include "gromacs/utility/basedefinitions.h" #include "gromacs/utility/real.h" @@ -314,6 +315,32 @@ int pullCheckPbcWithinGroups(const pull_t &pull, const t_pbc &pbc, real pbcMargin); +/*! \brief Checks whether a specific group that uses a reference atom is within PBC restrictions + * + * Groups that use a reference atom for determining PBC should have all their + * atoms within half the box size from the PBC atom. The box size is used + * per dimension for rectangular boxes, but can be a combination of + * dimensions for triclinic boxes, depending on which dimensions are + * involved in the pull coordinates a group is involved in. A margin is specified + * to ensure that atoms are not too close to the maximum distance. Only one group is + * checked. + * + * Should be called without MPI parallelization and after pull_calc_coms() + * has been called at least once. + * + * \param[in] pull The pull data structure + * \param[in] x The coordinates + * \param[in] pbc Information struct about periodicity + * \param[in] groupNr The index of the group (in pull.group[]) to check + * \param[in] pbcMargin The minimum margin (as a fraction) to half the box size + * \returns true if the group obeys PBC otherwise false + */ +bool pullCheckPbcWithinGroup(const pull_t &pull, + gmx::ArrayRef x, + const t_pbc &pbc, + int groupNr, + real pbcMargin); + /*! \brief Returns if we have pull coordinates with potential pulling. * * \param[in] pull The pull data structure. diff --git a/src/gromacs/pulling/pullutil.cpp b/src/gromacs/pulling/pullutil.cpp index 8280f6d61f..b771a60b03 100644 --- a/src/gromacs/pulling/pullutil.cpp +++ b/src/gromacs/pulling/pullutil.cpp @@ -934,3 +934,46 @@ int pullCheckPbcWithinGroups(const pull_t &pull, return -1; } + +bool pullCheckPbcWithinGroup(const pull_t &pull, + gmx::ArrayRef x, + const t_pbc &pbc, + int groupNr, + real pbcMargin) +{ + if (pbc.ePBC == epbcNONE) + { + return true; + } + GMX_ASSERT(groupNr < static_cast(pull.group.size()), "groupNr is out of range"); + + /* Check PBC if the group uses a PBC reference atom treatment. */ + const pull_group_work_t &group = pull.group[groupNr]; + if (group.epgrppbc != epgrppbcREFAT) + { + return true; + } + + /* Determine what dimensions are used for each group by pull coordinates */ + BoolVec dimUsed = { false, false, false }; + for (size_t c = 0; c < pull.coord.size(); c++) + { + const t_pull_coord &coordParams = pull.coord[c].params; + for (int groupIndex = 0; groupIndex < coordParams.ngroup; groupIndex++) + { + if (coordParams.group[groupIndex] == groupNr) + { + for (int d = 0; d < DIM; d++) + { + if (coordParams.dim[d] && + !(coordParams.eGeom == epullgCYL && groupIndex == 0)) + { + dimUsed[d] = true; + } + } + } + } + } + + return (pullGroupObeysPbcRestrictions(group, dimUsed, as_rvec_array(x.data()), pbc, pull.comm.pbcAtomBuffer[groupNr], pbcMargin)); +} -- 2.22.0