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-2020 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 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  return needsUpdate_;
72 }
73 
74 
76 {
77  if (debug)
78  {
79  Pout<< "sampledDistanceSurface::expire :"
80  << " needsUpdate:" << needsUpdate_ << endl;
81  }
82 
83  // Clear derived data
84  clearGeom();
85 
86  // already marked as expired
87  if (needsUpdate_)
88  {
89  return false;
90  }
91 
92  needsUpdate_ = true;
93  return true;
94 }
95 
96 
98 {
99  if (debug)
100  {
101  Pout<< "sampledDistanceSurface::update :"
102  << " needsUpdate:" << needsUpdate_ << endl;
103  }
104 
105  if (!needsUpdate_)
106  {
107  return false;
108  }
109 
111 
112  needsUpdate_ = false;
113  return true;
114 }
115 
116 
118 (
119  const interpolation<scalar>& sampler
120 ) const
121 {
122  return sampleOnFaces(sampler);
123 }
124 
125 
127 (
128  const interpolation<vector>& sampler
129 ) const
130 {
131  return sampleOnFaces(sampler);
132 }
133 
134 
136 (
137  const interpolation<sphericalTensor>& sampler
138 ) const
139 {
140  return sampleOnFaces(sampler);
141 }
142 
143 
145 (
146  const interpolation<symmTensor>& sampler
147 ) const
148 {
149  return sampleOnFaces(sampler);
150 }
151 
152 
154 (
155  const interpolation<tensor>& sampler
156 ) const
157 {
158  return sampleOnFaces(sampler);
159 }
160 
161 
163 (
164  const interpolation<scalar>& interpolator
165 ) const
166 {
167  return sampleOnPoints(interpolator);
168 }
169 
170 
172 (
173  const interpolation<vector>& interpolator
174 ) const
175 {
176  return sampleOnPoints(interpolator);
177 }
178 
180 (
181  const interpolation<sphericalTensor>& interpolator
182 ) const
183 {
184  return sampleOnPoints(interpolator);
185 }
186 
187 
189 (
190  const interpolation<symmTensor>& interpolator
191 ) const
192 {
193  return sampleOnPoints(interpolator);
194 }
195 
196 
198 (
199  const interpolation<tensor>& interpolator
200 ) const
201 {
202  return sampleOnPoints(interpolator);
203 }
204 
205 
207 {
208  os << "distanceSurface: " << name() << " :";
210 }
211 
212 
213 // ************************************************************************* //
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:62
Foam::sampledDistanceSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledDistanceSurface.C:75
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::sampledDistanceSurface::print
virtual void print(Ostream &os) const
Print information.
Definition: sampledDistanceSurface.C:206
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:198
volumeType.H
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
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:118
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
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:121
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:69
Foam::distanceSurface::print
void print(Ostream &os) const
Print information.
Definition: distanceSurface.C:694
volPointInterpolation.H
Foam::sampledDistanceSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledDistanceSurface.C:97
dictionary.H
Foam::distanceSurface::createGeometry
void createGeometry()
Create/recreate the distance surface.
Definition: distanceSurface.C:388
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::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:339
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)