2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019,2021, 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.
36 /*! \libinternal \file
37 * \brief Defines atom and atom interaction locality enums
39 * \author Berk Hess <hess@kth.se>
40 * \ingroup module_mdtypes
43 #ifndef GMX_MDTYPES_LOCALITY_H
44 #define GMX_MDTYPES_LOCALITY_H
46 #include "gromacs/utility/enumerationhelpers.h"
47 #include "gromacs/utility/exceptions.h"
52 /*! \brief Atom locality indicator: local, non-local, all.
55 * gridding, force calculation, x/f buffer operations
57 enum class AtomLocality : int
59 Local = 0, //!< Local atoms
60 NonLocal = 1, //!< Non-local atoms
61 All = 2, //!< Both local and non-local atoms
62 Count = 3 //!< The number of atom locality types
65 /*! \brief Get the human-friendly name for atom localities.
67 * \param[in] enumValue The enum value to get the name for.
69 [[maybe_unused]] static const char* enumValueToString(AtomLocality enumValue)
71 static constexpr gmx::EnumerationArray<AtomLocality, const char*> atomLocalityNames = {
72 "Local", "Non-local", "All"
74 return atomLocalityNames[enumValue];
76 /*! \brief Interaction locality indicator: local, non-local, all.
79 * pair-search, force calculation, x/f buffer operations
81 enum class InteractionLocality : int
83 Local = 0, //!< Interactions between local atoms only
84 NonLocal = 1, //!< Interactions between non-local and (non-)local atoms
85 Count = 2 //!< The number of interaction locality types
88 /*! \brief Get the human-friendly name for interaction localities.
90 * \param[in] enumValue The enum value to get the name for.
92 [[maybe_unused]] static const char* enumValueToString(InteractionLocality enumValue)
94 static constexpr gmx::EnumerationArray<InteractionLocality, const char*> interactionLocalityNames = {
97 return interactionLocalityNames[enumValue];
100 /*! \brief Convert atom locality to interaction locality.
102 * In the current implementation the this is straightforward conversion:
103 * local to local, non-local to non-local.
105 * \param[in] atomLocality Atom locality specifier
106 * \returns Interaction locality corresponding to the atom locality passed.
108 static inline InteractionLocality atomToInteractionLocality(const AtomLocality atomLocality)
111 /* determine interaction locality from atom locality */
112 if (atomLocality == AtomLocality::Local)
114 return InteractionLocality::Local;
116 else if (atomLocality == AtomLocality::NonLocal)
118 return InteractionLocality::NonLocal;
122 GMX_THROW(gmx::InconsistentInputError(
123 "Only Local and NonLocal atom locities can be converted to interaction locality."));
129 #endif // GMX_MDTYPES_LOCALITY_H