LagrangianSubMesh.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-2026 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 Class
25  Foam::LagrangianSubMesh
26 
27 Description
28  Mesh that relates to a sub-section of a Lagrangian mesh. This is used to
29  construct fields that relate to a contiguous sub-set of the Lagrangian
30  elements. This class only stores references and the indices defining the
31  range of the sub-set, so it is very lightweight and can be constructed and
32  thrown away largely without consideration of expense.
33 
34 SourceFiles
35  LagrangianSubMesh.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef LagrangianSubMesh_H
40 #define LagrangianSubMesh_H
41 
42 #include "LagrangianState.H"
43 #include "LagrangianFieldsFwd.H"
44 #include "LagrangianSubFieldsFwd.H"
45 #include "polyMesh.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class LagrangianMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class LagrangianSubMesh Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 {
60  // Private Data
61 
62  //- Reference to the Lagrangian mesh
63  const LagrangianMesh& mesh_;
64 
65  //- Group of the elements in this subset
66  const LagrangianGroup group_;
67 
68  //- Size of the subset
69  label size_;
70 
71  //- Start index of the subset
72  label start_;
73 
74  //- Index with which to compare instances
75  const uint64_t index_;
76 
77 
78  // Private Constructors
79 
80  //- Construct from components
81  explicit LagrangianSubMesh
82  (
83  const LagrangianMesh& mesh,
84  const LagrangianGroup group,
85  const label size,
86  const label start,
87  const uint64_t index
88  );
89 
90 
91 public:
92 
93  // Friend classes
94 
95  //- Allow the Lagrangian mesh to construct with a specified index
96  friend class LagrangianMesh;
97 
98 
99  //- Runtime type information
100  ClassName("LagrangianSubMesh");
101 
102 
103  // Public Type Definitions
104 
105  //- Mesh type
106  typedef LagrangianSubMesh Mesh;
107 
108 
109  // Constructors
110 
111  //- Construct from components, except for the index which is
112  // automatically generated from the complete mesh
113  explicit LagrangianSubMesh
114  (
115  const LagrangianMesh& mesh,
116  const LagrangianGroup group,
117  const label size,
118  const label start
119  );
120 
121  //- Construct from Lagrangian mesh, group offsets and group
122  explicit LagrangianSubMesh
123  (
124  const LagrangianMesh& mesh,
125  const labelList& groupOffsets,
126  const LagrangianGroup group
127  );
128 
129 
130  //- Destructor
132 
133 
134  // Member functions
135 
136  // Access
137 
138  //- Return the mesh
139  inline const LagrangianMesh& mesh() const;
140 
141  //- Return the object registry
142  const objectRegistry& db() const;
143 
144  //- Return time
145  const Time& time() const;
146 
147  //- Return the group
148  inline LagrangianGroup group() const;
149 
150  //- Return size
151  inline label size() const;
152 
153  //- Return size
154  inline label globalSize() const;
155 
156  //- Return size
157  static inline label size(const LagrangianSubMesh& subMesh);
158 
159  //- Return whether or not the mesh is empty
160  inline bool empty() const;
161 
162  //- Return start
163  inline label start() const;
164 
165  //- Return end
166  inline label end() const;
167 
168  //- Return the index
169  inline uint64_t index() const;
170 
171 
172  // Sub-setting
173 
174  //- Return the name of a field corresponding to this sub-mesh
175  inline word sub(const word& fieldName) const;
176 
177  //- Return the name of a field corresponding to the complete mesh
178  word complete(const word& subFieldName) const;
179 
180  //- Return a sub-list corresponding to this sub-mesh
181  template<class Type>
182  SubList<Type> sub(const List<Type>& list) const;
183 
184  //- Return a sub-field corresponding to this sub-mesh
185  template<class Type>
186  SubField<Type> sub(const Field<Type>& field) const;
187 
188  //- Return a sub-dimensioned-field corresponding to this sub-mesh
189  template<class Type, template<class> class PrimitiveField>
191  (
193  ) const;
194 
195 
196  // Geometry
197 
198  //- Return the face normals at the Lagrangian locations
199  template<class FieldType>
200  static tmp<FieldType> nf
201  (
203  );
204 
205  //- Return the face normals at the Lagrangian locations
206  template<class FieldType>
208  (
210  ) const;
211 
212  //- Return the face velocities at the Lagrangian locations
213  template<class FieldType>
214  static tmp<FieldType> Uf
215  (
217  );
218 
219  //- Return the face velocities at the Lagrangian locations
220  template<class FieldType>
222  (
224  ) const;
225 
226 
227  // Member Operators
228 
229  //- Add a sub-mesh to this one. Must relate to adjacent elements.
230  void operator+=(const LagrangianSubMesh&);
231 };
232 
233 
234 // Template Specialisations
235 
236 template<>
238 (
240 );
241 
242 template<>
244 (
246 );
247 
248 template<>
250 (
252 ) const;
253 
254 template<>
256 (
258 ) const;
259 
260 template<>
262 (
264 );
265 
266 template<>
268 (
270 );
271 
272 template<>
274 (
276 ) const;
277 
278 template<>
280 (
282 ) const;
283 
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #include "LagrangianSubMeshI.H"
292 
293 #ifdef NoRepository
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
Class containing Lagrangian geometry and topology.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
LagrangianGroup group() const
Return the group.
const Time & time() const
Return time.
static tmp< FieldType > nf(const LagrangianSubScalarSubField &fraction)
Return the face normals at the Lagrangian locations.
label size() const
Return size.
LagrangianSubMesh Mesh
Mesh type.
uint64_t index() const
Return the index.
label end() const
Return end.
bool empty() const
Return whether or not the mesh is empty.
const objectRegistry & db() const
Return the object registry.
void operator+=(const LagrangianSubMesh &)
Add a sub-mesh to this one. Must relate to adjacent elements.
ClassName("LagrangianSubMesh")
Runtime type information.
static tmp< FieldType > Uf(const LagrangianSubScalarSubField &fraction)
Return the face velocities at the Lagrangian locations.
word complete(const word &subFieldName) const
Return the name of a field corresponding to the complete mesh.
const LagrangianMesh & mesh() const
Return the mesh.
word sub(const word &fieldName) const
Return the name of a field corresponding to this sub-mesh.
label globalSize() const
Return size.
label start() const
Return start.
Pre-declare related SubField type.
Definition: SubField.H:63
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
const unitSet fraction
Namespace for OpenFOAM.
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
LagrangianGroup
Lagrangian group enumeration.