2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018, 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::LocalAtomSet.
39 * \author Christian Blau <cblau@gwdg.de>
41 * \ingroup module_domdec
43 #ifndef GMX_DOMDEC_LOCALATOMSET_H
44 #define GMX_DOMDEC_LOCALATOMSET_H
46 #include "gromacs/utility/arrayref.h"
53 class LocalAtomSetData
;
54 } // namespace internal
55 /*! \libinternal \brief
56 * A local atom set collects local, global and collective indices of
57 * the home atoms on a rank. The indices of the home atoms are automatically
58 * updated during domain decomposition, thus gmx::LocalAtomSet::localIndex
59 * enables iteration over local atoms properties like coordinates or forces.
60 * TODO: add a LocalAtomSet iterator.
62 * To generate a LocalAtomSet call gmx::LocalAtomSetManger::add and keep the
63 * handle to the LocalAtomSet returned from this call.
66 * \ingroup module_domdec
71 friend class LocalAtomSetManager
;
72 /*! \brief Maps indices on rank [0..numAtomsLocal_) to global atom indicices.
74 * \returns the collective index.
76 ArrayRef
<const int> collectiveIndex() const;
77 /*! \brief Global indices of the atoms in this set.
79 * \note For best performance, store and use a local copy of the arrayref.
81 * \returns the global index.
83 ArrayRef
<const int> globalIndex() const;
84 /*! \brief Local indices of the atoms.
86 * For example, the i-th local atom coordinate of this set is
87 * x[atomSet.localIndex()[i]].
89 * When using in a loop other than a range-based for loop,
90 * performance may improve if the ArrayRef is stored in
91 * a local variable before the loop is entered.
92 * Updated within domain-decomposition.
94 * \note For best performance, store and use a local copy of the ArrayRef.
96 * \returns the local index.
98 ArrayRef
<const int> localIndex() const;
99 /*! \brief The number of atoms from this group index on this rank.
101 * \note For best performance, store and use a local copy of the ArrayRef.
103 std::size_t numAtomsLocal() const;
104 /*! \brief The number of all atoms from this group index on all ranks together.
106 * \note For best performance, store and use a local copy.
108 std::size_t numAtomsGlobal() const;
110 /*! \brief Constructs a new atom set by setting a reference to its
112 * \param[in] data The data for the atom set is stored
113 * in LocalAtomSetData, which is manged by \ref gmx::LocalAtomSetManager.
115 explicit LocalAtomSet(const internal::LocalAtomSetData
&data
);
117 const internal::LocalAtomSetData
* data_
;