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 * * * * * * * * * * * * * //
92
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;
114 }
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(
143 const interpolation<scalar>& sampler
144) const
145{
146 return sampleOnFaces(sampler);
147}
148
149
151(
152 const interpolation<vector>& sampler
153) const
154{
155 return sampleOnFaces(sampler);
156}
157
158
160(
161 const interpolation<sphericalTensor>& sampler
162) const
163{
164 return sampleOnFaces(sampler);
165}
166
167
169(
170 const interpolation<symmTensor>& sampler
171) const
172{
173 return sampleOnFaces(sampler);
174}
175
176
178(
179 const interpolation<tensor>& sampler
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
196(
197 const interpolation<vector>& interpolator
198) const
199{
200 return sampleOnPoints(interpolator);
201}
202
204(
205 const interpolation<sphericalTensor>& interpolator
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
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.
Minimal example by using system/controlDict.functions:
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
void createGeometry()
Create/recreate the distance surface.
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 sampledSurface defined by a distance to a surface - resolved using an iso-surface (algorithm: cell,...
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.
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
OBJstream os(runTime.globalPath()/outputName)
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:372
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary dict