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 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", wordRe::null)),
49  zoneIDs_(mesh.cellZones().findIndices(zoneName_)),
50  isoSurfPtr_(nullptr),
51  isoSurfTimeIndex_(-1)
52 {
53  if (zoneName_ != wordRe::null && zoneIDs_.empty())
54  {
56  << "Cell zone " << zoneName_
57  << " not found. Using the entire mesh" << endl;
58  }
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63 
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 {
72  // Clear data
74  isoSurfPtr_.clear();
75 
76  // Already marked as expired
77  if (isoSurfTimeIndex_ == -1)
78  {
79  return false;
80  }
81 
82  // Force update
83  isoSurfTimeIndex_ = -1;
84  return true;
85 }
86 
87 
89 {
90  // Quick return if no update needed
91  if (!needsUpdate())
92  {
93  return false;
94  }
95 
96  // Clear any information in the base class
98 
99  // Update the iso surface
100  isoSurfPtr_.reset(calcIsoSurf().ptr());
101 
102  // Set the time index
103  isoSurfTimeIndex_ = mesh().time().timeIndex();
104 
105  return true;
106 }
107 
108 
110 {
111  return static_cast<const sampledIsoSurfaceSurface&>(*this).update();
112 }
113 
114 
115 #define IMPLEMENT_SAMPLE(Type, nullArg) \
116  Foam::tmp<Foam::Field<Foam::Type>> \
117  Foam::sampledSurfaces::sampledIsoSurfaceSurface::sample \
118  ( \
119  const VolField<Type>& vField \
120  ) const \
121  { \
122  return sampleField(vField); \
123  }
125 #undef IMPLEMENT_SAMPLE
126 
127 
128 #define IMPLEMENT_INTERPOLATE(Type, nullArg) \
129  Foam::tmp<Foam::Field<Foam::Type>> \
130  Foam::sampledSurfaces::sampledIsoSurfaceSurface::interpolate \
131  ( \
132  const interpolation<Type>& interpolator \
133  ) const \
134  { \
135  return interpolateField(interpolator); \
136  }
138 #undef IMPLEMENT_INTERPOLATE
139 
140 
141 // ************************************************************************* //
bool empty() const
Return true if the UList is empty (ie, size() is zero)
Definition: UListI.H:325
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
An abstract class for surfaces with sampling.
virtual void clearGeom() const
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 wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
static const wordRe null
An empty wordRe.
Definition: wordRe.H:88
A class for handling words, derived from string.
Definition: word.H:62
#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:251
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
FOR_ALL_FIELD_TYPES(DefineContiguousFvWallLocationDataType)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
#define IMPLEMENT_INTERPOLATE(Type, nullArg)
#define IMPLEMENT_SAMPLE(Type, nullArg)
dictionary dict