Expose vsite counting
authorPascal Merz <pascal.merz@me.com>
Wed, 12 Feb 2020 22:33:39 +0000 (15:33 -0700)
committerPascal Merz <pascal.merz@me.com>
Thu, 13 Feb 2020 02:45:35 +0000 (19:45 -0700)
This allows to check whether vsites are present before the
respective object is created.

Refs #3377 (prepares point 1)

Change-Id: I8273daf38d46e2f052573f48323b5b6137965e9f

src/gromacs/mdlib/vsite.cpp
src/gromacs/mdlib/vsite.h

index 4a0fe17a00e9e3ad1e9945044ff596d533ddb5c9..b73fad742f7f52707628c62ffb09b2c9a9e47d34 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,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.
@@ -2006,13 +2006,8 @@ int countInterUpdategroupVsites(const gmx_mtop_t&                           mtop
     return n_intercg_vsite;
 }
 
-std::unique_ptr<gmx_vsite_t> initVsite(const gmx_mtop_t& mtop, const t_commrec* cr)
+int countVsites(const gmx_mtop_t& mtop)
 {
-    GMX_RELEASE_ASSERT(cr != nullptr, "We need a valid commrec");
-
-    std::unique_ptr<gmx_vsite_t> vsite;
-
-    /* check if there are vsites */
     int nvsite = 0;
     for (int ftype = 0; ftype < F_NRE; ftype++)
     {
@@ -2029,6 +2024,17 @@ std::unique_ptr<gmx_vsite_t> initVsite(const gmx_mtop_t& mtop, const t_commrec*
                        "c_ftypeVsiteStart and/or c_ftypeVsiteEnd do not have correct values");
         }
     }
+    return nvsite;
+}
+
+std::unique_ptr<gmx_vsite_t> initVsite(const gmx_mtop_t& mtop, const t_commrec* cr)
+{
+    GMX_RELEASE_ASSERT(cr != nullptr, "We need a valid commrec");
+
+    std::unique_ptr<gmx_vsite_t> vsite;
+
+    /* check if there are vsites */
+    int nvsite = countVsites(mtop);
 
     if (nvsite == 0)
     {
index b224008d1b39960797c9101137c7c8b9ceee0637..9d10bc04d5c6bf13652c2fa057a6c2c87394c528 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,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.
@@ -147,6 +147,17 @@ int countNonlinearVsites(const gmx_mtop_t& mtop);
 int countInterUpdategroupVsites(const gmx_mtop_t&                           mtop,
                                 gmx::ArrayRef<const gmx::RangePartitioning> updateGroupingPerMoleculetype);
 
+/*! \brief Return the number of virtual sites
+ *
+ * \note This is used to determine whether modular simulator can be used.
+ *       This function can be made static once modular simulator supports
+ *       virtual sites.
+ *
+ * \param[in] mtop  The global topology
+ * \return          The number of virtual sites found in the topology
+ */
+int countVsites(const gmx_mtop_t& mtop);
+
 /* Initialize the virtual site struct,
  *
  * \param[in] mtop  The global topology