2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 * Declares gmx::internal::LocalAtomSetData.
39 * \author Christian Blau <cblau@gwdg.de>
40 * \ingroup module_domdec
42 #ifndef GMX_DOMDEC_LOCALATOMSETDATA_H
43 #define GMX_DOMDEC_LOCALATOMSETDATA_H
48 #include "gromacs/utility/arrayref.h"
49 #include "gromacs/utility/basedefinitions.h"
59 /* \brief Internal class for storing and managing atom indices of an atom set.
61 class LocalAtomSetData
64 /*! \brief Store the data for an atom set with an index group.
66 * Prior to domain decomposition, local atom indices are global atom indices
67 * and the collective index runs from 0..numberOfAtoms-1.
68 * local and collective indices will be updated in setLocalAndCollectiveIndices
69 * to match domain decompostion if domain decomposition is performed.
71 * \todo remove this constructor once all indices are represented
72 * as gmx::index instead of int.
74 * \note Not created if the internal int type does match gmx::index
76 * \param[in] globalAtomIndex Indices of the atoms to be managed
78 template<typename T
= void, typename U
= std::enable_if_t
<!std::is_same_v
<int, index
>, T
>>
79 explicit LocalAtomSetData(ArrayRef
<const int> globalAtomIndex
) :
80 globalIndex_(globalAtomIndex
.begin(), globalAtomIndex
.end()),
81 localIndex_(globalAtomIndex
.begin(), globalAtomIndex
.end())
83 collectiveIndex_
.resize(localIndex_
.size());
84 std::iota(collectiveIndex_
.begin(), collectiveIndex_
.end(), 0);
87 /*! \brief Store the data for an atom set with an index group.
89 * Prior to domain decomposition, local atom indices are global atom indices
90 * and the collective index runs from 0..numberOfAtoms-1.
91 * local and collective indices will be updated in setLocalAndCollectiveIndices
92 * to match domain decompostion if domain decomposition is performed.
94 * \param[in] globalAtomIndex Indices of the atoms to be managed
96 explicit LocalAtomSetData(ArrayRef
<const index
> globalAtomIndex
);
98 /*! \brief Sets the local and collective indices from a lookup in ga2la.
100 * Calculate local and collective indices of home atoms, assuming a valid
101 * global atom to local atom look-up table.
103 * \param[in] ga2la lookup table that reports if an atom is local.
105 void setLocalAndCollectiveIndices(const gmx_ga2la_t
& ga2la
);
106 /*! \brief Global indices of the atoms in this set. */
107 const std::vector
<int> globalIndex_
;
108 /*! \brief Maps indices on this rank [0..num_atoms_local_) to global atom indicices,
109 * so that localIndex[i] identifies the same atom as globalIndex[collectiveIndex[i]].
111 * This translation of locally dense atom data to global representation,
112 * allows to adresses per-atom properties, e.g., scattering factors,
113 * that are stored in a global continuous array for each atom of the atom set.
115 std::vector
<int> collectiveIndex_
;
116 /*! \brief Local indices of the atoms.
117 * Access the i-th local atom coordinate of this set by x[local_index_[i]].
118 * Constructed and updated every domain-decomposition step.
120 std::vector
<int> localIndex_
;
123 } // namespace internal