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-2020 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 (none/largestRegion/nearestPoints/proximity) | no | none
63  nearestPoints | Points for point-based segmentation | no |
64  maxDistance | Max search distance for nearestPoints | no | GREAT
65  relProximity | Max limit of absolute vs normal distance | no | 1e3
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 
144  //- Destructor
145  virtual ~sampledDistanceSurface() = default;
146 
147 
148  // Member Functions
149 
150  //- Does the surface need an update?
151  virtual bool needsUpdate() const;
152 
153  //- Mark the surface as needing an update.
154  // May also free up unneeded data.
155  // Return false if surface was already marked as expired.
156  virtual bool expire();
157 
158  //- Update the surface as required.
159  // Do nothing (and return false) if no update was needed
160  virtual bool update();
161 
162  //- Points of surface
163  virtual const pointField& points() const
164  {
165  return surface().points();
166  }
167 
168  //- Faces of surface
169  virtual const faceList& faces() const
170  {
171  return surface().surfFaces();
172  }
173 
174  //- Per-face zone/region information
175  virtual const labelList& zoneIds() const
176  {
177  return labelList::null();
178  }
179 
180  //- Face area vectors
181  virtual const vectorField& Sf() const
182  {
183  return surface().Sf();
184  }
185 
186  //- Face area magnitudes
187  virtual const scalarField& magSf() const
188  {
189  return surface().magSf();
190  }
191 
192  //- Face centres
193  virtual const vectorField& Cf() const
194  {
195  return surface().Cf();
196  }
197 
198 
199  // Sample
200 
201  //- Sample volume field onto surface faces
202  virtual tmp<scalarField> sample
203  (
204  const interpolation<scalar>& sampler
205  ) const;
206 
207  //- Sample volume field onto surface faces
208  virtual tmp<vectorField> sample
209  (
210  const interpolation<vector>& sampler
211  ) const;
212 
213  //- Sample volume field onto surface faces
214  virtual tmp<sphericalTensorField> sample
215  (
216  const interpolation<sphericalTensor>& sampler
217  ) const;
218 
219  //- Sample volume field onto surface faces
220  virtual tmp<symmTensorField> sample
221  (
222  const interpolation<symmTensor>& sampler
223  ) const;
224 
225  //- Sample volume field onto surface faces
226  virtual tmp<tensorField> sample
227  (
228  const interpolation<tensor>& sampler
229  ) const;
230 
231 
232  // Interpolate
233 
234  //- Interpolate volume field onto surface points
236  (
237  const interpolation<scalar>& interpolator
238  ) const;
239 
240  //- Interpolate volume field onto surface points
242  (
243  const interpolation<vector>& interpolator
244  ) const;
245 
246  //- Interpolate volume field onto surface points
248  (
249  const interpolation<sphericalTensor>& interpolator
250  ) const;
251 
252  //- Interpolate volume field onto surface points
254  (
255  const interpolation<symmTensor>& interpolator
256  ) const;
257 
258  //- Interpolate volume field onto surface points
260  (
261  const interpolation<tensor>& interpolator
262  ) const;
263 
264 
265  // Output
266 
267  //- Print information
268  virtual void print(Ostream& os) const;
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace Foam
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #ifdef NoRepository
280 #endif
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #endif
285 
286 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
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::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::sampledDistanceSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledDistanceSurface.C:75
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:433
Foam::sampledDistanceSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledDistanceSurface.H:238
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:411
Foam::sampledDistanceSurface::print
virtual void print(Ostream &os) const
Print information.
Definition: sampledDistanceSurface.C:206
Foam::sampledDistanceSurface::Sf
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledDistanceSurface.H:250
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:232
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:198
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:439
Foam::Field< vector >
sampledSurface.H
Foam::sampledDistanceSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledDistanceSurface.C:118
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
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:121
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:69
Foam::sampledDistanceSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledDistanceSurface.H:244
Foam::distanceSurface::surface
const meshedSurface & surface() const
The underlying surface.
Definition: distanceSurface.H:395
Foam::sampledDistanceSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledDistanceSurface.H:262
sampledDistanceSurfaceTemplates.C
Foam::sampledDistanceSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledDistanceSurface.C:97
Foam::List< face >
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:321
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:256
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:445
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:315
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:339
Foam::sampledDistanceSurface::TypeName
TypeName("sampledDistanceSurface")
Runtime type information.