LagrangianState.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #ifndef LagrangianState_H
27 #define LagrangianState_H
28 
29 #include "word.H"
30 #include "label.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 //- Lagrangian state enumeration
40 enum class LagrangianState : label
41 {
42  none = labelMin,
43  complete = 0,
44  inCell = 1,
45  onInternalFace = 2,
46  onPatchZero = 3,
47  toBeRemoved = labelMax - 1
48 };
49 
50 //- Return a string representation of a Lagrangian state enumeration
51 word name(const LagrangianState state);
52 
53 //- Output operator for Lagrangian state
54 inline Ostream& operator<<(Ostream& os, const LagrangianState state)
55 {
56  return os << name(state);
57 }
58 
59 //- Lagrangian group enumeration
60 enum class LagrangianGroup : label
61 {
62  none = labelMin,
63  complete = 0,
64  inInternalMesh = 1,
65  onPatchZero = 2,
66  toBeRemoved = labelMax - 1
67 };
68 
69 //- Return a string representation of a Lagrangian group enumeration
70 word name(const LagrangianGroup group);
71 
72 //- Output operator for Lagrangian group
74 {
75  return os << name(group);
76 }
77 
78 //- Convert from a state enumeration to the corresponding group enumerations
80 {
81  switch (state)
82  {
84  return LagrangianGroup::none;
91  default:
92  return
93  static_cast<LagrangianGroup>
94  (
95  static_cast<label>(state)
96  - static_cast<label>(LagrangianState::onPatchZero)
97  + static_cast<label>(LagrangianGroup::onPatchZero)
98  );
101  }
102 }
103 
104 //- Convert from a state enumeration to the corresponding group enumerations
106 {
107  switch (group)
108  {
110  return LagrangianState::none;
114  return LagrangianState::none; // <-- state is unknown
115  default:
116  return
117  static_cast<LagrangianState>
118  (
119  static_cast<label>(group)
120  - static_cast<label>(LagrangianGroup::onPatchZero)
121  + static_cast<label>(LagrangianState::onPatchZero)
122  );
125  }
126 }
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #endif
135 
136 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const char *const group
Group name for atomic constants.
Namespace for OpenFOAM.
LagrangianState groupToState(const LagrangianGroup &group)
Convert from a state enumeration to the corresponding group enumerations.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
LagrangianState
Lagrangian state enumeration.
LagrangianGroup stateToGroup(const LagrangianState &state)
Convert from a state enumeration to the corresponding group enumerations.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
LagrangianGroup
Lagrangian group enumeration.
static const label labelMax
Definition: label.H:62
static const label labelMin
Definition: label.H:61