sampledCuttingSurface.C
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-2021 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 \*---------------------------------------------------------------------------*/
27 
28 #include "sampledCuttingSurface.H"
29 #include "dictionary.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(sampledCuttingSurface, 0);
38  (
39  sampledSurface,
40  sampledCuttingSurface,
41  word
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 Foam::bitSet Foam::sampledCuttingSurface::cellSelection(const bool warn) const
49 {
50  boundBox meshBounds;
51 
52  bitSet cellsToSelect =
54  (
55  mesh(), bounds_, zoneNames_, meshBounds
56  );
57 
58  if (warn)
59  {
60  cuttingSurface::checkOverlap(name(), meshBounds, bounds_);
61  }
62 
63  return cellsToSelect;
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const polyMesh& mesh,
72  const word& surfaceType,
73  const word& surfaceName,
74  const bool triangulate,
75  const boundBox& bounds
76 )
77 :
78  sampledSurface(surfaceName, mesh),
79  cuttingSurface(mesh, surfaceType, surfaceName),
80  zoneNames_(),
81  bounds_(bounds),
82  triangulate_(triangulate),
83  needsUpdate_(true)
84 {}
85 
86 
88 (
89  const word& defaultSurfaceName,
90  const polyMesh& mesh,
91  const dictionary& dict
92 )
93 :
94  sampledSurface(defaultSurfaceName, mesh, dict),
95  cuttingSurface(defaultSurfaceName, mesh, dict),
96  zoneNames_(),
97  bounds_(dict.getOrDefault("bounds", boundBox::null())),
98  triangulate_(dict.getOrDefault("triangulate", true)),
99  needsUpdate_(true)
100 {
101  if (!dict.readIfPresent("zones", zoneNames_) && dict.found("zone"))
102  {
103  zoneNames_.resize(1);
104  dict.readEntry("zone", zoneNames_.first());
105  }
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 {
113  return needsUpdate_;
114 }
115 
116 
118 {
119  // Already marked as expired
120  if (needsUpdate_)
121  {
122  return false;
123  }
124 
126 
127  needsUpdate_ = true;
128  return true;
129 }
130 
131 
133 {
134  if (!needsUpdate_)
135  {
136  return false;
137  }
138 
140 
141  performCut(mesh(), triangulate_, cellSelection(true));
142 
143  if (debug)
144  {
146  Pout<< endl;
147  }
149  needsUpdate_ = false;
150  return true;
151 }
152 
153 
155 (
156  const interpolation<scalar>& sampler
157 ) const
158 {
159  return sampleOnFaces(sampler);
160 }
161 
162 
164 (
165  const interpolation<vector>& sampler
166 ) const
167 {
168  return sampleOnFaces(sampler);
169 }
170 
171 
173 (
174  const interpolation<sphericalTensor>& sampler
175 ) const
176 {
177  return sampleOnFaces(sampler);
178 }
179 
180 
182 (
183  const interpolation<symmTensor>& sampler
184 ) const
185 {
186  return sampleOnFaces(sampler);
187 }
188 
189 
191 (
192  const interpolation<tensor>& sampler
193 ) const
194 {
195  return sampleOnFaces(sampler);
196 }
197 
198 
200 (
201  const interpolation<scalar>& interpolator
202 ) const
203 {
204  return sampleOnPoints(interpolator);
205 }
206 
207 
209 (
210  const interpolation<vector>& interpolator
211 ) const
212 {
213  return sampleOnPoints(interpolator);
214 }
215 
217 (
218  const interpolation<sphericalTensor>& interpolator
219 ) const
220 {
221  return sampleOnPoints(interpolator);
222 }
223 
224 
226 (
227  const interpolation<symmTensor>& interpolator
228 ) const
229 {
230  return sampleOnPoints(interpolator);
231 }
232 
233 
235 (
236  const interpolation<tensor>& interpolator
237 ) const
238 {
239  return sampleOnPoints(interpolator);
240 }
241 
242 
243 // ************************************************************************* //
sampledCuttingSurface(const polyMesh &mesh, const word &surfaceType, const word &surfaceName, const bool triangulate=true, const boundBox &bounds=boundBox::null())
Construct from components.
dictionary dict
bool interpolate() const noexcept
Same as isPointData()
void print(Ostream &os, int level=0) const
Print information.
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:160
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
An abstract class for surfaces with sampling.
static bitSet cellSelection(const polyMesh &mesh, const boundBox &userBounds, const wordRes &zoneNames, boundBox &meshBounds)
Define cell selection from bounding-box and zones.
T & first()
Access first element of the list, position [0].
Definition: UList.H:853
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Macros for easy insertion into run-time selection tables.
const word & name() const noexcept
Name of surface.
dynamicFvMesh & mesh
static void checkOverlap(const word callerName, const boundBox &meshBounds, const boundBox &userBounds)
Check and warn if bounding boxes do not intersect.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
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
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool expire()
Mark the surface as needing an update.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Constructs a cutting surface through a mesh.
virtual bool update()
Update the surface as required.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)