sampledIsoSurface.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::sampledIsoSurface
29
30Description
31 A sampledSurface defined by a surface of iso value.
32 It only recalculates the iso-surface if time changes.
33 To be used in sampleSurfaces / functionObjects.
34
35Usage
36 Example of function object partial specification:
37 \verbatim
38 surfaces
39 {
40 surface1
41 {
42 type isoSurface;
43 isoField T;
44 isoValue 373;
45 isoMethod topo;
46 }
47 }
48 \endverbatim
49
50 Where the sub-entries comprise:
51 \table
52 Property | Description | Required | Default
53 type | isoSurface | yes |
54 isoField | field name for obtaining iso-surface | yes |
55 isoValue | value of iso-surface | yes |
56 isoValues| values for iso-surfaces | yes |
57 isoMethod | Iso-algorithm (cell/topo/point) | no | topo
58 average | cell values from averaged point values | no | false
59 bounds | limit with bounding box | no |
60 zone | limit to cell zone (name or regex) | no |
61 zones | limit to cell zones (names, regexs) | no |
62 simpleSubMesh | Simple sub-meshing in algorithm itself | no | false
63 exposedPatchName | name for zone subset | optional |
64 regularise | point snapping (bool or enum) | no | true
65 triangulate | triangulate faces (if regularise) | no | false
66 mergeTol | tolerance for merging points | no | 1e-6
67 \endtable
68
69 Some options are limited to particular algorithms.
70 - triangulate is topo-only
71 - simpleSubMesh and multiple isoValues are not available for point.
72
73Note
74 For the isoMethod \b point should use a "cellPoint" sampleScheme
75 since the triangles generated with this algorithm span across cells.
76
77SourceFiles
78 sampledIsoSurface.C
79 sampledIsoSurfaceTemplates.C
80
81\*---------------------------------------------------------------------------*/
82
83#ifndef sampledIsoSurface_H
84#define sampledIsoSurface_H
85
86#include "sampledSurface.H"
87#include "fvMeshSubset.H"
88#include "isoSurfaceBase.H"
89
90// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91
92namespace Foam
93{
94
95/*---------------------------------------------------------------------------*\
96 Class sampledIsoSurface Declaration
97\*---------------------------------------------------------------------------*/
98
99class sampledIsoSurface
100:
101 public sampledSurface
102{
103 // Private Data
104
105 //- Field to get isoSurface of
106 const word isoField_;
107
108 //- The iso-value(s)
109 List<scalar> isoValues_;
110
111 //- Parameters (filtering etc) for iso-surface
112 isoSurfaceParams isoParams_;
113
114 //- Whether to recalculate cell values as average of point values
115 bool average_;
116
117 //- Whether to triangulate ALGO_TOPO (after filtering)
118 bool triangulate_;
119
120 //- Use simple sub-meshing in algorithm itself
121 bool simpleSubMesh_;
122
123 //- The zone or zones for the iso-surface
124 wordRes zoneNames_;
125
126 //- For zones: patch to put exposed faces into
127 mutable word exposedPatchName_;
128
129
130 // Sampling geometry. Directly stored or via an iso-surface (ALGO_POINT)
131
132 //- Time at last call, also track if surface needs an update
133 mutable label prevTimeIndex_;
134
135 //- The extracted surface (direct storage)
136 mutable meshedSurface surface_;
137
138 //- For every face the original cell in mesh (direct storage)
139 mutable labelList meshCells_;
140
141 //- Extracted iso-surface, for interpolators
142 mutable autoPtr<isoSurfaceBase> isoSurfacePtr_;
143
144
145 // Mesh Subsetting
146
147 //- Cached subMesh for (pre-)subset of cell zones
148 mutable autoPtr<fvMeshSubset> subMeshPtr_;
149
150 //- Cached ignore cells for (post-)subset of cell zones
151 mutable autoPtr<bitSet> ignoreCellsPtr_;
152
153
154 // Fields
155
156 //- Cached volfield
157 mutable autoPtr<volScalarField> storedVolFieldPtr_;
158 mutable const volScalarField* volFieldPtr_;
159
160 //- Cached pointfield
161 mutable const pointScalarField* pointFieldPtr_;
162
163
164 // And on (pre-)subsetted mesh
165
166 //- Cached volfield
167 mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
168 mutable const volScalarField* volSubFieldPtr_;
169
170 //- Cached pointfield
171 mutable const pointScalarField* pointSubFieldPtr_;
172
174 // Private Member Functions
175
176 //- Get fields needed to recreate iso surface.
177 void getIsoFields() const;
178
179 //- Collect iso-surfaces into a single surface (No point merging)
180 void combineSurfaces(PtrList<isoSurfaceBase>& isoSurfPtrs);
181
182 //- Create iso surface (if time has changed)
183 // Do nothing (and return false) if no update was needed
184 bool updateGeometry() const;
185
186 //- Sample volume field onto surface faces
187 template<class Type>
188 tmp<Field<Type>> sampleOnFaces
189 (
190 const interpolation<Type>& sampler
191 ) const;
192
193 //- Interpolate volume field onto surface points
194 template<class Type>
195 tmp<Field<Type>> sampleOnPoints
196 (
197 const interpolation<Type>& interpolator
198 ) const;
199
200 //- Use isoSurfacePtr_ for point interpolation
201 template<class Type>
202 tmp<Field<Type>> sampleOnIsoSurfacePoints
203 (
204 const interpolation<Type>& interpolator
205 ) const;
206
207
208protected:
209
210 // Protected Member Functions
211
212 //- Is currently backed by an isoSurfacePtr_
213 bool hasIsoSurface() const
214 {
215 return bool(isoSurfacePtr_);
216 }
217
218
219public:
220
221 //- Runtime type information
222 TypeName("sampledIsoSurface");
223
224
225 // Constructors
226
227 //- Construct from dictionary
229 (
230 const isoSurfaceParams& params,
231 const word& name,
232 const polyMesh& mesh,
233 const dictionary& dict
234 );
235
236 //- Construct from dictionary
238 (
239 const word& name,
240 const polyMesh& mesh,
241 const dictionary& dict
242 );
243
244
245 //- Destructor
246 virtual ~sampledIsoSurface();
247
248
249 // Member Functions
250
251 //- Does the surface need an update?
252 virtual bool needsUpdate() const;
253
254 //- Mark the surface as needing an update.
255 // May also free up unneeded data.
256 // Return false if surface was already marked as expired.
257 virtual bool expire();
258
259 //- Update the surface as required.
260 // Do nothing (and return false) if no update was needed
261 virtual bool update();
262
263 //- The currently created surface geometry
264 const meshedSurface& surface() const
265 {
266 if (isoSurfacePtr_)
267 {
268 return *isoSurfacePtr_;
269 }
270 return surface_;
271 }
272
273 //- For each face, the original cell in mesh
274 const labelList& meshCells() const
275 {
276 if (isoSurfacePtr_)
277 {
278 return isoSurfacePtr_->meshCells();
279 }
280 return meshCells_;
281 }
282
283 //- Points of surface
284 virtual const pointField& points() const
285 {
286 return surface().points();
288
289 //- Faces of surface
290 virtual const faceList& faces() const
291 {
292 return surface().surfFaces();
293 }
294
295 //- Per-face zone/region information
296 virtual const labelList& zoneIds() const
297 {
298 return labelList::null();
299 }
300
301 //- Face area magnitudes
302 virtual const vectorField& Sf() const
303 {
304 return surface().Sf();
305 }
306
307 //- Face area magnitudes
308 virtual const scalarField& magSf() const
309 {
310 return surface().magSf();
311 }
312
313 //- Face centres
314 virtual const vectorField& Cf() const
315 {
316 return surface().Cf();
317 }
318
319
320 // Sample
321
322 //- Sample volume field onto surface faces
323 virtual tmp<scalarField> sample
324 (
325 const interpolation<scalar>& sampler
326 ) const;
327
328 //- Sample volume field onto surface faces
329 virtual tmp<vectorField> sample
330 (
331 const interpolation<vector>& sampler
332 ) const;
333
334 //- Sample volume field onto surface faces
335 virtual tmp<sphericalTensorField> sample
336 (
337 const interpolation<sphericalTensor>& sampler
338 ) const;
339
340 //- Sample volume field onto surface faces
342 (
343 const interpolation<symmTensor>& sampler
344 ) const;
345
346 //- Sample volume field onto surface faces
349 const interpolation<tensor>& sampler
350 ) const;
351
352
353 // Interpolate
354
355 //- Interpolate volume field onto surface points
357 (
358 const interpolation<scalar>& interpolator
359 ) const;
360
361 //- Interpolate volume field onto surface points
363 (
364 const interpolation<vector>& interpolator
365 ) const;
366
367 //- Interpolate volume field onto surface points
369 (
371 ) const;
372
373 //- Interpolate volume field onto surface points
375 (
376 const interpolation<symmTensor>& interpolator
377 ) const;
378
379 //- Interpolate volume field onto surface points
381 (
382 const interpolation<tensor>& interpolator
383 ) const;
384
385
386 // Output
387
388 //- Print information
389 virtual void print(Ostream& os, int level=0) const;
390};
391
392
393// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394
395} // End namespace Foam
396
397// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398
399#ifdef NoRepository
401#endif
402
403// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
404
405#endif
406
407// ************************************************************************* //
Minimal example by using system/controlDict.functions:
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
static const List< label > & null()
Return a null List.
Definition: ListI.H:109
const vectorField & Sf() const
Face area vectors (normals)
const scalarField & magSf() const
Face area magnitudes.
const vectorField & Cf() const
Face centres.
const List< Face > & surfFaces() const
Return const access to the faces.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
const Field< point_type > & points() const noexcept
Return reference to global points.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base class for volume field interpolation.
Definition: interpolation.H:60
Preferences for controlling iso-surface algorithms.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A sampledSurface defined by a surface of iso value. It only recalculates the iso-surface if time chan...
virtual const pointField & points() const
Points of surface.
TypeName("sampledIsoSurface")
Runtime type information.
virtual void print(Ostream &os, int level=0) const
Print information.
const meshedSurface & surface() const
The currently created surface geometry.
virtual ~sampledIsoSurface()
Destructor.
virtual const faceList & faces() const
Faces of surface.
virtual const vectorField & Cf() const
Face centres.
virtual const labelList & zoneIds() const
Per-face zone/region information.
virtual const scalarField & magSf() const
Face area magnitudes.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool update()
Update the surface as required.
virtual const vectorField & Sf() const
Face area magnitudes.
const labelList & meshCells() const
For each face, the original cell in mesh.
bool hasIsoSurface() const
Is currently backed by an isoSurfacePtr_.
An abstract class for surfaces with sampling.
const word & name() const noexcept
Name of surface.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
bool interpolate() const noexcept
Same as isPointData()
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
bool
Definition: EEqn.H:20
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
Definition: List.H:66
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
MeshedSurface< face > meshedSurface
Field< vector > vectorField
Specialisation of Field<T> for vector.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73