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-2019 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. Always triangulated.
32  To be used in sampleSurfaces / functionObjects. Recalculates iso surface
33  only if time changes.
34 
35  This is often embedded as part of a sampled surfaces function object.
36 
37 Usage
38  Example of function object partial specification:
39  \verbatim
40  surfaces
41  (
42  surface1
43  {
44  type sampledIsoSurface;
45  cell false;
46  }
47  );
48  \endverbatim
49 
50  Where the sub-entries comprise:
51  \table
52  Property | Description | Required | Default
53  type | sampledIsoSurface | yes |
54  isoField | field name for obtaining iso-surface | yes |
55  isoValue | value of iso-surface | yes |
56  mergeTol | tolerance for merging points | no | 1e-6
57  regularise | point snapping (bool or enum) | no | true
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  exposedPatchName | name for zone subset | partly |
63  \endtable
64 
65 SourceFiles
66  sampledIsoSurface.C
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef sampledIsoSurface_H
71 #define sampledIsoSurface_H
72 
73 #include "isoSurface.H"
74 #include "sampledSurface.H"
75 #include "fvMeshSubset.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class sampledIsoSurface Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class sampledIsoSurface
87 :
88  public sampledSurface
89 {
90  // Private data
91 
92  //- Field to get isoSurface of
93  const word isoField_;
94 
95  //- Iso value
96  const scalar isoVal_;
97 
98  //- Merge tolerance
99  const scalar mergeTol_;
100 
101  //- Filtering for iso-surface triangles
102  const isoSurfaceBase::filterType filter_;
103 
104  //- Whether to recalculate cell values as average of point values
105  const bool average_;
106 
107  //- Optional bounding box to trim triangles against
108  const boundBox bounds_;
109 
110  //- The zone or zones for the iso-surface
111  wordRes zoneNames_;
112 
113  //- For zones: patch to put exposed faces into
114  mutable word exposedPatchName_;
115 
116  mutable autoPtr<isoSurface> surfPtr_;
117 
118 
119  // Recreated for every isoSurface
120 
121  //- Time at last call, also track if surface needs an update
122  mutable label prevTimeIndex_;
123 
124  //- Cached volfield
125  mutable autoPtr<volScalarField> storedVolFieldPtr_;
126  mutable const volScalarField* volFieldPtr_;
127 
128  //- Cached pointfield
129  mutable const pointScalarField* pointFieldPtr_;
130 
131  // And on subsetted mesh
132 
133  //- Cached submesh
134  mutable autoPtr<fvMeshSubset> subMeshPtr_;
135 
136  //- Cached volfield
137  mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
138  mutable const volScalarField* volSubFieldPtr_;
139 
140  //- Cached pointfield
141  mutable const pointScalarField* pointSubFieldPtr_;
142 
143 
144  // Private Member Functions
145 
146  //- Get fields needed to recreate iso surface.
147  void getIsoFields() const;
148 
149  //- Create iso surface (if time has changed)
150  // Do nothing (and return false) if no update was needed
151  bool updateGeometry() const;
152 
153  //- Sample volume field onto surface faces
154  template<class Type>
155  tmp<Field<Type>> sampleOnFaces
156  (
157  const interpolation<Type>& sampler
158  ) const;
159 
160  //- Interpolate volume field onto surface points
161  template<class Type>
162  tmp<Field<Type>> sampleOnPoints
163  (
164  const interpolation<Type>& interpolator
165  ) const;
166 
167 
168 public:
169 
170  //- Runtime type information
171  TypeName("sampledIsoSurface");
172 
173 
174  // Constructors
175 
176  //- Construct from dictionary
178  (
179  const word& name,
180  const polyMesh& mesh,
181  const dictionary& dict
182  );
183 
184 
185  //- Destructor
186  virtual ~sampledIsoSurface();
187 
188 
189  // Member Functions
190 
191  const isoSurface& surface() const
192  {
193  return *surfPtr_;
194  }
195 
196  //- Does the surface need an update?
197  virtual bool needsUpdate() const;
198 
199  //- Mark the surface as needing an update.
200  // May also free up unneeded data.
201  // Return false if surface was already marked as expired.
202  virtual bool expire();
203 
204  //- Update the surface as required.
205  // Do nothing (and return false) if no update was needed
206  virtual bool update();
207 
208 
209  //- Points of surface
210  virtual const pointField& points() const
211  {
212  return surface().points();
213  }
214 
215  //- Faces of surface
216  virtual const faceList& faces() const
217  {
218  return surface().surfFaces();
219  }
220 
221  //- Per-face zone/region information
222  virtual const labelList& zoneIds() const
223  {
224  return labelList::null();
225  }
226 
227  //- Face area magnitudes
228  virtual const vectorField& Sf() const
229  {
230  return surface().Sf();
231  }
232 
233  //- Face area magnitudes
234  virtual const scalarField& magSf() const
235  {
236  return surface().magSf();
237  }
238 
239  //- Face centres
240  virtual const vectorField& Cf() const
241  {
242  return surface().Cf();
243  }
244 
245 
246  //- Lookup or read isoField.
247  // Sets volFieldPtr_ and pointFieldPtr_.
248  void getIsoField();
249 
250 
251  // Sample
252 
253  //- Sample volume field onto surface faces
254  virtual tmp<scalarField> sample
255  (
256  const interpolation<scalar>& sampler
257  ) const;
258 
259  //- Sample volume field onto surface faces
260  virtual tmp<vectorField> sample
261  (
262  const interpolation<vector>& sampler
263  ) const;
264 
265  //- Sample volume field onto surface faces
267  (
268  const interpolation<sphericalTensor>& sampler
269  ) const;
270 
271  //- Sample volume field onto surface faces
273  (
274  const interpolation<symmTensor>& sampler
275  ) const;
276 
277  //- Sample volume field onto surface faces
278  virtual tmp<tensorField> sample
279  (
280  const interpolation<tensor>& sampler
281  ) const;
282 
283 
284  // Interpolate
285 
286  //- Interpolate volume field onto surface points
288  (
289  const interpolation<scalar>& interpolator
290  ) const;
291 
292  //- Interpolate volume field onto surface points
294  (
295  const interpolation<vector>& interpolator
296  ) const;
297 
298  //- Interpolate volume field onto surface points
300  (
301  const interpolation<sphericalTensor>& interpolator
302  ) const;
303 
304  //- Interpolate volume field onto surface points
306  (
307  const interpolation<symmTensor>& interpolator
308  ) const;
309 
310  //- Interpolate volume field onto surface points
312  (
313  const interpolation<tensor>& interpolator
314  ) const;
315 
316 
317  // Output
318 
319  //- Write
320  virtual void print(Ostream&) const;
321 };
322 
323 
324 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 
326 } // End namespace Foam
327 
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 
330 #ifdef NoRepository
332 #endif
333 
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
335 
336 #endif
337 
338 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
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:488
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
fvMeshSubset.H
Foam::sampledIsoSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledIsoSurface.H:294
Foam::MeshedSurface::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:376
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:362
Foam::sampledIsoSurface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledIsoSurface.H:264
Foam::sampledIsoSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledIsoSurface.C:516
Foam::sampledIsoSurface::print
virtual void print(Ostream &) const
Write.
Definition: sampledIsoSurface.C:611
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::sampledIsoSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledIsoSurface.H:276
Foam::isoSurface
A surface formed by the iso value. After "Regularised Marching Tetrahedra: improved iso-surface extra...
Definition: isoSurface.H:89
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:382
Foam::label
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:62
Foam::Field< vector >
Foam::sampledIsoSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledIsoSurface.C:523
sampledSurface.H
Foam::sampledIsoSurface
A sampledSurface defined by a surface of iso value. Always triangulated. To be used in sampleSurfaces...
Definition: sampledIsoSurface.H:140
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
Foam::sampledIsoSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledIsoSurface.C:496
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::sampledIsoSurface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledIsoSurface.H:288
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pointScalarField
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
Definition: pointFields.H:51
isoSurface.H
Foam::sampledIsoSurface::getIsoField
void getIsoField()
Lookup or read isoField.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
Foam::sampledIsoSurface::surface
const isoSurface & surface() const
Definition: sampledIsoSurface.H:245
Foam::List< face >
Foam::sampledIsoSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledIsoSurface.H:270
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:308
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::MeshedSurface::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:388
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:302
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::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:326
Foam::sampledIsoSurface::~sampledIsoSurface
virtual ~sampledIsoSurface()
Destructor.
Definition: sampledIsoSurface.C:482
Foam::sampledIsoSurface::sampledIsoSurface
sampledIsoSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledIsoSurface.C:417
Foam::isoSurfaceBase::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceBase.H:87
Foam::sampledIsoSurface::Sf
virtual const vectorField & Sf() const
Face area magnitudes.
Definition: sampledIsoSurface.H:282
Foam::sampledIsoSurface::TypeName
TypeName("sampledIsoSurface")
Runtime type information.