Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
29#include "dictionary.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38 (
41 word
42 );
43}
44
45
46// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47
48Foam::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 }
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;
148
149 needsUpdate_ = false;
150 return true;
151}
152
153
155(
157) const
158{
159 return sampleOnFaces(sampler);
160}
161
162
164(
166) const
167{
168 return sampleOnFaces(sampler);
169}
170
171
173(
175) const
176{
177 return sampleOnFaces(sampler);
178}
179
180
182(
184) const
185{
186 return sampleOnFaces(sampler);
187}
188
189
191(
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
210 const interpolation<vector>& interpolator
211) const
212{
213 return sampleOnPoints(interpolator);
214}
215
217(
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static const List< face > & null() noexcept
Definition List.H:138
virtual label triangulate()
surfaceTopo surfaceType(labelHashSet *badEdgesPtr=nullptr) const
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A bounding box defined in terms of min/max extrema points.
Definition boundBox.H:71
static void checkOverlap(const word callerName, const boundBox &meshBounds, const boundBox &userBounds)
Check and warn if bounding boxes do not intersect.
static bitSet cellSelection(const polyMesh &mesh, const boundBox &userBounds, const wordRes &zoneNames, boundBox &meshBounds)
Define cell selection from bounding-box and zones.
Constructs a cutting surface through a mesh.
void print(Ostream &os, int level=0) const
Print information.
virtual void performCut(const primitiveMesh &mesh, const bool triangulate, bitSet &&cellIdLabels)
Cut mesh, restricted to a list of cells.
const word & surfaceName() const
The name of the underlying searchableSurface.
cuttingSurface(const polyMesh &mesh, const word &surfaceType, const word &surfaceName)
Construct from components.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Abstract base class for volume field interpolation.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A surface define by using an input surface to cut the mesh cells.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool update()
Update the surface as required.
sampledCuttingSurface(const polyMesh &mesh, const word &surfaceType, const word &surfaceName, const bool triangulate=true, const boundBox &bounds=boundBox::null())
Construct from components.
An abstract class for surfaces with sampling.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
const word & name() const noexcept
Name of surface.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
bool interpolate() const noexcept
Same as isPointData().
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
Namespace for bounding specifications. At the moment, mostly for tables.
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary dict