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-2021 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  Example:
31  \verbatim
32  {
33  type distanceSurface;
34  surfaceType searchableBox;
35  min (-1 -1 -1);
36  max (1 1 1);
37  distance 0.1;
38  signed yes;
39  filtering full;
40  interpolate yes;
41  }
42  \endverbatim
43 
44 Usage
45  \table
46  Property | Description | Required | Default value
47  surfaceType | the type of surface to sample from | yes |
48  distance | the distance from which to sample the surface | yes |
49  signed | sample only on one side of the surface, specified by \\
50  the sign of the distance | yes |
51  filtering | the level of filtering to perform on the iso-surface \\
52  | no | full
53  interpolate | interpolate values to the surface points | no | no
54  \endtable
55 
56 See also
57  Foam::isoSurface
58 
59 SourceFiles
60  distanceSurface.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef sampledSurfaces_distanceSurface_H
65 #define sampledSurfaces_distanceSurface_H
66 
67 #include "sampledSurface.H"
68 #include "searchableSurface.H"
69 #include "isoSurface.H"
70 #include "fvMeshSubset.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 namespace sampledSurfaces
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class distanceSurface Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class distanceSurface
84 :
85  public sampledSurface
86 {
87  // Private Data
88 
89  //- Surface
90  const autoPtr<searchableSurface> surfPtr_;
91 
92  //- Distance value
93  const scalar distance_;
94 
95  //- Signed distance
96  const bool signed_;
97 
98  //- Whether to coarsen
99  const isoSurface::filterType filter_;
100 
101  //- Whether to recalculate cell values as average of point values
102  const Switch average_;
103 
104  //- If restricted to zones, name of this zone or a regular expression
105  wordRe zoneKey_;
106 
107  //- For zones: patch to put exposed faces into
108  mutable word exposedPatchName_;
109 
110  //- Track if the surface needs an update
111  mutable bool needsUpdate_;
112 
113  //- Optional subsetted mesh
114  autoPtr<fvMeshSubset> subMeshPtr_;
115 
116  //- Distance to cell centres
117  autoPtr<volScalarField> cellDistancePtr_;
118 
119  //- Distance to points
120  scalarField pointDistance_;
121 
122  //- Constructed iso surface
123  autoPtr<isoSurface> isoSurfPtr_;
124 
125 
126  // Private Member Functions
127 
128  //- Create iso surface
129  void createGeometry();
130 
131  //- Sample field on faces
132  template<class Type>
133  tmp<Field<Type>> sampleField
134  (
136  ) const;
137 
138 
139  template<class Type>
141  interpolateField(const interpolation<Type>&) const;
142 
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("distanceSurface");
148 
149 
150  // Constructors
151 
152  //- Construct from dictionary
154  (
155  const word& name,
156  const polyMesh& mesh,
157  const dictionary& dict
158  );
159 
160 
161  //- Destructor
162  virtual ~distanceSurface();
163 
164 
165  // Member Functions
166 
167  //- Does the surface need an update?
168  virtual bool needsUpdate() const;
169 
170  //- Mark the surface as needing an update.
171  // May also free up unneeded data.
172  // Return false if surface was already marked as expired.
173  virtual bool expire();
174 
175  //- Update the surface as required.
176  // Do nothing (and return false) if no update was needed
177  virtual bool update();
178 
179  //- Points of surface
180  virtual const pointField& points() const
181  {
182  return surface().points();
183  }
184 
185  //- Faces of surface
186  virtual const faceList& faces() const
187  {
188  return surface().faces();
189  }
190 
191  const isoSurface& surface() const
192  {
193  return isoSurfPtr_();
194  }
195 
196  //- Sample field on surface
197  virtual tmp<scalarField> sample
198  (
199  const volScalarField&
200  ) const;
201 
202  //- Sample field on surface
203  virtual tmp<vectorField> sample
204  (
205  const volVectorField&
206  ) const;
208  //- Sample field on surface
210  (
212  ) const;
214  //- Sample field on surface
216  (
217  const volSymmTensorField&
218  ) const;
219 
220  //- Sample field on surface
221  virtual tmp<tensorField> sample
222  (
223  const volTensorField&
224  ) const;
225 
226 
227  //- Interpolate field on surface
229  (
230  const interpolation<scalar>&
231  ) const;
232 
233  //- Interpolate field on surface
235  (
236  const interpolation<vector>&
237  ) const;
238 
239  //- Interpolate field on surface
241  (
243  ) const;
244 
245  //- Interpolate field on surface
247  (
249  ) const;
250 
251  //- Interpolate field on surface
253  (
254  const interpolation<tensor>&
255  ) const;
256 
257  //- Write
258  virtual void print(Ostream&) const;
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace sampledSurfaces
265 } // End namespace Foam
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #ifdef NoRepository
270  #include "distanceSurfaceTemplates.C"
271 #endif
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #endif
276 
277 // ************************************************************************* //
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:156
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.
Generic GeometricField class.
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
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.
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:54
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:76
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.