dd->atomSets = atomSets;
- dd->localTopologyChecker = std::make_unique<LocalTopologyChecker>();
+ dd->localTopologyChecker =
+ std::make_unique<LocalTopologyChecker>(mtop_, dd->comm->systemInfo.useUpdateGroups);
return dd;
}
/*! \brief Print error output when interactions are missing */
[[noreturn]] static void dd_print_missing_interactions(const gmx::MDLogger& mdlog,
t_commrec* cr,
- int numBondedInteractionsOverAllDomains,
+ const int numBondedInteractionsOverAllDomains,
+ const int expectedNumGlobalBondedInteractions,
const gmx_mtop_t& top_global,
const gmx_localtop_t* top_local,
ArrayRef<const RVec> x,
"Not all bonded interactions have been properly assigned to the domain "
"decomposition cells");
- const int ndiff_tot = numBondedInteractionsOverAllDomains
- - dd->reverse_top->expectedNumGlobalBondedInteractions();
+ const int ndiff_tot = numBondedInteractionsOverAllDomains - expectedNumGlobalBondedInteractions;
for (int ftype = 0; ftype < F_NRE; ftype++)
{
if (DDMASTER(dd))
{
GMX_LOG(mdlog.warning).appendText("A list of missing interactions:");
- int rest_global = dd->reverse_top->expectedNumGlobalBondedInteractions();
+ int rest_global = expectedNumGlobalBondedInteractions;
int rest = numBondedInteractionsOverAllDomains;
for (int ftype = 0; ftype < F_NRE; ftype++)
{
"two-body cut-off distance (%g nm), see option -rdd, for pairs and tabulated bonds "
"also see option -ddcheck",
-ndiff_tot,
- dd->reverse_top->expectedNumGlobalBondedInteractions(),
+ expectedNumGlobalBondedInteractions,
dd_cutoff_multibody(dd),
dd_cutoff_twobody(dd));
}
gmx_fatal_collective(FARGS, cr->mpi_comm_mygroup, MASTER(cr), "%s", errorMessage.c_str());
}
+namespace gmx
+{
+
+/*! \brief Compute the total bonded interaction count
+ *
+ * \param[in] mtop The global system topology
+ * \param[in] useUpdateGroups Whether update groups are in use
+ *
+ * When using domain decomposition without update groups,
+ * constraint-type interactions can be split across domains, and so we
+ * do not consider them in this correctness check. Otherwise, we
+ * include them.
+ */
+static int computeExpectedNumGlobalBondedInteractions(const gmx_mtop_t& mtop, const bool useUpdateGroups)
+{
+ int expectedNumGlobalBondedInteractions = gmx_mtop_interaction_count(mtop, IF_BOND);
+ if (useUpdateGroups)
+ {
+ expectedNumGlobalBondedInteractions += gmx_mtop_interaction_count(mtop, IF_CONSTRAINT);
+ }
+ return expectedNumGlobalBondedInteractions;
+}
+
+LocalTopologyChecker::LocalTopologyChecker(const gmx_mtop_t& mtop, const bool useUpdateGroups) :
+ expectedNumGlobalBondedInteractions(computeExpectedNumGlobalBondedInteractions(mtop, useUpdateGroups))
+{
+}
+
+} // namespace gmx
void scheduleCheckOfLocalTopology(gmx_domdec_t* dd, const int numBondedInteractionsToReduce)
{
"The check for the total number of bonded interactions requires the "
"value to have been reduced across all domains");
if (cr->dd->localTopologyChecker->numBondedInteractionsOverAllDomains.value()
- != cr->dd->reverse_top->expectedNumGlobalBondedInteractions())
+ != cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions)
{
dd_print_missing_interactions(
mdlog,
cr,
cr->dd->localTopologyChecker->numBondedInteractionsOverAllDomains.value(),
+ cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions,
top_global,
top_local,
x,
struct LocalTopologyChecker
{
public:
+ //! Constructor
+ LocalTopologyChecker(const gmx_mtop_t& mtop, bool useUpdateGroups);
/*! \brief Data to help check local topology construction
*
* Partitioning could incorrectly miss a bonded interaction.
* removed when it is again time to check after a new
* partition. */
std::optional<int> numBondedInteractionsOverAllDomains;
+ //! The number of bonded interactions computed from the full system topology
+ int expectedNumGlobalBondedInteractions = 0;
/*! \} */
};
//! \brief Intermolecular reverse ilist
reverse_ilist_t ril_intermol;
- //! The number of bonded interactions computed from the full topology
- int expectedNumGlobalBondedInteractions = 0;
-
/* Work data structures for multi-threading */
//! \brief Thread work array for local topology generation
std::vector<thread_work_t> th_work;
return impl_->ril_mt[moleculeType];
}
-int gmx_reverse_top_t::expectedNumGlobalBondedInteractions() const
-{
- return impl_->expectedNumGlobalBondedInteractions;
-}
-
ArrayRef<const MolblockIndices> gmx_reverse_top_t::molblockIndices() const
{
return impl_->mbi;
return impl_->ilsort != ilsortNO_FE;
}
-/*! \brief Compute the total bonded interaction count
- *
- * \param[in] mtop The global system topology
- * \param[in] includeConstraints Whether constraint interactions are included in the count
- * \param[in] includeSettles Whether settle interactions are included in the count
- *
- * When using domain decomposition without update groups,
- * constraint-type interactions can be split across domains, and so we
- * do not consider them in this correctness check. Otherwise, we
- * include them.
- */
-static int computeExpectedNumGlobalBondedInteractions(const gmx_mtop_t& mtop,
- const bool includeConstraints,
- const bool includeSettles)
-{
- int expectedNumGlobalBondedInteractions = gmx_mtop_interaction_count(mtop, IF_BOND);
- if (includeConstraints)
- {
- expectedNumGlobalBondedInteractions +=
- gmx_mtop_ftype_count(mtop, F_CONSTR) + gmx_mtop_ftype_count(mtop, F_CONSTRNC);
- }
- if (includeSettles)
- {
- expectedNumGlobalBondedInteractions += gmx_mtop_ftype_count(mtop, F_SETTLE);
- }
- return expectedNumGlobalBondedInteractions;
-}
-
/*! \brief Generate the reverse topology */
gmx_reverse_top_t::Impl::Impl(const gmx_mtop_t& mtop,
const bool useFreeEnergy,
const ReverseTopOptions& reverseTopOptions) :
options(reverseTopOptions),
hasPositionRestraints(gmx_mtop_ftype_count(mtop, F_POSRES) + gmx_mtop_ftype_count(mtop, F_FBPOSRES) > 0),
- bInterAtomicInteractions(mtop.bIntermolecularInteractions),
- expectedNumGlobalBondedInteractions(
- computeExpectedNumGlobalBondedInteractions(mtop,
- reverseTopOptions.includeConstraints,
- reverseTopOptions.includeSettles))
+ bInterAtomicInteractions(mtop.bIntermolecularInteractions)
{
bInterAtomicInteractions = mtop.bIntermolecularInteractions;
ril_mt.resize(mtop.moltype.size());
//! Gets the interaction list for the given molecule type
const reverse_ilist_t& interactionListForMoleculeType(int moleculeType) const;
- //! Returns the total count of bonded interactions, used for checking partitioning
- int expectedNumGlobalBondedInteractions() const;
-
//! Returns the molecule block indices
gmx::ArrayRef<const MolblockIndices> molblockIndices() const;
//! Returns whether the reverse topology describes intermolecular interactions