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