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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::sampledIsoSurface
29 
30 Description
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 
35 Usage
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 
73 SourceFiles
74  sampledIsoSurface.C
75  sampledIsoSurfaceTemplates.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef sampledIsoSurface_H
80 #define sampledIsoSurface_H
81 
82 #include "sampledSurface.H"
83 #include "fvMeshSubset.H"
84 #include "isoSurfaceBase.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class sampledIsoSurface Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class sampledIsoSurface
96 :
97  public sampledSurface
98 {
99  // Private Data
100 
101  //- Field to get isoSurface of
102  const word isoField_;
103 
104  //- The iso-value(s)
105  List<scalar> isoValues_;
106 
107  //- Parameters (filtering etc) for iso-surface
108  isoSurfaceParams isoParams_;
109 
110  //- Whether to recalculate cell values as average of point values
111  bool average_;
112 
113  //- Whether to triangulate ALGO_TOPO (after filtering)
114  bool triangulate_;
115 
116  //- Use simple sub-meshing in algorithm itself
117  bool simpleSubMesh_;
118 
119  //- The zone or zones for the iso-surface
120  wordRes zoneNames_;
121 
122  //- For zones: patch to put exposed faces into
123  mutable word exposedPatchName_;
124 
125 
126  // Sampling geometry. Directly stored or via an iso-surface (ALGO_POINT)
127 
128  //- Time at last call, also track if surface needs an update
129  mutable label prevTimeIndex_;
130 
131  //- The extracted surface (direct storage)
132  mutable meshedSurface surface_;
133 
134  //- For every face the original cell in mesh (direct storage)
135  mutable labelList meshCells_;
136 
137  //- Extracted iso-surface, for interpolators
138  mutable autoPtr<isoSurfaceBase> isoSurfacePtr_;
139 
140 
141  // Mesh Subsetting
142 
143  //- Cached subMesh for (pre-)subset of cell zones
144  mutable autoPtr<fvMeshSubset> subMeshPtr_;
145 
146  //- Cached ignore cells for (post-)subset of cell zones
147  mutable autoPtr<bitSet> ignoreCellsPtr_;
148 
149 
150  // Fields
151 
152  //- Cached volfield
153  mutable autoPtr<volScalarField> storedVolFieldPtr_;
154  mutable const volScalarField* volFieldPtr_;
155 
156  //- Cached pointfield
157  mutable const pointScalarField* pointFieldPtr_;
158 
159 
160  // And on (pre-)subsetted mesh
161 
162  //- Cached volfield
163  mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
164  mutable const volScalarField* volSubFieldPtr_;
165 
166  //- Cached pointfield
167  mutable const pointScalarField* pointSubFieldPtr_;
168 
169 
170  // Private Member Functions
171 
172  //- Get fields needed to recreate iso surface.
173  void getIsoFields() const;
174 
175  //- Collect iso-surfaces into a single surface (No point merging)
176  void combineSurfaces(PtrList<isoSurfaceBase>& isoSurfPtrs);
177 
178  //- Create iso surface (if time has changed)
179  // Do nothing (and return false) if no update was needed
180  bool updateGeometry() const;
181 
182  //- Sample volume field onto surface faces
183  template<class Type>
184  tmp<Field<Type>> sampleOnFaces
185  (
186  const interpolation<Type>& sampler
187  ) const;
188 
189  //- Interpolate volume field onto surface points
190  template<class Type>
191  tmp<Field<Type>> sampleOnPoints
192  (
193  const interpolation<Type>& interpolator
194  ) const;
195 
196  //- Use isoSurfacePtr_ for point interpolation
197  template<class Type>
198  tmp<Field<Type>> sampleOnIsoSurfacePoints
199  (
200  const interpolation<Type>& interpolator
201  ) const;
202 
203 
204 protected:
205 
206  // Protected Member Functions
207 
208  //- Is currently backed by an isoSurfacePtr_
209  bool hasIsoSurface() const
210  {
211  return bool(isoSurfacePtr_);
212  }
213 
214 
215 public:
216 
217  //- Runtime type information
218  TypeName("samplediIsoSurfacePoint");
219 
220 
221  // Constructors
222 
223  //- Construct from dictionary
225  (
226  const isoSurfaceParams& params,
227  const word& name,
228  const polyMesh& mesh,
229  const dictionary& dict
230  );
231 
232  //- Construct from dictionary
234  (
235  const word& name,
236  const polyMesh& mesh,
237  const dictionary& dict
238  );
239 
240 
241  //- Destructor
242  virtual ~sampledIsoSurface();
243 
244 
245  // Member Functions
246 
247  //- Does the surface need an update?
248  virtual bool needsUpdate() const;
249 
250  //- Mark the surface as needing an update.
251  // May also free up unneeded data.
252  // Return false if surface was already marked as expired.
253  virtual bool expire();
254 
255  //- Update the surface as required.
256  // Do nothing (and return false) if no update was needed
257  virtual bool update();
258 
259  //- The currently created surface geometry
260  const meshedSurface& surface() const
261  {
262  if (isoSurfacePtr_)
263  {
264  return *isoSurfacePtr_;
265  }
266  return surface_;
267  }
268 
269  //- For each face, the original cell in mesh
270  const labelList& meshCells() const
271  {
272  if (isoSurfacePtr_)
273  {
274  return isoSurfacePtr_->meshCells();
275  }
276  return meshCells_;
277  }
278 
279  //- Points of surface
280  virtual const pointField& points() const
281  {
282  return surface().points();
283  }
284 
285  //- Faces of surface
286  virtual const faceList& faces() const
287  {
288  return surface().surfFaces();
289  }
290 
291  //- Per-face zone/region information
292  virtual const labelList& zoneIds() const
293  {
294  return labelList::null();
295  }
296 
297  //- Face area magnitudes
298  virtual const vectorField& Sf() const
299  {
300  return surface().Sf();
301  }
302 
303  //- Face area magnitudes
304  virtual const scalarField& magSf() const
305  {
306  return surface().magSf();
307  }
308 
309  //- Face centres
310  virtual const vectorField& Cf() const
311  {
312  return surface().Cf();
313  }
314 
315 
316  // Sample
317 
318  //- Sample volume field onto surface faces
319  virtual tmp<scalarField> sample
320  (
321  const interpolation<scalar>& sampler
322  ) const;
323 
324  //- Sample volume field onto surface faces
325  virtual tmp<vectorField> sample
326  (
327  const interpolation<vector>& sampler
328  ) const;
329 
330  //- Sample volume field onto surface faces
331  virtual tmp<sphericalTensorField> sample
332  (
333  const interpolation<sphericalTensor>& sampler
334  ) const;
335 
336  //- Sample volume field onto surface faces
338  (
339  const interpolation<symmTensor>& sampler
340  ) const;
341 
342  //- Sample volume field onto surface faces
343  virtual tmp<tensorField> sample
344  (
345  const interpolation<tensor>& sampler
346  ) const;
347 
348 
349  // Interpolate
350 
351  //- Interpolate volume field onto surface points
353  (
354  const interpolation<scalar>& interpolator
355  ) const;
356 
357  //- Interpolate volume field onto surface points
359  (
360  const interpolation<vector>& interpolator
361  ) const;
362 
363  //- Interpolate volume field onto surface points
365  (
366  const interpolation<sphericalTensor>& interpolator
367  ) const;
368 
369  //- Interpolate volume field onto surface points
371  (
372  const interpolation<symmTensor>& interpolator
373  ) const;
374 
375  //- Interpolate volume field onto surface points
377  (
378  const interpolation<tensor>& interpolator
379  ) const;
380 
381 
382  // Output
383 
384  //- Write
385  virtual void print(Ostream& os) const;
386 };
387 
388 
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390 
391 } // End namespace Foam
392 
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 
395 #ifdef NoRepository
397 #endif
398 
399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 
401 #endif
402 
403 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
sampledIsoSurfaceTemplates.C
Foam::List< label >::null
static const List< label > & null()
Return a null List.
Definition: ListI.H:108
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::sampledIsoSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledIsoSurface.C:726
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
fvMeshSubset.H
Foam::sampledIsoSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledIsoSurface.H:384
Foam::MeshedSurface::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:433
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:411
Foam::sampledIsoSurface::TypeName
TypeName("samplediIsoSurfacePoint")
Runtime type information.
Foam::sampledIsoSurface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledIsoSurface.H:354
Foam::sampledIsoSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledIsoSurface.C:756
Foam::sampledIsoSurface::hasIsoSurface
bool hasIsoSurface() const
Is currently backed by an isoSurfacePtr_.
Definition: sampledIsoSurface.H:283
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sampledIsoSurface::meshCells
const labelList & meshCells() const
For each face, the original cell in mesh.
Definition: sampledIsoSurface.H:344
isoSurfaceBase.H
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::sampledIsoSurface::surface
const meshedSurface & surface() const
The currently created surface geometry.
Definition: sampledIsoSurface.H:334
Foam::sampledIsoSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledIsoSurface.H:366
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:439
Foam::Field< vector >
Foam::sampledIsoSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledIsoSurface.C:764
Foam::sampledIsoSurface::sampledIsoSurface
sampledIsoSurface(const isoSurfaceParams &params, const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledIsoSurface.C:583
sampledSurface.H
Foam::sampledIsoSurface
A sampledSurface defined by a surface of iso value. It only recalculates the iso-surface if time chan...
Definition: sampledIsoSurface.H:169
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::sampledIsoSurface::print
virtual void print(Ostream &os) const
Write.
Definition: sampledIsoSurface.C:861
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
Foam::sampledIsoSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledIsoSurface.C:734
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::isoSurfaceParams
Preferences for controlling iso-surface algorithms.
Definition: isoSurfaceParams.H:91
Foam::sampledIsoSurface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledIsoSurface.H:378
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::List< scalar >
Foam::sampledIsoSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledIsoSurface.H:360
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:321
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
bool
bool
Definition: EEqn.H:20
Foam::MeshedSurface::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:445
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:315
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::MeshedSurface< face >
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:339
Foam::sampledIsoSurface::~sampledIsoSurface
virtual ~sampledIsoSurface()
Destructor.
Definition: sampledIsoSurface.C:720
Foam::sampledIsoSurface::Sf
virtual const vectorField & Sf() const
Face area magnitudes.
Definition: sampledIsoSurface.H:372
Foam::pointScalarField
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
Definition: pointFieldsFwd.H:56