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-2026 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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
39 
41 Foam::sampledSurfaces::sampledIsoSurfaceSurface::calcIsoSurf
42 (
43  const scalarField& pointValues,
44  const scalar isoValue
45 ) const
46 {
47  if (zone_.all())
48  {
50  (
51  new cutPolyIsoSurface(mesh(), pointValues, isoValue)
52  );
53  }
54  else
55  {
57  (
58  new cutPolyIsoSurface(mesh(), pointValues, isoValue, zone_.zone())
59  );
60  }
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
67 (
68  const word& name,
69  const polyMesh& mesh,
70  const dictionary& dict
71 )
72 :
74  zone_(mesh, dict, true),
75  isoSurfPtr_(nullptr),
76  isoSurfTimeIndex_(-1)
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  // Quick return if no update needed
91  if (!zone_.regenerate() && !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 
142 {
144  zone_.movePoints();
145  isoSurfPtr_.clear();
146  isoSurfTimeIndex_ = -1;
147 }
148 
149 
151 (
152  const polyTopoChangeMap& map
153 )
154 {
156  zone_.topoChange(map);
157  isoSurfPtr_.clear();
158  isoSurfTimeIndex_ = -1;
159 }
160 
161 
163 (
164  const polyMeshMap& map
165 )
166 {
168  zone_.mapMesh(map);
169  isoSurfPtr_.clear();
170  isoSurfTimeIndex_ = -1;
171 }
172 
173 
175 (
176  const polyDistributionMap& map
177 )
178 {
180  zone_.distribute(map);
181  isoSurfPtr_.clear();
182  isoSurfTimeIndex_ = -1;
183 }
184 
185 
186 // ************************************************************************* //
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:28
Iso-surface class based on the cutPoly cutting routines.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
const cellZone & zone() const
Return const access to the cell set.
bool all() const
Return true if the set comprises all the cells.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void movePoints()
Update for mesh point-motion.
sampledIsoSurfaceSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool update()
Update the surface as required.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(cutPlane, 0)
Namespace for OpenFOAM.
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
#define IMPLEMENT_INTERPOLATE(Type, nullArg)
#define IMPLEMENT_SAMPLE(Type, nullArg)
dictionary dict