All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sampledCuttingPlane.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::cuttingPlane
26 
27 Description
28  A sampledSurface defined by a plane using the iso-surface algorithm
29  to 'cut' the mesh.
30 
31 SourceFiles
32  sampledCuttingPlane.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef sampledCuttingPlane_H
37 #define sampledCuttingPlane_H
38 
39 #include "sampledSurface.H"
40 #include "isoSurface.H"
41 #include "plane.H"
42 #include "ZoneIDs.H"
43 #include "fvMeshSubset.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace sampledSurfaces
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class cuttingPlane Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class cuttingPlane
57 :
58  public sampledSurface
59 {
60  // Private Data
61 
62  //- Plane
63  const plane plane_;
64 
65  //- Whether to coarsen
66  const isoSurface::filterType filter_;
67 
68  //- Whether to recalculate cell values as average of point values
69  const Switch average_;
70 
71  //- Zone name/index (if restricted to zones)
72  mutable cellZoneID zoneID_;
73 
74  //- For zones: patch to put exposed faces into
75  mutable word exposedPatchName_;
76 
77  //- Track if the surface needs an update
78  mutable bool needsUpdate_;
79 
80 
81  //- Optional subsetted mesh
82  autoPtr<fvMeshSubset> subMeshPtr_;
83 
84  //- Distance to cell centres
85  autoPtr<volScalarField> cellDistancePtr_;
86 
87  //- Distance to points
88  scalarField pointDistance_;
89 
90  //- Constructed iso surface
91  autoPtr<isoSurface> isoSurfPtr_;
92 
93  //- Triangles converted to faceList
94  mutable autoPtr<faceList> facesPtr_;
95 
96 
97  // Private Member Functions
98 
99  //- Create iso surface
100  void createGeometry();
101 
102  //- Sample field on faces
103  template<class Type>
104  tmp<Field<Type>> sampleField
105  (
107  ) const;
108 
109 
110  template<class Type>
112  interpolateField(const interpolation<Type>&) const;
113 
114 
115 public:
116 
117  //- Runtime type information
118  TypeName("cuttingPlane");
119 
120 
121  // Constructors
122 
123  //- Construct from dictionary
125  (
126  const word& name,
127  const polyMesh& mesh,
128  const dictionary& dict
129  );
130 
131 
132  //- Destructor
133  virtual ~cuttingPlane();
134 
135 
136  // Member Functions
137 
138  //- Does the surface need an update?
139  virtual bool needsUpdate() const;
140 
141  //- Mark the surface as needing an update.
142  // May also free up unneeded data.
143  // Return false if surface was already marked as expired.
144  virtual bool expire();
145 
146  //- Update the surface as required.
147  // Do nothing (and return false) if no update was needed
148  virtual bool update();
149 
150  //- Points of surface
151  virtual const pointField& points() const
152  {
153  return surface().points();
154  }
155 
156  //- Faces of surface
157  virtual const faceList& faces() const
158  {
159  return surface().faces();
160  }
162  const isoSurface& surface() const
163  {
164  return isoSurfPtr_();
165  }
166 
167  //- Sample field on surface
168  virtual tmp<scalarField> sample
169  (
170  const volScalarField&
171  ) const;
172 
173  //- Sample field on surface
174  virtual tmp<vectorField> sample
175  (
176  const volVectorField&
177  ) const;
178 
179  //- Sample field on surface
181  (
183  ) const;
184 
185  //- Sample field on surface
187  (
188  const volSymmTensorField&
189  ) const;
190 
191  //- Sample field on surface
192  virtual tmp<tensorField> sample
193  (
194  const volTensorField&
195  ) const;
196 
197 
198  //- Interpolate field on surface
200  (
201  const interpolation<scalar>&
202  ) const;
203 
204  //- Interpolate field on surface
206  (
207  const interpolation<vector>&
208  ) const;
209 
210  //- Interpolate field on surface
212  (
214  ) const;
215 
216  //- Interpolate field on surface
218  (
220  ) const;
221 
222  //- Interpolate field on surface
224  (
225  const interpolation<tensor>&
226  ) const;
227 
228  //- Write
229  virtual void print(Ostream&) const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace sampledSurfaces
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #ifdef NoRepository
242 #endif
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
A sampledSurface defined by a plane which &#39;cuts&#39; the mesh using the cuttingPlane algorithm. The plane is triangulated by default.
Definition: sampledPlane.H:55
dictionary dict
virtual const faceList & faces() const
Faces of surface.
cuttingPlane(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
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.
virtual void print(Ostream &) const
Write.
const word & name() const
Name of surface.
virtual bool update()
Update the surface as required.
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.
TypeName("cuttingPlane")
Runtime type information.
A sampledSurface defined by a plane using the iso-surface algorithm to &#39;cut&#39; the mesh.
const isoSurface & surface() const
virtual const pointField & points() const
Points of surface.
A class for handling words, derived from string.
Definition: word.H:59
virtual const pointField & points() const
Points of surface.
A sampledSurface defined by a surface of iso value. To be used in sampleSurfaces / functionObjects...
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
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
virtual bool needsUpdate() const
Does the surface need an update?
Abstract base class for interpolation.
virtual const faceList & faces() const
Faces of surface.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
virtual bool expire()
Mark the surface as needing an update.