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
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Minimal example by using system/controlDict.functions:
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
T & first()
Return the first element of the list.
Definition: UListI.H:202
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
void checkOverlap(const word callerName, const boundBox &meshBounds, const boundBox &userBounds) const
Constructs a cutting surface through a mesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Abstract base class for volume field interpolation.
Definition: interpolation.H:60
scalar print()
Print to screen.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A surface define by using an input surface to cut the mesh cells.
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.
An abstract class for surfaces with sampling.
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:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary dict