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::invertedBox)),
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 * * * * * * * * * * * * * //
110 
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  }
148 
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 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
Foam::boundBox::invertedBox
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
Definition: boundBox.H:86
Foam::cuttingSurfaceBase::checkOverlap
static void checkOverlap(const word callerName, const boundBox &meshBounds, const boundBox &userBounds)
Check and warn if bounding boxes do not intersect.
Definition: cuttingSurfaceBaseSelection.C:34
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::sampledCuttingSurface::sampledCuttingSurface
sampledCuttingSurface(const polyMesh &mesh, const word &surfaceType, const word &surfaceName, const bool triangulate=true, const boundBox &bounds=boundBox::invertedBox)
Construct from components.
Definition: sampledCuttingSurface.C:70
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::cuttingSurfaceBase::cellSelection
static bitSet cellSelection(const polyMesh &mesh, const boundBox &userBounds, const wordRes &zoneNames, boundBox &meshBounds)
Define cell selection from bounding-box and zones.
Definition: cuttingSurfaceBaseSelection.C:53
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::cuttingSurface::print
void print(Ostream &os, int level=0) const
Print information.
Definition: cuttingSurface.C:170
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::sampledCuttingSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledCuttingSurface.C:111
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:302
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
Foam::interpolation< scalar >
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:123
Foam::sampledCuttingSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledCuttingSurface.C:117
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledCuttingSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledCuttingSurface.C:155
Foam::sampledCuttingSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledCuttingSurface.C:132
Foam::sampledSurface::mesh
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
Definition: sampledSurface.H:316
dictionary.H
Foam::sampledSurface::clearGeom
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
Definition: sampledSurface.C:53
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::cuttingSurface
Constructs a cutting surface through a mesh.
Definition: cuttingSurface.H:54
sampledCuttingSurface.H
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405