sampledIsoSurfaceSurface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace sampledSurfaces
33 {
35 }
36 }
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const word& name,
43  const polyMesh& mesh,
44  const dictionary& dict
45 )
46 :
47  sampledSurface(name, mesh, dict),
48  zoneName_(dict.lookupOrDefault("zone", word::null)),
49  isoSurfPtr_(nullptr),
50  isoSurfTimeIndex_(-1)
51 {
52  if (zoneName_ != word::null && !mesh.cellZones().found(zoneName_))
53  {
55  << "Cell zone " << zoneName_
56  << " not found. Using the entire mesh" << endl;
57  }
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  // Clear data
73  isoSurfPtr_.clear();
74 
75  // Already marked as expired
76  if (isoSurfTimeIndex_ == -1)
77  {
78  return false;
79  }
80 
81  // Force update
82  isoSurfTimeIndex_ = -1;
83  return true;
84 }
85 
86 
88 {
89  // Quick return if no update needed
90  if (!needsUpdate())
91  {
92  return false;
93  }
94 
95  // Clear any information in the base class
97 
98  // Update the iso surface
99  isoSurfPtr_.reset(calcIsoSurf().ptr());
100 
101  // Set the time index
102  isoSurfTimeIndex_ = mesh().time().timeIndex();
103 
104  return true;
105 }
106 
107 
109 {
110  return static_cast<const sampledIsoSurfaceSurface&>(*this).update();
111 }
112 
113 
114 #define IMPLEMENT_SAMPLE(Type, nullArg) \
115  Foam::tmp<Foam::Field<Foam::Type>> \
116  Foam::sampledSurfaces::sampledIsoSurfaceSurface::sample \
117  ( \
118  const VolField<Type>& vField \
119  ) const \
120  { \
121  return sampleField(vField); \
122  }
124 #undef IMPLEMENT_SAMPLE
125 
126 
127 #define IMPLEMENT_INTERPOLATE(Type, nullArg) \
128  Foam::tmp<Foam::Field<Foam::Type>> \
129  Foam::sampledSurfaces::sampledIsoSurfaceSurface::interpolate \
130  ( \
131  const interpolation<Type>& interpolator \
132  ) const \
133  { \
134  return interpolateField(interpolator); \
135  }
137 #undef IMPLEMENT_INTERPOLATE
138 
139 
140 // ************************************************************************* //
bool found(const label objectIndex) const
Return true if objectIndex is in any zone.
Definition: ZoneList.C:122
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const cellZoneList & cellZones() const
Return cell zones.
Definition: polyMesh.H:452
An abstract class for surfaces with sampling.
virtual void clearGeom() const
const polyMesh & mesh() const
Access to the underlying mesh.
A base class for sampled surfaces constructed from iso-surfaces.
sampledIsoSurfaceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual bool expire()
Mark the surface as needing an update.
virtual bool update()
Update the surface as required.
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
#define WarningInFunction
Report a warning using Foam::Warning.
defineTypeNameAndDebug(cutPlane, 0)
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
#define IMPLEMENT_INTERPOLATE(Type, nullArg)
#define IMPLEMENT_SAMPLE(Type, nullArg)
dictionary dict