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 -------------------------------------------------------------------------------
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 "sampledDistanceSurface.H"
29 #include "dictionary.H"
30 #include "volFields.H"
31 #include "volPointInterpolation.H"
33 #include "fvMesh.H"
34 #include "volumeType.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(sampledDistanceSurface, 0);
42  (
43  sampledSurface,
44  sampledDistanceSurface,
45  word,
46  distanceSurface
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),
83  distance,
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() << " :";
233  distanceSurface::print(os, level);
234 }
235 
236 
237 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
volFields.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::sampledDistanceSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledDistanceSurface.C:99
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::distanceSurface::print
void print(Ostream &os, int level=0) const
Print information.
Definition: distanceSurface.C:762
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
sampledDistanceSurface.H
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:209
volumeType.H
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::sampledDistanceSurface::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledDistanceSurface.C:230
Foam::addNamedToRunTimeSelectionTable
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
Foam::sampledDistanceSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledDistanceSurface.C:142
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
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledDistanceSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledDistanceSurface.C:93
Foam::distance
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
volPointInterpolation.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::sampledDistanceSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledDistanceSurface.C:121
dictionary.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::distanceSurface::createGeometry
void createGeometry()
Create/recreate the distance surface.
Definition: distanceSurface.C:413
Foam::sampledDistanceSurface::sampledDistanceSurface
sampledDistanceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledDistanceSurface.C:54
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.