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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::sampledDistanceSurface
28 
29 Description
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 
35 Usage
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 
68 SourceFiles
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 
82 namespace Foam
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class sampledDistanceSurface Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class 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 
127 public:
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;
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  //- 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
226  virtual tmp<sphericalTensorField> sample
227  (
228  const interpolation<sphericalTensor>& sampler
229  ) const;
230 
231  //- Sample volume field onto surface faces
232  virtual tmp<symmTensorField> sample
233  (
234  const interpolation<symmTensor>& sampler
235  ) const;
236 
237  //- Sample volume field onto surface faces
238  virtual tmp<tensorField> sample
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 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::List::null
static const List< T > & null()
Return a null List.
Definition: ListI.H:109
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::sampledDistanceSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledDistanceSurface.C:99
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::sampledDistanceSurface::~sampledDistanceSurface
virtual ~sampledDistanceSurface()=default
Destructor.
Foam::MeshedSurface::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:435
Foam::sampledDistanceSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledDistanceSurface.H:250
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:413
Foam::sampledDistanceSurface::Sf
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledDistanceSurface.H:262
Foam::distanceSurface::distance
scalar distance() const noexcept
The distance to the underlying searchableSurface.
Definition: distanceSurface.H:415
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::sampledDistanceSurface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledDistanceSurface.H:244
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:209
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:441
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::Field< vector >
Foam::sampledDistanceSurface::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledDistanceSurface.C:230
sampledSurface.H
Foam::sampledDistanceSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledDistanceSurface.C:142
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
distanceSurface.H
Foam::sampledDistanceSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledDistanceSurface.C:93
Foam::sampledDistanceSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledDistanceSurface.H:256
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distanceSurface::surface
const meshedSurface & surface() const
The underlying surface.
Definition: distanceSurface.H:421
Foam::sampledDistanceSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledDistanceSurface.H:274
sampledDistanceSurfaceTemplates.C
Foam::sampledDistanceSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledDistanceSurface.C:121
Foam::List< face >
Foam::sampledSurface::mesh
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
Definition: sampledSurface.H:316
Foam::sampledDistanceSurface
A sampledSurface defined by a distance to a surface - resolved using an iso-surface (algorithm: cell,...
Definition: sampledDistanceSurface.H:158
Foam::sampledDistanceSurface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledDistanceSurface.H:268
Foam::sampledDistanceSurface::sampledDistanceSurface
sampledDistanceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledDistanceSurface.C:54
Foam::MeshedSurface::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:447
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::sampledDistanceSurface::TypeName
TypeName("sampledDistanceSurface")
Runtime type information.