Separate job script files for gmxapi package versions.
[gromacs.git] / src / gromacs / domdec / localatomset.h
blob41599d37b21790c550095888e307a09a1acfa4ed
1 /*
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.
35 /*! \file
36 * \libinternal \brief
37 * Declares gmx::LocalAtomSet.
39 * \author Christian Blau <cblau@gwdg.de>
40 * \inlibraryapi
41 * \ingroup module_domdec
43 #ifndef GMX_DOMDEC_LOCALATOMSET_H
44 #define GMX_DOMDEC_LOCALATOMSET_H
46 #include <cstddef>
48 namespace gmx
50 template<typename>
51 class ArrayRef;
52 namespace internal
54 class LocalAtomSetData;
55 } // namespace internal
56 /*! \libinternal \brief
57 * A local atom set collects local, global and collective indices of
58 * the home atoms on a rank. The indices of the home atoms are automatically
59 * updated during domain decomposition, thus gmx::LocalAtomSet::localIndex
60 * enables iteration over local atoms properties like coordinates or forces.
61 * TODO: add a LocalAtomSet iterator.
63 * To generate a LocalAtomSet call gmx::LocalAtomSetManger::add and keep the
64 * handle to the LocalAtomSet returned from this call.
66 * \inlibraryapi
67 * \ingroup module_domdec
69 class LocalAtomSet
71 public:
72 friend class LocalAtomSetManager;
73 /*! \brief Maps indices on rank [0..numAtomsLocal_) to global atom indicices.
75 * \returns the collective index.
77 ArrayRef<const int> collectiveIndex() const;
78 /*! \brief Global indices of the atoms in this set.
80 * \note For best performance, store and use a local copy of the arrayref.
82 * \returns the global index.
84 ArrayRef<const int> globalIndex() const;
85 /*! \brief Local indices of the atoms.
87 * For example, the i-th local atom coordinate of this set is
88 * x[atomSet.localIndex()[i]].
90 * When using in a loop other than a range-based for loop,
91 * performance may improve if the ArrayRef is stored in
92 * a local variable before the loop is entered.
93 * Updated within domain-decomposition.
95 * \note For best performance, store and use a local copy of the ArrayRef.
97 * \returns the local index.
99 ArrayRef<const int> localIndex() const;
100 /*! \brief The number of atoms from this group index on this rank.
102 * \note For best performance, store and use a local copy of the ArrayRef.
104 std::size_t numAtomsLocal() const;
105 /*! \brief The number of all atoms from this group index on all ranks together.
107 * \note For best performance, store and use a local copy.
109 std::size_t numAtomsGlobal() const;
111 private:
112 /*! \brief Constructs a new atom set by setting a reference to its
113 * internal data.
114 * \param[in] data The data for the atom set is stored
115 * in LocalAtomSetData, which is manged by \ref gmx::LocalAtomSetManager.
117 explicit LocalAtomSet(const internal::LocalAtomSetData& data);
119 const internal::LocalAtomSetData* data_;
122 } // namespace gmx
124 #endif