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-2023 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 FaceCutValues Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 template<class Type>
85 {
86  // Private Data
87 
88  //- The face
89  const face& f_;
90 
91  //- The face's cuts
92  const List<labelPair>& fCuts_;
93 
94  //- The point values that we want to iterate over
95  const Field<Type>& pPsis_;
96 
97  //- The point values that define the iso-surface
98  const scalarField& pAlphas_;
99 
100  //- The value that defines the iso-surface
101  const scalar isoAlpha_;
102 
103  //- Do we want to iterate over the cut below or above the iso surface?
104  const bool below_;
105 
106 
107 public:
108 
109  // Public Typedefs
110 
111  //- The value type
112  typedef Type value_type;
113 
114 
115  // Public Classes
116 
117  //- Forward iterator
119  {
120  // Private Data
121 
122  //- Reference to the face-values
123  const FaceCutValues<Type>& fValues_;
124 
125  //- Index of the sub-face and sub-face-point
126  label i_, j_;
127 
128  //- Cache of values on cut edges for this sub-face segment
129  mutable Tuple2<label, Pair<Type>> iAndCutPsis_;
130 
131 
132  // Private Member Functions
133 
134  //- Get the values on the cut edges for this sub-face segment
135  const Pair<Type>& cutPsis(const label i) const;
136 
137  //- Return the size of the given sub-face
138  label size(const label i) const;
139 
140  //- Return the value for the given sub-face and sub-face-point
141  const Type psi(const label i, const label j) const;
142 
143 
144  public:
145 
146  // Constructors
147 
148  //- Construct from components
150  (
151  const FaceCutValues<Type>& fValues,
152  const label i,
153  const label j
154  );
155 
156 
157  // Member Functions
158 
159  //- Get the next value around the sub-face
160  Type next() const;
161 
162 
163  // Member Operators
164 
165  //- Equality comparison
166  bool operator==(const const_iterator& it) const;
167 
168  //- Inequality comparison
169  bool operator!=(const const_iterator& it) const;
170 
171  //- Dereference
172  Type operator*() const;
173 
174  //- Increment
175  inline const_iterator& operator++();
176 
177  //- Increment
178  inline const_iterator operator++(int);
179  };
180 
181 
182  // Constructors
183 
184  //- Construct from components
186  (
187  const face& f,
188  const List<labelPair>& fCuts,
189  const Field<Type>& pPsis,
190  const scalarField& pAlphas,
191  const scalar isoAlpha,
192  const bool below
193  );
194 
195 
196  // Member Functions
197 
198  //- Get the beginning of the iteration over the values
199  const_iterator begin() const;
200 
201  //- Get the end of the iteration over the values
202  const_iterator end() const;
203 };
204 
205 
206 /*---------------------------------------------------------------------------*\
207  Class CellCutValues Declaration
208 \*---------------------------------------------------------------------------*/
209 
210 template<class Type>
212 {
213  // Private Data
214 
215  //- The cell
216  const cell& c_;
217 
218  //- The cell's edge addressing
219  const cellEdgeAddressing& cAddr_;
220 
221  //- The cell's cuts
222  const labelListList& cCuts_;
223 
224  //- The faces
225  const faceList& fs_;
226 
227  //- The point values that we want to iterate over
228  const Field<Type>& pPsis_;
229 
230  //- The point values that define the iso-surface
231  const scalarField& pAlphas_;
232 
233  //- The value that defines the iso-surface
234  const scalar isoAlpha_;
235 
236 
237 public:
238 
239  // Public Typedefs
240 
241  //- The value type
242  typedef Type value_type;
243 
244 
245  // Public Classes
246 
247  //- Forward iterator
249  {
250  // Private Data
251 
252  //- Reference to the cell-values
253  const CellCutValues<Type>& cValues_;
254 
255  //- Index of the loop and loop-point
256  label i_, j_;
257 
258 
259  // Private Member Functions
260 
261  //- The values at this loop-point and the next
262  Pair<Type> psis_;
263 
264  //- Return the value for the given loop and loop-point
265  Type psi(const label i, const label j);
266 
267 
268  public:
269 
270  // Constructors
271 
272  //- Construct from components
274  (
275  const CellCutValues<Type>& cValues,
276  const label i,
277  const label j
278  );
279 
280 
281  // Member Functions
282 
283  //- Get the next value around the loop
284  const Type& next() const;
285 
286 
287  // Member Operators
288 
289  //- Equality comparison
290  bool operator==(const const_iterator& it) const;
291 
292  //- Inequality comparison
293  bool operator!=(const const_iterator& it) const;
294 
295  //- Dereference
296  const Type& operator*() const;
297 
298  //- Increment
299  inline const_iterator& operator++();
300 
301  //- Increment
302  inline const_iterator operator++(int);
303  };
304 
305 
306  // Constructors
307 
308  //- Construct from components
310  (
311  const cell& c,
312  const cellEdgeAddressing& cAddr,
313  const labelListList& cCuts,
314  const faceList& fs,
315  const Field<Type>& pPsis,
316  const scalarField& pAlphas,
317  const scalar isoAlpha
318  );
319 
320 
321  // Member Functions
322 
323  //- Get the beginning of the iteration over the values
324  const_iterator begin() const;
325 
326  //- Get the end of the iteration over the values
327  const_iterator end() const;
328 };
329 
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
331 
332 } // End namespace cutPoly
333 } // End namespace Foam
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #include "cutPolyValueI.H"
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #ifdef NoRepository
342  #include "cutPolyValueTemplates.C"
343 #endif
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 #endif
348 
349 // ************************************************************************* //
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 <T> with first() and second() elements.
Definition: Pair.H:65
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:242
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:112
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.
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)