sampledIsoSurfaceSurface.H
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 Class
25  Foam::sampledSurfaces::sampledIsoSurfaceSurface
26 
27 Description
28  A base class for sampled surfaces constructed from iso-surfaces
29 
30 SourceFiles
31  sampledIsoSurfaceSurface.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sampledIsoSurfaceSurface_H
36 #define sampledIsoSurfaceSurface_H
37 
38 #include "sampledSurface.H"
39 #include "cutPolyIsoSurface.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace sampledSurfaces
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class sampledIsoSurfaceSurface Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public sampledSurface
55 {
56 private:
57 
58  // Private Data
59 
60  //- If restricted to zones, name of this zone or a regular expression
61  const wordRe zoneName_;
62 
63  //- If restricted to zones, the indices of the zones
64  const labelList zoneIDs_;
65 
66  //- Constructed iso surface
67  mutable autoPtr<cutPolyIsoSurface> isoSurfPtr_;
68 
69  //- Time index at last surface generation
70  mutable label isoSurfTimeIndex_;
71 
72 
73  // Private Member Functions
74 
75  //- Generate the iso surface
76  virtual autoPtr<cutPolyIsoSurface> calcIsoSurf() const = 0;
77 
78  //- Sample field on the surface's faces
79  template<class Type>
80  tmp<Field<Type>> sampleField
81  (
82  const VolField<Type>& vField
83  ) const;
84 
85  //- Interpolate field to the surface's points
86  template<class Type>
87  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
88 
89 
90 protected:
91 
92  // Protected Member Functions
93 
94  //- Access the zone indices
95  inline const labelList& zoneIDs() const
96  {
97  return zoneIDs_.empty() ? NullObjectRef<labelList>() : zoneIDs_;
98  }
99 
100  //- Access the time index
101  inline const label& timeIndex() const
102  {
103  return isoSurfTimeIndex_;
104  }
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("sampledIsoSurfaceSurface");
111 
112 
113  // Constructors
114 
115  //- Construct from dictionary
117  (
118  const word& name,
119  const polyMesh& mesh,
120  const dictionary& dict
121  );
122 
123 
124  //- Destructor
125  virtual ~sampledIsoSurfaceSurface();
126 
127 
128  // Member Functions
129 
130  //- Mark the surface as needing an update.
131  // May also free up unneeded data.
132  // Return false if surface was already marked as expired.
133  virtual bool expire();
134 
135  //- Update the surface as required.
136  // Do nothing (and return false) if no update was needed
137  virtual bool update();
138 
139  //- Update the surface as required.
140  // Do nothing (and return false) if no update was needed
141  virtual bool update() const;
142 
143  //- Points of surface
144  virtual const pointField& points() const
145  {
146  return isoSurfPtr_->points();
147  }
148 
149  //- Faces of surface
150  virtual const faceList& faces() const
151  {
152  return isoSurfPtr_->faces();
153  }
154 
155  //- Sample field on the surface's faces
156  #define DEFINE_SAMPLE(Type, nullArg) \
157  virtual tmp<Field<Type>> sample \
158  ( \
159  const VolField<Type>& \
160  ) const;
162  #undef DEFINE_SAMPLE
163 
164  //- Interpolate field to the surface's points
165  #define DEFINE_INTERPOLATE(Type, nullArg) \
166  virtual tmp<Field<Type>> interpolate \
167  ( \
168  const interpolation<Type>& \
169  ) const;
171  #undef DEFINE_INTERPOLATE
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace sampledSurfaces
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #ifdef NoRepository
184 #endif
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
Generic GeometricField class.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
Definition: UListI.H:325
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base class for interpolation.
Definition: interpolation.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
An abstract class for surfaces with sampling.
const word & name() const
Name of surface.
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.
TypeName("sampledIsoSurfaceSurface")
Runtime type information.
virtual bool expire()
Mark the surface as needing an update.
const label & timeIndex() const
Access the time index.
virtual bool update()
Update the surface as required.
virtual const faceList & faces() const
Faces of surface.
virtual const pointField & points() const
Points of surface.
const labelList & zoneIDs() const
Access the zone indices.
A class for managing temporary objects.
Definition: tmp.H:55
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
#define DEFINE_SAMPLE(Type, nullArg)
Sample field on the surface's faces.
#define DEFINE_INTERPOLATE(Type, nullArg)
Interpolate field to the surface's points.
dictionary dict