sampledDistanceSurface.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-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::sampledDistanceSurface
28
29Description
30 A sampledSurface defined by a distance to a surface - resolved using
31 an iso-surface (algorithm: cell, point, topo)
32
33 This is often embedded as part of a sampled surfaces function object.
34
35Usage
36 Example of function object partial specification:
37 \verbatim
38 surfaces
39 {
40 surface1
41 {
42 type distanceSurface;
43 surfaceType triSurfaceMesh;
44 surfaceName something.obj;
45 topology proximity;
46 }
47 }
48 \endverbatim
49
50 Where the sub-entries comprise:
51 \table
52 Property | Description | Required | Default
53 type | distanceSurface | yes |
54 distance | distance from surface | no | 0
55 signed | Use sign when distance is positive | no | true
56 isoMethod | Iso-algorithm (cell/topo/point) | no | default
57 regularise | Face simplification (enum or bool) | no | true
58 average | Cell values from averaged point values | no | false
59 bounds | Limit with bounding box | no |
60 surfaceType | Type of surface | yes |
61 surfaceName | Name of surface in \c triSurface/ | no | dict name
62 topology | Topology filter name | no | none
63 nearestPoints | Points for point-based segmentation | no |
64 maxDistance | Max search distance for nearestPoints | no | GREAT
65 absProximity | Max proximity of face centres | no | 1e-5
66 \endtable
67
68SourceFiles
69 sampledDistanceSurface.C
70 sampledDistanceSurfaceTemplates.C
71
72\*---------------------------------------------------------------------------*/
73
74#ifndef sampledDistanceSurface_H
75#define sampledDistanceSurface_H
76
77#include "sampledSurface.H"
78#include "distanceSurface.H"
79
80// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81
82namespace Foam
83{
84
85/*---------------------------------------------------------------------------*\
86 Class sampledDistanceSurface Declaration
87\*---------------------------------------------------------------------------*/
88
89class sampledDistanceSurface
90:
91 public sampledSurface,
92 public distanceSurface
93{
94 // Private Data
95
96 //- Whether to recalculate cell values as average of point values
97 bool average_;
98
99 //- Track if the surface needs an update
100 mutable bool needsUpdate_;
101
102
103 // Private Member Functions
104
105 //- Sample volume field onto surface faces
106 template<class Type>
107 tmp<Field<Type>> sampleOnFaces
108 (
109 const interpolation<Type>& sampler
110 ) const;
111
112 //- Interpolate volume field onto surface points
113 template<class Type>
114 tmp<Field<Type>> sampleOnPoints
115 (
116 const interpolation<Type>& interpolation
117 ) const;
118
119 //- Use distance surface isoSurfacePtr_ for point interpolation
120 template<class Type>
121 tmp<Field<Type>> sampleOnIsoSurfacePoints
122 (
123 const interpolation<Type>& interpolator
124 ) const;
125
126
127public:
128
129 //- Runtime type information
130 TypeName("sampledDistanceSurface");
131
132
133 // Constructors
134
135 //- Construct from dictionary
137 (
138 const word& name,
139 const polyMesh& mesh,
140 const dictionary& dict
141 );
142
143
145 (
146 const word name,
147 const polyMesh& mesh,
148 const bool interpolate,
149 autoPtr<searchableSurface>&& surface,
150 const scalar distance,
151 const bool useSignedDistance
152 //const isoSurfaceParams& params = isoSurfaceParams()
153 );
154
155
156 //- Destructor
157 virtual ~sampledDistanceSurface() = default;
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 //- Points of surface
175 virtual const pointField& points() const
176 {
177 return surface().points();
178 }
179
180 //- Faces of surface
181 virtual const faceList& faces() const
182 {
183 return surface().surfFaces();
184 }
185
186 //- Per-face zone/region information
187 virtual const labelList& zoneIds() const
188 {
189 return labelList::null();
190 }
191
192 //- Face area vectors
193 virtual const vectorField& Sf() const
194 {
195 return surface().Sf();
196 }
197
198 //- Face area magnitudes
199 virtual const scalarField& magSf() const
200 {
201 return surface().magSf();
202 }
203
204 //- Face centres
205 virtual const vectorField& Cf() const
206 {
207 return surface().Cf();
208 }
209
210
211 // Sample
212
213 //- Sample volume field onto surface faces
214 virtual tmp<scalarField> sample
215 (
216 const interpolation<scalar>& sampler
217 ) const;
218
219 //- Sample volume field onto surface faces
220 virtual tmp<vectorField> sample
221 (
222 const interpolation<vector>& sampler
223 ) const;
224
225 //- Sample volume field onto surface faces
227 (
228 const interpolation<sphericalTensor>& sampler
229 ) const;
230
231 //- Sample volume field onto surface faces
233 (
234 const interpolation<symmTensor>& sampler
235 ) const;
236
237 //- Sample volume field onto surface faces
239 (
240 const interpolation<tensor>& sampler
241 ) const;
242
243
244 // Interpolate
245
246 //- Interpolate volume field onto surface points
248 (
249 const interpolation<scalar>& interpolator
250 ) const;
251
252 //- Interpolate volume field onto surface points
254 (
255 const interpolation<vector>& interpolator
256 ) const;
257
258 //- Interpolate volume field onto surface points
260 (
261 const interpolation<sphericalTensor>& interpolator
262 ) const;
263
264 //- Interpolate volume field onto surface points
266 (
267 const interpolation<symmTensor>& interpolator
268 ) const;
269
270 //- Interpolate volume field onto surface points
272 (
273 const interpolation<tensor>& interpolator
274 ) const;
275
276
277 // Output
278
279 //- Print information
280 virtual void print(Ostream& os, int level=0) const;
281};
282
283
284// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285
286} // End namespace Foam
287
288// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289
290#ifdef NoRepository
292#endif
293
294// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295
296#endif
297
298// ************************************************************************* //
Minimal example by using system/controlDict.functions:
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.
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
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
scalar distance() const noexcept
The distance to the underlying searchableSurface.
const meshedSurface & surface() const
The underlying surface.
Abstract base class for volume field interpolation.
Definition: interpolation.H:60
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A sampledSurface defined by a distance to a surface - resolved using an iso-surface (algorithm: cell,...
virtual const pointField & points() const
Points of surface.
virtual void print(Ostream &os, int level=0) const
Print information.
sampledDistanceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
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.
TypeName("sampledDistanceSurface")
Runtime type information.
virtual bool expire()
Mark the surface as needing an update.
virtual ~sampledDistanceSurface()=default
Destructor.
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 vectors.
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 class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
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