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-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 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 
165 
166 /*---------------------------------------------------------------------------*\
167  Class FaceCutValues Declaration
168 \*---------------------------------------------------------------------------*/
169 
170 template<class Type>
172 {
173  // Private Data
174 
175  //- The face
176  const face& f_;
177 
178  //- The face's cuts
179  const List<labelPair>& fCuts_;
180 
181  //- The point values that we want to iterate over
182  const Field<Type>& pPsis_;
183 
184  //- The point values that define the iso-surface
185  const scalarField& pAlphas_;
186 
187  //- The value that defines the iso-surface
188  const scalar isoAlpha_;
189 
190  //- Do we want to iterate over the cut below or above the iso surface?
191  const bool below_;
192 
193 
194 public:
195 
196  // Public Typedefs
197 
198  //- The value type
199  typedef Type value_type;
200 
201 
202  // Public Classes
203 
204  //- Forward iterator
206  {
207  // Private Data
208 
209  //- Reference to the face-values
210  const FaceCutValues<Type>& fValues_;
211 
212  //- Index of the sub-face and sub-face-point
213  label i_, j_;
214 
215  //- Cache of values on cut edges for this sub-face segment
216  mutable Tuple2<label, Pair<Type>> iAndCutPsis_;
217 
218 
219  // Private Member Functions
220 
221  //- Get the values on the cut edges for this sub-face segment
222  const Pair<Type>& cutPsis(const label i) const;
223 
224  //- Return the size of the given sub-face
225  label size(const label i) const;
226 
227  //- Return the value for the given sub-face and sub-face-point
228  const Type psi(const label i, const label j) const;
229 
230 
231  public:
232 
233  // Constructors
234 
235  //- Construct from components
237  (
238  const FaceCutValues<Type>& fValues,
239  const label i,
240  const label j
241  );
242 
243 
244  // Member Functions
245 
246  //- Get the next value around the sub-face
247  Type next() const;
248 
249 
250  // Member Operators
251 
252  //- Equality comparison
253  bool operator==(const const_iterator& it) const;
254 
255  //- Inequality comparison
256  bool operator!=(const const_iterator& it) const;
257 
258  //- Dereference
259  Type operator*() const;
260 
261  //- Increment
262  inline const_iterator& operator++();
263 
264  //- Increment
265  inline const_iterator operator++(int);
266  };
267 
268 
269  // Constructors
270 
271  //- Construct from components
273  (
274  const face& f,
275  const List<labelPair>& fCuts,
276  const Field<Type>& pPsis,
277  const scalarField& pAlphas,
278  const scalar isoAlpha,
279  const bool below
280  );
281 
282 
283  // Member Functions
284 
285  //- Get the beginning of the iteration over the values
286  const_iterator begin() const;
287 
288  //- Get the end of the iteration over the values
289  const_iterator end() const;
290 };
291 
292 
293 /*---------------------------------------------------------------------------*\
294  Class CellCutValues Declaration
295 \*---------------------------------------------------------------------------*/
296 
297 template<class Type>
299 {
300  // Private Data
301 
302  //- The cell
303  const cell& c_;
304 
305  //- The cell's edge addressing
306  const cellEdgeAddressing& cAddr_;
307 
308  //- The cell's cuts
309  const labelListList& cCuts_;
310 
311  //- The faces
312  const faceList& fs_;
313 
314  //- The point values that we want to iterate over
315  const Field<Type>& pPsis_;
316 
317  //- The point values that define the iso-surface
318  const scalarField& pAlphas_;
319 
320  //- The value that defines the iso-surface
321  const scalar isoAlpha_;
322 
323 
324 public:
325 
326  // Public Typedefs
327 
328  //- The value type
329  typedef Type value_type;
330 
331 
332  // Public Classes
333 
334  //- Forward iterator
336  {
337  // Private Data
338 
339  //- Reference to the cell-values
340  const CellCutValues<Type>& cValues_;
341 
342  //- Index of the loop and loop-point
343  label i_, j_;
344 
345 
346  // Private Member Functions
347 
348  //- The values at this loop-point and the next
349  Pair<Type> psis_;
350 
351  //- Return the value for the given loop and loop-point
352  Type psi(const label i, const label j);
353 
354 
355  public:
356 
357  // Constructors
358 
359  //- Construct from components
361  (
362  const CellCutValues<Type>& cValues,
363  const label i,
364  const label j
365  );
366 
367 
368  // Member Functions
369 
370  //- Get the next value around the loop
371  const Type& next() const;
372 
373 
374  // Member Operators
375 
376  //- Equality comparison
377  bool operator==(const const_iterator& it) const;
378 
379  //- Inequality comparison
380  bool operator!=(const const_iterator& it) const;
381 
382  //- Dereference
383  const Type& operator*() const;
384 
385  //- Increment
386  inline const_iterator& operator++();
387 
388  //- Increment
389  inline const_iterator operator++(int);
390  };
391 
392 
393  // Constructors
394 
395  //- Construct from components
397  (
398  const cell& c,
399  const cellEdgeAddressing& cAddr,
400  const labelListList& cCuts,
401  const faceList& fs,
402  const Field<Type>& pPsis,
403  const scalarField& pAlphas,
404  const scalar isoAlpha
405  );
406 
407 
408  // Member Functions
409 
410  //- Get the beginning of the iteration over the values
411  const_iterator begin() const;
412 
413  //- Get the end of the iteration over the values
414  const_iterator end() const;
415 };
416 
417 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
418 
419 } // End namespace cutPoly
420 } // End namespace Foam
421 
422 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
423 
424 #include "cutPolyValueI.H"
425 
426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
427 
428 #ifdef NoRepository
429  #include "cutPolyValueTemplates.C"
430 #endif
431 
432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
433 
434 #endif
435 
436 // ************************************************************************* //
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:66
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:329
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.
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 end() const
Get the end of the iteration over the values.
Type value_type
The value type.
Definition: cutPolyValue.H:199
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.
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)