Loading...
Searching...
No Matches
sampledDistanceSurface.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"
30#include "volFields.H"
33#include "fvMesh.H"
34#include "volumeType.H"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
42 (
45 word,
47 );
48}
49
50
51// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52
54(
55 const word& name,
56 const polyMesh& mesh,
57 const dictionary& dict
58)
59:
62 average_(dict.getOrDefault("average", false)),
63 needsUpdate_(true)
64{}
65
66
68(
69 const word name,
70 const polyMesh& mesh,
71 const bool interpolate,
73 const scalar distance,
74 const bool useSignedDistance
75)
76:
79 (
80 mesh,
82 std::move(surface),
84 useSignedDistance
85 ),
86 average_(false), // pass as param?
87 needsUpdate_(true)
88{}
89
90
91// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94{
95 return needsUpdate_;
96}
97
98
100{
101 if (debug)
102 {
103 Pout<< "sampledDistanceSurface::expire :"
104 << " needsUpdate:" << needsUpdate_ << endl;
105 }
106
107 // Clear derived data
108 clearGeom();
109
110 // already marked as expired
111 if (needsUpdate_)
112 {
113 return false;
115
116 needsUpdate_ = true;
117 return true;
118}
119
120
122{
123 if (debug)
124 {
125 Pout<< "sampledDistanceSurface::update :"
126 << " needsUpdate:" << needsUpdate_ << endl;
127 }
128
129 if (!needsUpdate_)
130 {
131 return false;
132 }
133
135
136 needsUpdate_ = false;
137 return true;
138}
139
140
142(
144) const
145{
146 return sampleOnFaces(sampler);
147}
148
149
151(
153) const
154{
155 return sampleOnFaces(sampler);
156}
157
158
160(
162) const
163{
164 return sampleOnFaces(sampler);
165}
166
167
169(
171) const
172{
173 return sampleOnFaces(sampler);
174}
175
176
178(
180) const
181{
182 return sampleOnFaces(sampler);
183}
184
185
187(
188 const interpolation<scalar>& interpolator
189) const
190{
191 return sampleOnPoints(interpolator);
192}
193
194
197 const interpolation<vector>& interpolator
198) const
199{
200 return sampleOnPoints(interpolator);
201}
202
204(
206) const
207{
208 return sampleOnPoints(interpolator);
209}
210
211
213(
214 const interpolation<symmTensor>& interpolator
215) const
216{
217 return sampleOnPoints(interpolator);
218}
219
220
222(
223 const interpolation<tensor>& interpolator
224) const
225{
226 return sampleOnPoints(interpolator);
227}
228
229
230void Foam::sampledDistanceSurface::print(Ostream& os, int level) const
231{
232 os << "distanceSurface: " << name() << " :";
234}
235
236
237// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
void createGeometry()
Create/recreate the distance surface.
scalar distance() const noexcept
The distance to the underlying searchableSurface.
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
void print(Ostream &os, int level=0) const
Print information.
const meshedSurface & surface() const
The underlying surface.
Abstract base class for volume field interpolation.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A sampledSurface defined by a distance to a surface - resolved using an iso-surface (algorithm: cell,...
virtual tmp< scalarField > interpolate(const interpolation< scalar > &interpolator) const
Interpolate volume field onto surface points.
virtual void print(Ostream &os, int level=0) const
Print information.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
sampledDistanceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
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.
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
OBJstream os(runTime.globalPath()/outputName)
auto & name
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for OpenFOAM.
scalar distance(const vector &p1, const vector &p2)
Definition curveTools.C:12
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary dict