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 "MeshedSurface.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace sampledSurfaces
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class isoSurface Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class isoSurface
55 :
56  public sampledSurface,
57  public MeshedSurface<face>
58 {
59  // Private Data
60 
61  //- Field to get isoSurface of
62  const word isoField_;
63 
64  //- Iso value
65  const scalarField isoVals_;
66 
67  //- Whether to coarsen
68  const Switch regularise_;
69 
70  //- If restricted to zones, name of this zone or a regular expression
71  keyType zoneKey_;
72 
73  // Recreated for every isoSurface
74 
75  //- Time at last call, also track it surface needs an update
76  mutable label prevTimeIndex_;
77 
78  //- For every triangle/face the original cell in mesh
79  mutable labelList meshCells_;
80 
81 
82  // Private Member Functions
83 
84  //- Create iso surface (if time has changed)
85  // Do nothing (and return false) if no update was needed
86  bool updateGeometry() const;
87 
88  //- Sample field on faces
89  template<class Type>
90  tmp<Field<Type>> sampleField
91  (
93  ) const;
94 
95  //- Interpolate field to vertices
96  template<class Type>
98  interpolateField(const interpolation<Type>&) const;
99 
100 
101 public:
102 
103  //- Runtime type information
104  TypeName("isoSurface");
105 
106 
107  // Constructors
108 
109  //- Construct from dictionary
110  isoSurface
111  (
112  const word& name,
113  const polyMesh& mesh,
114  const dictionary& dict
115  );
116 
117 
118  //- Destructor
119  virtual ~isoSurface();
120 
121 
122  // Member Functions
123 
124  //- Does the surface need an update?
125  virtual bool needsUpdate() const;
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  //- Points of surface
137  virtual const pointField& points() const
138  {
140  }
141 
142  //- Faces of surface
143  virtual const faceList& faces() const
144  {
145  return *this;
146  }
147 
148  //- Sample field on surface
149  virtual tmp<scalarField> sample
150  (
151  const volScalarField&
152  ) const;
153 
154  //- Sample field on surface
155  virtual tmp<vectorField> sample
156  (
157  const volVectorField&
158  ) const;
159 
160  //- Sample field on surface
162  (
164  ) const;
165 
166  //- Sample field on surface
168  (
169  const volSymmTensorField&
170  ) const;
171 
172  //- Sample field on surface
173  virtual tmp<tensorField> sample
174  (
175  const volTensorField&
176  ) const;
177 
178  //- Interpolate field on surface
180  (
181  const interpolation<scalar>&
182  ) const;
183 
184  //- Interpolate field on surface
186  (
187  const interpolation<vector>&
188  ) const;
189 
190  //- Interpolate field on surface
192  (
194  ) const;
195 
196  //- Interpolate field on surface
198  (
200  ) const;
201 
202  //- Interpolate field on surface
204  (
205  const interpolation<tensor>&
206  ) const;
207 
208  //- Write
209  virtual void print(Ostream&) const;
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace sampledSurfaces
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
A class for handling keywords in dictionaries.
Definition: keyType.H:64
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.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
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:53
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.