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-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 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  //- Optional name of the cellZone
61  const word zoneName_;
62 
63  //- Constructed iso surface
64  mutable autoPtr<cutPolyIsoSurface> isoSurfPtr_;
65 
66  //- Time index at last surface generation
67  mutable label isoSurfTimeIndex_;
68 
69 
70  // Private Member Functions
71 
72  //- Generate the iso surface
73  virtual autoPtr<cutPolyIsoSurface> calcIsoSurf() const = 0;
74 
75  //- Sample field on the surface's faces
76  template<class Type>
77  tmp<Field<Type>> sampleField
78  (
79  const VolField<Type>& vField
80  ) const;
81 
82  //- Interpolate field to the surface's points
83  template<class Type>
84  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
85 
86 
87 protected:
88 
89  // Protected Member Functions
90 
91  //- Access the zoneName
92  inline const word& zoneName() const
93  {
94  return zoneName_;
95  }
96 
97  //- Access the time index
98  inline const label& timeIndex() const
99  {
100  return isoSurfTimeIndex_;
101  }
102 
103 
104 public:
105 
106  //- Runtime type information
107  TypeName("sampledIsoSurfaceSurface");
108 
109 
110  // Constructors
111 
112  //- Construct from dictionary
114  (
115  const word& name,
116  const polyMesh& mesh,
117  const dictionary& dict
118  );
119 
120 
121  //- Destructor
122  virtual ~sampledIsoSurfaceSurface();
123 
124 
125  // Member Functions
126 
127  //- Mark the surface as needing an update.
128  // May also free up unneeded data.
129  // Return false if surface was already marked as expired.
130  virtual bool expire();
131 
132  //- Update the surface as required.
133  // Do nothing (and return false) if no update was needed
134  virtual bool update();
135 
136  //- Update the surface as required.
137  // Do nothing (and return false) if no update was needed
138  virtual bool update() const;
139 
140  //- Points of surface
141  virtual const pointField& points() const
142  {
143  return isoSurfPtr_->points();
144  }
145 
146  //- Faces of surface
147  virtual const faceList& faces() const
148  {
149  return isoSurfPtr_->faces();
150  }
151 
152  //- Sample field on the surface's faces
153  #define DEFINE_SAMPLE(Type, nullArg) \
154  virtual tmp<Field<Type>> sample \
155  ( \
156  const VolField<Type>& \
157  ) const;
159  #undef DEFINE_SAMPLE
160 
161  //- Interpolate field to the surface's points
162  #define DEFINE_INTERPOLATE(Type, nullArg) \
163  virtual tmp<Field<Type>> interpolate \
164  ( \
165  const interpolation<Type>& \
166  ) const;
168  #undef DEFINE_INTERPOLATE
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace sampledSurfaces
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #ifdef NoRepository
181 #endif
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
Generic GeometricField class.
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:162
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 word & zoneName() const
Access the zoneName.
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.
A class for managing temporary objects.
Definition: tmp.H:55
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