sampledCuttingSurface.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::sampledCuttingSurface
28 
29 Description
30  A surface define by using an input surface to cut the mesh cells
31 
32 Usage
33  Dictionary controls:
34  \table
35  Property | Description | Required | Default
36  type | surfaceCut | yes |
37  surfaceType | type of surface | yes |
38  surfaceName | name of surface in \c triSurface/ | no | dict name
39  triangulate | triangulate faces | no | true
40  bounds | limit with bounding box | no |
41  zone | limit to cell zone (name or regex) | no |
42  zones | limit to cell zones (names, regexs) | no |
43  \endtable
44 
45 Note
46  No attempt at resolving degenerate cases.
47  Since the cut faces can be quite ugly, they will often be triangulated.
48 
49 SourceFiles
50  sampledCuttingSurface.C
51  sampledCuttingSurfaceTemplates.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef sampledCuttingSurface_H
56 #define sampledCuttingSurface_H
57 
58 #include "sampledSurface.H"
59 #include "cuttingSurface.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class sampledCuttingSurface Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class sampledCuttingSurface
71 :
72  public sampledSurface,
73  public cuttingSurface
74 {
75  // Private Data
76 
77  //- The zone or zones in which cutting is to occur
78  wordRes zoneNames_;
79 
80  //- Optional bounding box to trim against
81  const boundBox bounds_;
82 
83  //- Triangulate faces or not
84  const bool triangulate_;
85 
86  //- Track if the surface needs an update
87  mutable bool needsUpdate_;
88 
89 
90  // Private Member Functions
91 
92  //- Define cell selection from zones and bounding box.
93  // Optionally check and warn if the bounding box
94  // does not overlap with the mesh (or submesh)
95  bitSet cellSelection(const bool warn=false) const;
96 
97 
98  //- Sample volume field onto surface faces
99  template<class Type>
100  tmp<Field<Type>> sampleOnFaces
101  (
102  const interpolation<Type>& sampler
103  ) const;
104 
105  //- Interpolate volume field onto surface points
106  template<class Type>
107  tmp<Field<Type>> sampleOnPoints
108  (
109  const interpolation<Type>& interpolator
110  ) const;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("surfaceCut");
117 
118 
119  // Constructors
120 
121  //- Construct from components
123  (
124  const polyMesh& mesh,
125  const word& surfaceType,
126  const word& surfaceName,
127  const bool triangulate = true,
128  const boundBox& bounds = boundBox::null()
129  );
130 
131  //- Construct from dictionary
133  (
134  const word& defaultSurfaceName,
135  const polyMesh& mesh,
136  const dictionary& dict
137  );
138 
139 
140  //- Destructor
141  virtual ~sampledCuttingSurface() = default;
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 
159  //- Points of surface
160  virtual const pointField& points() const
161  {
162  return cuttingSurface::points();
163  }
164 
165  //- Faces of surface
166  virtual const faceList& faces() const
167  {
168  return cuttingSurface::surfFaces();
169  }
170 
171  //- Per-face zone/region information
172  // Could instead return meshCells or cellZoneId of the meshCells.
173  virtual const labelList& zoneIds() const
174  {
175  return labelList::null();
176  }
177 
178  //- Face area magnitudes
179  virtual const vectorField& Sf() const
180  {
181  return cuttingSurface::Sf();
182  }
183 
184  //- Face area magnitudes
185  virtual const scalarField& magSf() const
186  {
187  return cuttingSurface::magSf();
188  }
189 
190  //- Face centres
191  virtual const vectorField& Cf() const
192  {
193  return cuttingSurface::Cf();
194  }
195 
196  //- For each face, the original cell in mesh
198 
199 
200  // Sample
201 
202  //- Sample volume field onto surface faces
203  virtual tmp<scalarField> sample
204  (
205  const interpolation<scalar>& sampler
206  ) const;
207 
208  //- Sample volume field onto surface faces
209  virtual tmp<vectorField> sample
210  (
211  const interpolation<vector>& sampler
212  ) const;
213 
214  //- Sample volume field onto surface faces
215  virtual tmp<sphericalTensorField> sample
216  (
217  const interpolation<sphericalTensor>& sampler
218  ) const;
219 
220  //- Sample volume field onto surface faces
221  virtual tmp<symmTensorField> sample
222  (
223  const interpolation<symmTensor>& sampler
224  ) const;
225 
226  //- Sample volume field onto surface faces
227  virtual tmp<tensorField> sample
228  (
229  const interpolation<tensor>& sampler
230  ) const;
231 
232 
233  // Interpolate
234 
235  //- Interpolate volume field onto surface points
237  (
238  const interpolation<scalar>& interpolator
239  ) const;
240 
241  //- Interpolate volume field onto surface points
243  (
244  const interpolation<vector>& interpolator
245  ) const;
247  //- Interpolate volume field onto surface points
249  (
250  const interpolation<sphericalTensor>& interpolator
251  ) const;
252 
253  //- Interpolate volume field onto surface points
255  (
256  const interpolation<symmTensor>& interpolator
257  ) const;
258 
259  //- Interpolate volume field onto surface points
261  (
262  const interpolation<tensor>& interpolator
263  ) const;
264 };
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace Foam
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #ifdef NoRepository
275 #endif
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
static const boundBox & null() noexcept
The null boundBox is the same as an inverted box.
Definition: boundBox.H:137
sampledCuttingSurface(const polyMesh &mesh, const word &surfaceType, const word &surfaceName, const bool triangulate=true, const boundBox &bounds=boundBox::null())
Construct from components.
const word & surfaceName() const
The name of the underlying searchableSurface.
dictionary dict
bool interpolate() const noexcept
Same as isPointData()
virtual const vectorField & Cf() const
Face centres.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const vectorField & Sf() const
Face area vectors (normals)
virtual ~sampledCuttingSurface()=default
Destructor.
virtual const pointField & points() const
Points of surface.
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
static const List< label > & null()
Return a null List.
Definition: ListI.H:130
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const scalarField & magSf() const
Face area magnitudes.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const scalarField & magSf() const
Face area magnitudes.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
const Field< point_type > & points() const noexcept
Return reference to global points.
virtual const labelList & zoneIds() const
Per-face zone/region information.
virtual const vectorField & Sf() const
Face area magnitudes.
const List< Face > & surfFaces() const
Return const access to the faces.
TypeName("surfaceCut")
Runtime type information.
surfaceTopo surfaceType(labelHashSet *badEdgesPtr=nullptr) const
Calculate surface type formed by patch, optionally recording the indices of illegal edges...
virtual bool needsUpdate() const
Does the surface need an update?
const labelList & meshCells() const
The mesh cells cut.
virtual bool expire()
Mark the surface as needing an update.
const vectorField & Cf() const
Face centres.
Abstract base class for volume field interpolation.
virtual const faceList & faces() const
Faces of surface.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< label > labelList
A List of labels.
Definition: List.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual bool update()
Update the surface as required.
Namespace for OpenFOAM.