sampledIsoSurface.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) 2011-2019 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::isoSurface
26 
27 Description
28  A sampledSurface defined by a surface of iso value.
29  To be used in sampleSurfaces / functionObjects. Recalculates iso surface
30  only if time changes.
31 
32 SourceFiles
33  sampledIsoSurface.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sampledIsoSurface_H
38 #define sampledIsoSurface_H
39 
40 #include "sampledSurface.H"
41 #include "isoSurface.H"
42 #include "MeshedSurface.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 namespace sampledSurfaces
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class isoSurface Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class isoSurface
56 :
57  public sampledSurface,
58  public MeshedSurface<face>
59 {
60  // Private Data
61 
62  //- Field to get isoSurface of
63  const word isoField_;
64 
65  //- Iso value
66  const scalarField isoVals_;
67 
68  //- Whether to coarsen
69  const Foam::isoSurface::filterType filter_;
70 
71  //- If restricted to zones, name of this zone or a regular expression
72  keyType zoneKey_;
73 
74  // Recreated for every isoSurface
75 
76  //- Time at last call, also track it surface needs an update
77  mutable label prevTimeIndex_;
78 
79  //- For every triangle/face the original cell in mesh
80  mutable labelList meshCells_;
81 
82 
83  // Private Member Functions
84 
85  //- Create iso surface (if time has changed)
86  // Do nothing (and return false) if no update was needed
87  bool updateGeometry() const;
88 
89  //- Sample field on faces
90  template<class Type>
91  tmp<Field<Type>> sampleField
92  (
94  ) const;
95 
96  //- Interpolate field to vertices
97  template<class Type>
99  interpolateField(const interpolation<Type>&) const;
100 
101 
102 public:
103 
104  //- Runtime type information
105  TypeName("isoSurface");
106 
107 
108  // Constructors
109 
110  //- Construct from dictionary
111  isoSurface
112  (
113  const word& name,
114  const polyMesh& mesh,
115  const dictionary& dict
116  );
117 
118 
119  //- Destructor
120  virtual ~isoSurface();
121 
122 
123  // Member Functions
124 
125  //- Does the surface need an update?
126  virtual bool needsUpdate() const;
127 
128  //- Mark the surface as needing an update.
129  // May also free up unneeded data.
130  // Return false if surface was already marked as expired.
131  virtual bool expire();
132 
133  //- Update the surface as required.
134  // Do nothing (and return false) if no update was needed
135  virtual bool update();
136 
137  //- Points of surface
138  virtual const pointField& points() const
139  {
141  }
142 
143  //- Faces of surface
144  virtual const faceList& faces() const
145  {
146  return *this;
147  }
148 
149  //- Sample field on surface
150  virtual tmp<scalarField> sample
151  (
152  const volScalarField&
153  ) const;
154 
155  //- Sample field on surface
156  virtual tmp<vectorField> sample
157  (
158  const volVectorField&
159  ) const;
160 
161  //- Sample field on surface
163  (
165  ) const;
166 
167  //- Sample field on surface
169  (
170  const volSymmTensorField&
171  ) const;
172 
173  //- Sample field on surface
174  virtual tmp<tensorField> sample
175  (
176  const volTensorField&
177  ) const;
178 
179  //- Interpolate field on surface
181  (
182  const interpolation<scalar>&
183  ) const;
184 
185  //- Interpolate field on surface
187  (
188  const interpolation<vector>&
189  ) const;
190 
191  //- Interpolate field on surface
193  (
195  ) const;
196 
197  //- Interpolate field on surface
199  (
201  ) const;
202 
203  //- Interpolate field on surface
205  (
206  const interpolation<tensor>&
207  ) const;
208 
209  //- Write
210  virtual void print(Ostream&) const;
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace sampledSurfaces
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #ifdef NoRepository
223 #endif
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
A class for handling keywords in dictionaries.
Definition: keyType.H:66
dictionary dict
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
virtual void print(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An abstract class for surfaces with sampling.
const word & name() const
Name of surface.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
bool interpolate() const
Interpolation requested for surface.
Generic GeometricField class.
virtual bool needsUpdate() const
Does the surface need an update?
isoSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual bool expire()
Mark the surface as needing an update.
TypeName("isoSurface")
Runtime type information.
virtual const pointField & points() const
Points of surface.
A class for handling words, derived from string.
Definition: word.H:59
const Field< PointType > & points() const
Return reference to global points.
A sampledSurface defined by a surface of iso value. To be used in sampleSurfaces / functionObjects...
const polyMesh & mesh() const
Access to the underlying mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Abstract base class for interpolation.
virtual const faceList & faces() const
Faces of surface.
virtual bool update()
Update the surface as required.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.