LocalAtomSet construction with vectors of gmx::index
authorChristian Blau <cblau@gwdg.de>
Fri, 30 Aug 2019 09:43:24 +0000 (11:43 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 30 Aug 2019 13:14:50 +0000 (15:14 +0200)
LocalAtomSet construction is updated to follow the transition to use
gmx::index whenever objects, like atoms, are of type gmx::index in
an array.

Keeping the old int based constructors for legacy compability.

Change-Id: Ic0973f5260a8de9e87bf5391040e14e533012d88

src/gromacs/domdec/localatomsetdata.cpp
src/gromacs/domdec/localatomsetdata.h
src/gromacs/domdec/localatomsetmanager.cpp
src/gromacs/domdec/localatomsetmanager.h

index c8ff4c7ec16516b4a3eec37e501ef0fee8d941c1..7a8899ba48eac05ce22e4622a93e3236d657de7b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -65,6 +65,13 @@ LocalAtomSetData::LocalAtomSetData(ArrayRef<const int> globalIndex) :
     std::iota(collectiveIndex_.begin(), collectiveIndex_.end(), 0);
 }
 
+LocalAtomSetData::LocalAtomSetData(ArrayRef<const index> globalIndex) :
+    globalIndex_(globalIndex.begin(), globalIndex.end()), localIndex_(globalIndex.begin(), globalIndex.end())
+{
+    collectiveIndex_.resize(localIndex_.size());
+    std::iota(collectiveIndex_.begin(), collectiveIndex_.end(), 0);
+}
+
 void
 LocalAtomSetData::setLocalAndCollectiveIndices(const gmx_ga2la_t &ga2la)
 {
index dc257791a70fd76c0027de9587258c4ecf5856bf..986e26f8f5309190cf8fc76862c779f671312543 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -45,6 +45,7 @@
 #include <vector>
 
 #include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/basedefinitions.h"
 
 class gmx_ga2la_t;
 
@@ -66,9 +67,24 @@ class LocalAtomSetData
          * local and collective indices will be updated in setLocalAndCollectiveIndices
          * to match domain decompostion if domain decomposition is performed.
          *
+         * \todo remove this constructor once all indices are represented
+         *       as gmx::index instead of int.
+         *
          * \param[in] globalAtomIndex Indices of the atoms to be managed
          */
         explicit LocalAtomSetData(ArrayRef<const int> globalAtomIndex);
+
+        /*! \brief Store the data for an atom set with an index group.
+         *
+         * Prior to domain decomposition, local atom indices are global atom indices
+         * and the collective index runs from 0..numberOfAtoms-1.
+         * local and collective indices will be updated in setLocalAndCollectiveIndices
+         * to match domain decompostion if domain decomposition is performed.
+         *
+         * \param[in] globalAtomIndex Indices of the atoms to be managed
+         */
+        explicit LocalAtomSetData(ArrayRef<const index> globalAtomIndex);
+
         /*! \brief Sets the local and collective indices from a lookup in ga2la.
          *
          * Calculate local and collective indices of home atoms, assuming a valid
index 6305d2bd2de2dcb608ca4894806a66cd9ae0e27a..7182c954ca2674d464f8811db19e9ea8b3dbed8d 100644 (file)
@@ -81,6 +81,13 @@ LocalAtomSetManager::add(ArrayRef<const int> globalAtomIndex)
     return LocalAtomSet(*impl_->atomSetData_.back());
 }
 
+LocalAtomSet
+LocalAtomSetManager::add(ArrayRef<const index> globalAtomIndex)
+{
+    impl_->atomSetData_.push_back(std::make_unique<internal::LocalAtomSetData>(globalAtomIndex));
+    return LocalAtomSet(*impl_->atomSetData_.back());
+}
+
 void
 LocalAtomSetManager::setIndicesInDomainDecomposition(const gmx_ga2la_t &ga2la)
 {
index 2e2853c75f7e2e53795a10002833002d6a4b0732..2b6233ede1c47b635959935b3c19927e97465988 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -47,6 +47,7 @@
 #include <memory>
 
 #include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/classhelpers.h"
 
 class gmx_ga2la_t;
@@ -70,12 +71,22 @@ class LocalAtomSetManager
         ~LocalAtomSetManager();
 
         /*! \brief Add a new atom set to be managed and give back a handle.
+         *
+         * \todo remove this routine once all indices are represented as
+         *       gmx::index instead of int.
          *
          * \param[in] globalAtomIndex Indices of the atoms to be managed
          * \returns Handle to LocalAtomSet.
          */
         LocalAtomSet add(ArrayRef<const int> globalAtomIndex);
 
+        /*! \brief Add a new atom set to be managed and give back a handle.
+         *
+         * \param[in] globalAtomIndex Indices of the atoms to be managed
+         * \returns Handle to LocalAtomSet.
+         */
+        LocalAtomSet add(ArrayRef<const index> globalAtomIndex);
+
         /*! \brief Recalculate local and collective indices from ga2la.
          * Uses global atom to local atom lookup structure to
          * update atom indices.