distanceSurface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sampledSurfaces::distanceSurface
26 
27 Description
28  A sampledSurface defined by a distance to a surface.
29 
30 SourceFiles
31  distanceSurface.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sampledSurfaces_distanceSurface_H
36 #define sampledSurfaces_distanceSurface_H
37 
38 #include "sampledSurface.H"
39 #include "searchableSurface.H"
40 #include "isoSurface.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace sampledSurfaces
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class distanceSurface Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class distanceSurface
54 :
55  public sampledSurface
56 {
57  // Private Data
58 
59  //- Surface
60  const autoPtr<searchableSurface> surfPtr_;
61 
62  //- Distance value
63  const scalar distance_;
64 
65  //- Signed distance
66  const bool signed_;
67 
68  //- Whether to coarsen
69  const Switch regularise_;
70 
71  //- Whether to recalculate cell values as average of point values
72  const Switch average_;
73 
74  //- If restricted to zones, name of this zone or a regular expression
75  keyType zoneKey_;
76 
77  //- Track if the surface needs an update
78  mutable bool needsUpdate_;
79 
80 
81  //- Distance to cell centres
82  autoPtr<volScalarField> cellDistancePtr_;
83 
84  //- Distance to points
85  scalarField pointDistance_;
86 
87  //- Constructed iso surface
88  autoPtr<isoSurface> isoSurfPtr_;
89 
90 
91  // Private Member Functions
92 
93  //- Create iso surface
94  void createGeometry();
95 
96  //- Sample field on faces
97  template<class Type>
98  tmp<Field<Type>> sampleField
99  (
101  ) const;
102 
103 
104  template<class Type>
106  interpolateField(const interpolation<Type>&) const;
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("distanceSurface");
113 
114 
115  // Constructors
116 
117  //- Construct from dictionary
119  (
120  const word& name,
121  const polyMesh& mesh,
122  const dictionary& dict
123  );
124 
125  //- Construct from components
127  (
128  const word& name,
129  const polyMesh& mesh,
130  const bool interpolate,
131  const word& surfaceType,
132  const word& surfaceName,
133  const scalar distance,
134  const bool signedDistance,
135  const Switch regularise,
136  const Switch average
137  );
138 
139 
140  //- Destructor
141  virtual ~distanceSurface();
142 
143 
144  // Member Functions
145 
146  //- Does the surface need an update?
147  virtual bool needsUpdate() const;
148 
149  //- Mark the surface as needing an update.
150  // May also free up unneeded data.
151  // Return false if surface was already marked as expired.
152  virtual bool expire();
153 
154  //- Update the surface as required.
155  // Do nothing (and return false) if no update was needed
156  virtual bool update();
157 
158  //- Points of surface
159  virtual const pointField& points() const
160  {
161  return surface().points();
162  }
163 
164  //- Faces of surface
165  virtual const faceList& faces() const
166  {
167  return surface().faces();
168  }
170  const isoSurface& surface() const
171  {
172  return isoSurfPtr_();
173  }
174 
175  //- Sample field on surface
176  virtual tmp<scalarField> sample
177  (
178  const volScalarField&
179  ) const;
180 
181  //- Sample field on surface
182  virtual tmp<vectorField> sample
183  (
184  const volVectorField&
185  ) const;
186 
187  //- Sample field on surface
189  (
191  ) const;
192 
193  //- Sample field on surface
195  (
196  const volSymmTensorField&
197  ) const;
198 
199  //- Sample field on surface
200  virtual tmp<tensorField> sample
201  (
202  const volTensorField&
203  ) const;
204 
205 
206  //- Interpolate field on surface
208  (
209  const interpolation<scalar>&
210  ) const;
211 
212  //- Interpolate field on surface
214  (
215  const interpolation<vector>&
216  ) const;
217 
218  //- Interpolate field on surface
220  (
222  ) const;
223 
224  //- Interpolate field on surface
226  (
228  ) const;
229 
230  //- Interpolate field on surface
232  (
233  const interpolation<tensor>&
234  ) const;
235 
236  //- Write
237  virtual void print(Ostream&) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace sampledSurfaces
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #ifdef NoRepository
249  #include "distanceSurfaceTemplates.C"
250 #endif
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #endif
255 
256 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:64
dictionary dict
const isoSurface & surface() const
virtual const faceList & faces() const
Faces of surface.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An abstract class for surfaces with sampling.
const word & name() const
Name of surface.
virtual bool update()
Update the surface as required.
bool interpolate() const
Interpolation requested for surface.
TypeName("distanceSurface")
Runtime type information.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
Generic GeometricField class.
A sampledSurface defined by a distance to a surface.
virtual void print(Ostream &) const
Write.
virtual const pointField & points() const
Points of surface.
A class for handling words, derived from string.
Definition: word.H:59
Type average(const Field< Type > &) const
Area-averaged value of a field across the surface.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool expire()
Mark the surface as needing an update.
A sampledSurface defined by a surface of iso value. To be used in sampleSurfaces / functionObjects...
const polyMesh & mesh() const
Access to the underlying mesh.
virtual const pointField & points() const
Points of surface.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
distanceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Abstract base class for interpolation.
virtual const faceList & faces() const
Faces of surface.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.