sampledIsoSurfaceCell.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::sampledIsoSurfaceCell
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 sampledIsoSurfaceCell;
45  cell true;
46  }
47  );
48  \endverbatim
49 
50  Where the sub-entries comprise:
51  \table
52  Property | Description | Required | Default
53  type | sampledIsoSurfaceCell | 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 | yes |
58  average | cell values from averaged point values | no | false
59  bounds | limit with bounding box | no |
60  \endtable
61 
62 Note
63  Does not currently support cell zones.
64 
65 SourceFiles
66  sampledIsoSurfaceCell.C
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef sampledIsoSurfaceCell_H
71 #define sampledIsoSurfaceCell_H
72 
73 #include "sampledSurface.H"
74 #include "MeshedSurface.H"
75 #include "MeshedSurfacesFwd.H"
76 #include "isoSurfaceBase.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class sampledIsoSurfaceCell Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class sampledIsoSurfaceCell
88 :
89  public sampledSurface,
90  public meshedSurface
91 {
92  // Private typedefs for convenience
93  typedef meshedSurface MeshStorage;
94 
95  // Private data
96 
97  //- Field to get isoSurface of
98  const word isoField_;
99 
100  //- Iso value
101  const scalar isoVal_;
102 
103  //- Filtering for iso-surface triangles
104  const isoSurfaceBase::filterType filter_;
105 
106  //- Whether to recalculate cell values as average of point values
107  const bool average_;
108 
109  //- Optional bounding box to trim triangles against
110  const boundBox bounds_;
111 
112 
113  // Recreated for every isoSurface
114 
115  //- Time at last call, also track it surface needs an update
116  mutable label prevTimeIndex_;
117 
118  //- For every triangle the original cell in mesh
119  mutable labelList meshCells_;
120 
121 
122  // Private Member Functions
123 
124  //- Create iso surface (if time has changed)
125  // Do nothing (and return false) if no update was needed
126  bool updateGeometry() const;
127 
128  //- Sample volume field onto surface faces
129  template<class Type>
130  tmp<Field<Type>> sampleOnFaces
131  (
132  const interpolation<Type>& sampler
133  ) const;
134 
135  //- Interpolate volume field onto surface points
136  template<class Type>
137  tmp<Field<Type>> sampleOnPoints
138  (
139  const interpolation<Type>& interpolator
140  ) const;
141 
142 
143 public:
144 
145  //- Runtime type information
146  TypeName("sampledIsoSurfaceCell");
147 
148 
149  // Constructors
150 
151  //- Construct from dictionary
153  (
154  const word& name,
155  const polyMesh& mesh,
156  const dictionary& dict
157  );
158 
159 
160  //- Destructor
161  virtual ~sampledIsoSurfaceCell();
162 
163 
164  // Member Functions
165 
166  //- Does the surface need an update?
167  virtual bool needsUpdate() const;
168 
169  //- Mark the surface as needing an update.
170  // May also free up unneeded data.
171  // Return false if surface was already marked as expired.
172  virtual bool expire();
173 
174  //- Update the surface as required.
175  // Do nothing (and return false) if no update was needed
176  virtual bool update();
177 
178 
179  //- Points of surface
180  virtual const pointField& points() const
181  {
182  return MeshStorage::points();
183  }
184 
185  //- Faces of surface
186  virtual const faceList& faces() const
187  {
188  return MeshStorage::surfFaces();
189  }
190 
191  //- Per-face zone/region information
192  virtual const labelList& zoneIds() const
193  {
194  return labelList::null();
195  }
196 
197  //- Face area magnitudes
198  virtual const vectorField& Sf() const
199  {
200  return MeshStorage::Sf();
201  }
202 
203  //- Face area magnitudes
204  virtual const scalarField& magSf() const
205  {
206  return MeshStorage::magSf();
207  }
208 
209  //- Face centres
210  virtual const vectorField& Cf() const
211  {
212  return MeshStorage::Cf();
213  }
214 
215 
216  // Sample
217 
218  //- Sample volume field onto surface faces
220  (
221  const interpolation<scalar>& sampler
222  ) const;
223 
224  //- Sample volume field onto surface faces
226  (
227  const interpolation<vector>& sampler
228  ) const;
229 
230  //- Sample volume field onto surface faces
232  (
233  const interpolation<sphericalTensor>& sampler
234  ) const;
235 
236  //- Sample volume field onto surface faces
238  (
239  const interpolation<symmTensor>& sampler
240  ) const;
241 
242  //- Sample volume field onto surface faces
244  (
245  const interpolation<tensor>& sampler
246  ) const;
247 
248 
249  // Interpolate
250 
251  //- Interpolate volume field onto surface points
253  (
254  const interpolation<scalar>& interpolator
255  ) const;
256 
257  //- Interpolate volume field onto surface points
259  (
260  const interpolation<vector>& interpolator
261  ) const;
262 
263  //- Interpolate volume field onto surface points
265  (
266  const interpolation<sphericalTensor>& interpolator
267  ) const;
268 
269  //- Interpolate volume field onto surface points
271  (
272  const interpolation<symmTensor>& interpolator
273  ) const;
274 
275  //- Interpolate volume field onto surface points
277  (
278  const interpolation<tensor>& interpolator
279  ) const;
280 
281  //- Write
282  virtual void print(Ostream&) const;
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #ifdef NoRepository
294 #endif
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #endif
299 
300 // ************************************************************************* //
Foam::sampledIsoSurfaceCell::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledIsoSurfaceCell.C:235
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
sampledIsoSurfaceCellTemplates.C
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::sampledIsoSurfaceCell::print
virtual void print(Ostream &) const
Write.
Definition: sampledIsoSurfaceCell.C:357
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::sampledIsoSurfaceCell::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledIsoSurfaceCell.H:225
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::sampledIsoSurfaceCell::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledIsoSurfaceCell.H:231
Foam::sampledIsoSurfaceCell::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledIsoSurfaceCell.C:227
Foam::sampledIsoSurfaceCell::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledIsoSurfaceCell.C:260
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:376
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:362
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
isoSurfaceBase.H
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::MeshedSurface< face >::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::sampledIsoSurfaceCell::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledIsoSurfaceCell.H:249
Foam::Field< vector >
sampledSurface.H
Foam::sampledIsoSurfaceCell::points
virtual const pointField & points() const
Points of surface.
Definition: sampledIsoSurfaceCell.H:219
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
Foam::sampledIsoSurfaceCell::update
virtual bool update()
Update the surface as required.
Definition: sampledIsoSurfaceCell.C:252
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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::List< label >
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:308
Foam::sampledIsoSurfaceCell::~sampledIsoSurfaceCell
virtual ~sampledIsoSurfaceCell()
Destructor.
Definition: sampledIsoSurfaceCell.C:221
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::sampledIsoSurfaceCell::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledIsoSurfaceCell.H:243
Foam::MeshedSurface< face >::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::sampledIsoSurfaceCell::TypeName
TypeName("sampledIsoSurfaceCell")
Runtime type information.
Foam::sampledIsoSurfaceCell::Sf
virtual const vectorField & Sf() const
Face area magnitudes.
Definition: sampledIsoSurfaceCell.H:237
MeshedSurfacesFwd.H
Foam::MeshedSurface< face >
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:326
Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
sampledIsoSurfaceCell(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledIsoSurfaceCell.C:194
Foam::sampledIsoSurfaceCell
A sampledSurface defined by a surface of iso value. Always triangulated. To be used in sampleSurfaces...
Definition: sampledIsoSurfaceCell.H:126
Foam::isoSurfaceBase::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceBase.H:87
MeshedSurface.H