distanceSurface.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::distanceSurface
29 
30 Description
31  A surface defined by a distance from an input searchable surface.
32  Uses an iso-surface algorithm (cell, topo, point) for constructing the
33  distance surface.
34 
35 Usage
36  Dictionary controls:
37  \table
38  Property | Description | Required | Default
39  distance | distance from surface | yes |
40  signed | Use sign when distance is positive | partly |
41  isoAlgorithm | (cell/topo/point) | no | cell
42  regularise | Point snapping (enum or bool) | no | true
43  bounds | Limit with bounding box | no |
44  surfaceType | Type of surface | yes |
45  surfaceName | Name of surface in \c triSurface/ | no | dict name
46  \endtable
47 
48 Note
49  For distance = 0, some special adjustments.
50  - Always signed (ignoring the input value).
51  - Use normal distance from surface (for better treatment of open edges).
52  - When the isoSurfaceCell algorithm is used, additional checks for open
53  surfaces edges are used to limit the extend of resulting distance
54  surface. The resulting surface elements will not, however, contain
55  partial cell coverage.
56 
57  For compatibility, the keyword 'cell' (as a bool) is accepted
58 
59 SourceFiles
60  distanceSurface.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef distanceSurface_H
65 #define distanceSurface_H
66 
67 #include "sampledSurface.H"
68 #include "searchableSurface.H"
69 #include "isoSurface.H"
70 #include "isoSurfaceCell.H"
71 #include "isoSurfaceTopo.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class distanceSurface Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class distanceSurface
83 {
84  // Private data
85 
86  //- Reference to mesh
87  const polyMesh& mesh_;
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  //- The iso-surface algorithm type
99  const isoSurfaceBase::algorithmType isoAlgo_;
100 
101  //- Filtering for iso-surface triangles
102  const isoSurfaceBase::filterType filter_;
103 
104  //- Optional bounding box to trim against
105  const boundBox bounds_;
106 
107  //- Distance to cell centres
108  autoPtr<volScalarField> cellDistancePtr_;
109 
110  //- Distance to points
111  scalarField pointDistance_;
112 
113  //- Constructed iso surface (ALGO_POINT)
114  autoPtr<isoSurface> isoSurfPtr_;
115 
116  //- Constructed iso surface (ALGO_CELL)
117  autoPtr<isoSurfaceCell> isoSurfCellPtr_;
118 
119  //- Constructed iso surface (ALGO_TOPO)
120  autoPtr<isoSurfaceTopo> isoSurfTopoPtr_;
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("distanceSurface");
126 
127 
128  // Constructors
129 
130  //- Construct from dictionary
132  (
133  const word& defaultSurfaceName,
134  const polyMesh& mesh,
135  const dictionary& dict
136  );
137 
138  //- Construct from components
140  (
141  const polyMesh& mesh,
142  const bool interpolate,
143  const word& surfaceType,
144  const word& surfaceName,
145  const scalar distance,
146  const bool signedDistance,
148  const isoSurfaceBase::filterType filter,
149  const boundBox& bounds = boundBox::invertedBox
150  );
151 
152 
153  //- Destructor
154  virtual ~distanceSurface() = default;
155 
156 
157  // Member Functions
158 
159  //- Create/recreate the distance surface
160  void createGeometry();
161 
162  //- The name of the underlying searchableSurface
163  const word& surfaceName() const
164  {
165  return surfPtr_->name();
166  }
167 
168  //- The distance to the underlying searchableSurface
169  scalar distance() const
170  {
171  return distance_;
172  }
173 
174 
175  //- The underlying surface
176  const meshedSurface& surface() const
177  {
178  if (isoSurfCellPtr_)
179  {
180  return *isoSurfCellPtr_;
181  }
182  else if (isoSurfTopoPtr_)
183  {
184  return *isoSurfTopoPtr_;
185  }
186  return *isoSurfPtr_;
187  }
188 
189 
190  //- The underlying surface
192  {
193  if (isoSurfCellPtr_)
194  {
195  return *isoSurfCellPtr_;
196  }
197  else if (isoSurfTopoPtr_)
198  {
199  return *isoSurfTopoPtr_;
200  }
201  return *isoSurfPtr_;
202  }
203 
204  //- For each face, the original cell in mesh
205  const labelList& meshCells() const
206  {
207  if (isoSurfCellPtr_)
208  {
209  return isoSurfCellPtr_->meshCells();
210  }
211  else if (isoSurfTopoPtr_)
212  {
213  return isoSurfTopoPtr_->meshCells();
214  }
215  return isoSurfPtr_->meshCells();
216  }
217 
218  //- For each face, the original cell in mesh
220  {
221  if (isoSurfCellPtr_)
222  {
223  return isoSurfCellPtr_->meshCells();
224  }
225  else if (isoSurfTopoPtr_)
226  {
227  return isoSurfTopoPtr_->meshCells();
228  }
229  return isoSurfPtr_->meshCells();
230  }
231 
232 
233  // Interpolate
234 
235  //- Interpolate volume field onto surface points
236  template<class Type>
238  (
240  const Field<Type>& pointValues
241  ) const;
242 
243 
244  // Output
245 
246  //- Print information
247  void print(Ostream& os) const;
248 
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #ifdef NoRepository
259  #include "distanceSurfaceTemplates.C"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::distanceSurface::distance
scalar distance() const
The distance to the underlying searchableSurface.
Definition: distanceSurface.H:208
isoSurfaceTopo.H
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
isoSurfaceCell.H
Foam::boundBox::invertedBox
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
Definition: boundBox.H:86
distanceSurfaceTemplates.C
Foam::distanceSurface::distanceSurface
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: distanceSurface.C:88
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:121
Foam::isoSurfaceBase::algorithmType
algorithmType
The algorithm types.
Definition: isoSurfaceBase.H:78
Foam::distanceSurface::meshCells
const labelList & meshCells() const
For each face, the original cell in mesh.
Definition: distanceSurface.H:244
Foam::Field< scalar >
sampledSurface.H
Foam::distanceSurface::interpolate
tmp< Field< Type > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &cellValues, const Field< Type > &pointValues) const
Interpolate volume field onto surface points.
Foam::distanceSurface::surfaceName
const word & surfaceName() const
The name of the underlying searchableSurface.
Definition: distanceSurface.H:202
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
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::distanceSurface::print
void print(Ostream &os) const
Print information.
Definition: distanceSurface.C:468
isoSurface.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distanceSurface::~distanceSurface
virtual ~distanceSurface()=default
Destructor.
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::distanceSurface::surface
const meshedSurface & surface() const
The underlying surface.
Definition: distanceSurface.H:215
Foam::List< label >
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::distanceSurface::meshCells
labelList & meshCells()
For each face, the original cell in mesh.
Definition: distanceSurface.H:258
Foam::distanceSurface::createGeometry
void createGeometry()
Create/recreate the distance surface.
Definition: distanceSurface.C:180
Foam::distanceSurface::TypeName
TypeName("distanceSurface")
Runtime type information.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::MeshedSurface< face >
Foam::distanceSurface::surface
meshedSurface & surface()
The underlying surface.
Definition: distanceSurface.H:230
Foam::isoSurfaceBase::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceBase.H:87