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-2019 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 - using either
31  an isoSurfaceCell or an isoSurface.
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  }
44  );
45  \endverbatim
46 
47  Where the sub-entries comprise:
48  \table
49  Property | Description | Required | Default
50  type | distanceSurface | yes |
51  distance | Distance from surface | yes |
52  signed | Use sign when distance is positive | partly |
53  isoAlgorithm | (cell/topo/point) | no | cell
54  regularise | Point snapping for iso-surface | no | true
55  average | Cell values from averaged point values | no | false
56  bounds | Limit with bounding box | no |
57  surfaceType | Type of surface | yes |
58  surfaceName | Name of surface in \c triSurface/ | no | dict name
59  \endtable
60 
61 Note
62  For compatibility, the keyword 'cell' (as a bool) is accepted
63 
64 SourceFiles
65  sampledDistanceSurface.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef sampledDistanceSurface_H
70 #define sampledDistanceSurface_H
71 
72 #include "sampledSurface.H"
73 #include "distanceSurface.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class sampledDistanceSurface Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class sampledDistanceSurface
85 :
86  public sampledSurface,
87  public distanceSurface
88 {
89  // Private data
90 
91  //- Whether to recalculate cell values as average of point values
92  const bool average_;
93 
94  //- Track if the surface needs an update
95  mutable bool needsUpdate_;
96 
97 
98  // Private Member Functions
99 
100  //- Sample volume field onto surface faces
101  template<class Type>
102  tmp<Field<Type>> sampleOnFaces
103  (
104  const interpolation<Type>& sampler
105  ) const;
106 
107  //- Interpolate volume field onto surface points
108  template<class Type>
109  tmp<Field<Type>> sampleOnPoints
110  (
111  const interpolation<Type>& interpolation
112  ) const;
113 
114 
115 public:
116 
117  //- Runtime type information
118  TypeName("sampledDistanceSurface");
119 
120 
121  // Constructors
122 
123  //- Construct from dictionary
125  (
126  const word& name,
127  const polyMesh& mesh,
128  const dictionary& dict
129  );
130 
131 
132  //- Destructor
133  virtual ~sampledDistanceSurface() = default;
134 
135 
136  // Member Functions
137 
138  //- Does the surface need an update?
139  virtual bool needsUpdate() const;
140 
141  //- Mark the surface as needing an update.
142  // May also free up unneeded data.
143  // Return false if surface was already marked as expired.
144  virtual bool expire();
145 
146  //- Update the surface as required.
147  // Do nothing (and return false) if no update was needed
148  virtual bool update();
149 
150  //- Points of surface
151  virtual const pointField& points() const
152  {
153  return surface().points();
154  }
155 
156  //- Faces of surface
157  virtual const faceList& faces() const
158  {
159  return surface().surfFaces();
160  }
161 
162  //- Per-face zone/region information
163  virtual const labelList& zoneIds() const
164  {
165  return labelList::null();
166  }
167 
168  //- Face area vectors
169  virtual const vectorField& Sf() const
170  {
171  return surface().Sf();
172  }
173 
174  //- Face area magnitudes
175  virtual const scalarField& magSf() const
176  {
177  return surface().magSf();
178  }
179 
180  //- Face centres
181  virtual const vectorField& Cf() const
182  {
183  return surface().Cf();
184  }
185 
186 
187  // Sample
188 
189  //- Sample volume field onto surface faces
190  virtual tmp<scalarField> sample
191  (
192  const interpolation<scalar>& sampler
193  ) const;
194 
195  //- Sample volume field onto surface faces
196  virtual tmp<vectorField> sample
197  (
198  const interpolation<vector>& sampler
199  ) const;
200 
201  //- Sample volume field onto surface faces
203  (
204  const interpolation<sphericalTensor>& sampler
205  ) const;
206 
207  //- Sample volume field onto surface faces
209  (
210  const interpolation<symmTensor>& sampler
211  ) const;
212 
213  //- Sample volume field onto surface faces
214  virtual tmp<tensorField> sample
215  (
216  const interpolation<tensor>& sampler
217  ) const;
218 
219 
220  // Interpolate
221 
222  //- Interpolate volume field onto surface points
224  (
225  const interpolation<scalar>& interpolator
226  ) const;
227 
228  //- Interpolate volume field onto surface points
230  (
231  const interpolation<vector>& interpolator
232  ) const;
233 
234  //- Interpolate volume field onto surface points
236  (
237  const interpolation<sphericalTensor>& interpolator
238  ) const;
239 
240  //- Interpolate volume field onto surface points
242  (
243  const interpolation<symmTensor>& interpolator
244  ) const;
245 
246  //- Interpolate volume field onto surface points
248  (
249  const interpolation<tensor>& interpolator
250  ) const;
251 
252 
253  // Output
254 
255  //- Print information
256  virtual void print(Ostream& os) const;
257 };
258 
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #ifdef NoRepository
268 #endif
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 #endif
273 
274 // ************************************************************************* //
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:59
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:206
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:218
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:200
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:121
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: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
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:212
Foam::distanceSurface::surface
const meshedSurface & surface() const
The underlying surface.
Definition: distanceSurface.H:215
Foam::sampledDistanceSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledDistanceSurface.H:230
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:308
Foam::sampledDistanceSurface
A sampledSurface defined by a distance to a surface - using either an isoSurfaceCell or an isoSurface...
Definition: sampledDistanceSurface.H:133
Foam::sampledDistanceSurface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledDistanceSurface.H:224
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:302
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:326
Foam::sampledDistanceSurface::TypeName
TypeName("sampledDistanceSurface")
Runtime type information.