cutPolyValue.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) 2022-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 Namespace
25  Foam::cutPoly
26 
27 Description
28  Functions and classes for extracting values from cut edges, faces and cells
29 
30 SourceFiles
31  cutPolyValueI.H
32  cutPolyValueTemplates.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef cutPolyValue_H
37 #define cutPolyValue_H
38 
39 #include "cutPoly.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace cutPoly
46 {
47 
48 //- Get the local coordinate within an edge, given end point values and an
49 // iso-value
50 inline scalar edgeCutLambda
51 (
52  const edge& e,
53  const scalarField& pAlphas,
54  const scalar isoAlpha
55 );
56 
57 //- Linearly interpolate a value from the end points to the cut point of an
58 // edge, given a local coordinate within the edge
59 template<class Type>
60 Type edgeCutValue
61 (
62  const edge& e,
63  const scalar lambda,
64  const Field<Type>& pPsis
65 );
66 
67 //- Linearly interpolate a value from the end points to the cut point of an
68 // edge, given end point values and an iso-value
69 template<class Type>
70 Type edgeCutValue
71 (
72  const edge& e,
73  const scalarField& pAlphas,
74  const scalar isoAlpha,
75  const Field<Type>& pPsis
76 );
77 
78 
79 /*---------------------------------------------------------------------------*\
80  Class FaceValues Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 template<class Type>
85 {
86  // Private Data
87 
88  //- The face
89  const face& f_;
90 
91  //- The point values that we want to iterate over
92  const Field<Type>& pPsis_;
93 
94 
95 public:
96 
97  // Public Typedefs
98 
99  //- The value type
100  typedef Type value_type;
101 
102 
103  // Public Classes
104 
105  //- Forward iterator
107  {
108  // Private Data
109 
110  //- Reference to the face-values
111  const FaceValues<Type>& fValues_;
112 
113  //- Index of the face-point
114  label i_;
115 
116 
117  public:
118 
119  // Constructors
120 
121  //- Construct from components
122  const_iterator(const FaceValues<Type>& fValues, const label i);
123 
124 
125  // Member Functions
126 
127  //- Get the next value around the sub-face
128  Type next() const;
129 
130 
131  // Member Operators
132 
133  //- Equality comparison
134  bool operator==(const const_iterator& it) const;
135 
136  //- Inequality comparison
137  bool operator!=(const const_iterator& it) const;
138 
139  //- Dereference
140  Type operator*() const;
141 
142  //- Increment
143  inline const_iterator& operator++();
144 
145  //- Increment
146  inline const_iterator operator++(int);
147  };
148 
149 
150  // Constructors
151 
152  //- Construct from components
153  FaceValues(const face& f, const Field<Type>& pPsis);
154 
155 
156  // Member Functions
157 
158  //- Get the beginning of the iteration over the values
159  const_iterator begin() const;
160 
161  //- Get the end of the iteration over the values
162  const_iterator end() const;
163 
164  //- Get the beginning of the iteration over the values
165  const_iterator cbegin() const;
166 
167  //- Get the end of the iteration over the values
168  const_iterator cend() const;
169 };
170 
171 
172 /*---------------------------------------------------------------------------*\
173  Class FaceCutValues Declaration
174 \*---------------------------------------------------------------------------*/
175 
176 template<class Type>
178 {
179  // Private Data
180 
181  //- The face
182  const face& f_;
183 
184  //- The face's cuts
185  const List<labelPair>& fCuts_;
186 
187  //- The point values that we want to iterate over
188  const Field<Type>& pPsis_;
189 
190  //- The point values that define the iso-surface
191  const scalarField& pAlphas_;
192 
193  //- The value that defines the iso-surface
194  const scalar isoAlpha_;
195 
196  //- Do we want to iterate over the cut below or above the iso surface?
197  const bool below_;
198 
199 
200 public:
201 
202  // Public Typedefs
203 
204  //- The value type
205  typedef Type value_type;
206 
207 
208  // Public Classes
209 
210  //- Forward iterator
212  {
213  // Private Data
214 
215  //- Reference to the face-values
216  const FaceCutValues<Type>& fValues_;
217 
218  //- Index of the sub-face and sub-face-point
219  label i_, j_;
220 
221  //- Cache of values on cut edges for this sub-face segment
222  mutable Tuple2<label, Pair<Type>> iAndCutPsis_;
223 
224 
225  // Private Member Functions
226 
227  //- Get the values on the cut edges for this sub-face segment
228  const Pair<Type>& cutPsis(const label i) const;
229 
230  //- Return the size of the given sub-face
231  label size(const label i) const;
232 
233  //- Return the value for the given sub-face and sub-face-point
234  const Type psi(const label i, const label j) const;
235 
236 
237  public:
238 
239  // Constructors
240 
241  //- Construct from components
243  (
244  const FaceCutValues<Type>& fValues,
245  const label i,
246  const label j
247  );
248 
249 
250  // Member Functions
251 
252  //- Get the next value around the sub-face
253  Type next() const;
254 
255 
256  // Member Operators
257 
258  //- Equality comparison
259  bool operator==(const const_iterator& it) const;
260 
261  //- Inequality comparison
262  bool operator!=(const const_iterator& it) const;
263 
264  //- Dereference
265  Type operator*() const;
266 
267  //- Increment
268  inline const_iterator& operator++();
269 
270  //- Increment
271  inline const_iterator operator++(int);
272  };
273 
274 
275  // Constructors
276 
277  //- Construct from components
279  (
280  const face& f,
281  const List<labelPair>& fCuts,
282  const Field<Type>& pPsis,
283  const scalarField& pAlphas,
284  const scalar isoAlpha,
285  const bool below
286  );
287 
288 
289  // Member Functions
290 
291  //- Get the beginning of the iteration over the values
292  const_iterator begin() const;
293 
294  //- Get the end of the iteration over the values
295  const_iterator end() const;
296 
297  //- Get the beginning of the iteration over the values
298  const_iterator cbegin() const;
299 
300  //- Get the end of the iteration over the values
301  const_iterator cend() const;
302 };
303 
304 
305 /*---------------------------------------------------------------------------*\
306  Class CellCutValues Declaration
307 \*---------------------------------------------------------------------------*/
308 
309 template<class Type>
311 {
312  // Private Data
313 
314  //- The cell
315  const cell& c_;
316 
317  //- The cell's edge addressing
318  const cellEdgeAddressing& cAddr_;
319 
320  //- The cell's cuts
321  const labelListList& cCuts_;
322 
323  //- The faces
324  const faceList& fs_;
325 
326  //- The point values that we want to iterate over
327  const Field<Type>& pPsis_;
328 
329  //- The point values that define the iso-surface
330  const scalarField& pAlphas_;
331 
332  //- The value that defines the iso-surface
333  const scalar isoAlpha_;
334 
335 
336 public:
337 
338  // Public Typedefs
339 
340  //- The value type
341  typedef Type value_type;
342 
343 
344  // Public Classes
345 
346  //- Forward iterator
348  {
349  // Private Data
350 
351  //- Reference to the cell-values
352  const CellCutValues<Type>& cValues_;
353 
354  //- Index of the loop and loop-point
355  label i_, j_;
356 
357 
358  // Private Member Functions
359 
360  //- The values at this loop-point and the next
361  Pair<Type> psis_;
362 
363  //- Return the value for the given loop and loop-point
364  Type psi(const label i, const label j);
365 
366 
367  public:
368 
369  // Constructors
370 
371  //- Construct from components
373  (
374  const CellCutValues<Type>& cValues,
375  const label i,
376  const label j
377  );
378 
379 
380  // Member Functions
381 
382  //- Get the next value around the loop
383  const Type& next() const;
384 
385 
386  // Member Operators
387 
388  //- Equality comparison
389  bool operator==(const const_iterator& it) const;
390 
391  //- Inequality comparison
392  bool operator!=(const const_iterator& it) const;
393 
394  //- Dereference
395  const Type& operator*() const;
396 
397  //- Increment
398  inline const_iterator& operator++();
399 
400  //- Increment
401  inline const_iterator operator++(int);
402  };
403 
404 
405  // Constructors
406 
407  //- Construct from components
409  (
410  const cell& c,
411  const cellEdgeAddressing& cAddr,
412  const labelListList& cCuts,
413  const faceList& fs,
414  const Field<Type>& pPsis,
415  const scalarField& pAlphas,
416  const scalar isoAlpha
417  );
418 
419 
420  // Member Functions
421 
422  //- Get the beginning of the iteration over the values
423  const_iterator begin() const;
424 
425  //- Get the end of the iteration over the values
426  const_iterator end() const;
427 
428  //- Get the beginning of the iteration over the values
429  const_iterator cbegin() const;
430 
431  //- Get the end of the iteration over the values
432  const_iterator cend() const;
433 };
434 
435 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
436 
437 } // End namespace cutPoly
438 } // End namespace Foam
439 
440 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 
442 #include "cutPolyValueI.H"
443 
444 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
445 
446 #ifdef NoRepository
447  #include "cutPolyValueTemplates.C"
448 #endif
449 
450 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
451 
452 #endif
453 
454 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:83
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:67
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
bool operator==(const const_iterator &it) const
Equality comparison.
const Type & next() const
Get the next value around the loop.
const_iterator(const CellCutValues< Type > &cValues, const label i, const label j)
Construct from components.
bool operator!=(const const_iterator &it) const
Inequality comparison.
Type value_type
The value type.
Definition: cutPolyValue.H:341
const_iterator begin() const
Get the beginning of the iteration over the values.
const_iterator cbegin() const
Get the beginning of the iteration over the values.
const_iterator end() const
Get the end of the iteration over the values.
const_iterator cend() const
Get the end of the iteration over the values.
CellCutValues(const cell &c, const cellEdgeAddressing &cAddr, const labelListList &cCuts, const faceList &fs, const Field< Type > &pPsis, const scalarField &pAlphas, const scalar isoAlpha)
Construct from components.
bool operator==(const const_iterator &it) const
Equality comparison.
const_iterator(const FaceCutValues< Type > &fValues, const label i, const label j)
Construct from components.
Type next() const
Get the next value around the sub-face.
bool operator!=(const const_iterator &it) const
Inequality comparison.
const_iterator cend() const
Get the end of the iteration over the values.
const_iterator end() const
Get the end of the iteration over the values.
Type value_type
The value type.
Definition: cutPolyValue.H:205
const_iterator cbegin() const
Get the beginning of the iteration over the values.
const_iterator begin() const
Get the beginning of the iteration over the values.
FaceCutValues(const face &f, const List< labelPair > &fCuts, const Field< Type > &pPsis, const scalarField &pAlphas, const scalar isoAlpha, const bool below)
Construct from components.
bool operator==(const const_iterator &it) const
Equality comparison.
const_iterator(const FaceValues< Type > &fValues, const label i)
Construct from components.
Type next() const
Get the next value around the sub-face.
bool operator!=(const const_iterator &it) const
Inequality comparison.
Type value_type
The value type.
Definition: cutPolyValue.H:100
const_iterator begin() const
Get the beginning of the iteration over the values.
const_iterator end() const
Get the end of the iteration over the values.
const_iterator cbegin() const
Get the beginning of the iteration over the values.
const_iterator cend() const
Get the end of the iteration over the values.
FaceValues(const face &f, const Field< Type > &pPsis)
Construct from components.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
dimensionedScalar lambda(viscosity->lookup("lambda"))
const dimensionedScalar c
Speed of light in a vacuum.
scalar edgeCutLambda(const edge &e, const scalarField &pAlphas, const scalar isoAlpha)
Get the local coordinate within an edge, given end point values and an.
Definition: cutPolyValueI.H:31
Type edgeCutValue(const edge &e, const scalar lambda, const Field< Type > &pPsis)
Linearly interpolate a value from the end points to the cut point of an.
Namespace for OpenFOAM.
const doubleScalar e
Definition: doubleScalar.H:106
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
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList f(nPoints)