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-2021 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  Example:
32  \verbatim
33  {
34  type cuttingPlane;
35  planeType pointAndNormal;
36  point (0 0 0);
37  normal (0 0 1);
38  filtering full;
39  interpolate yes;
40  }
41  \endverbatim
42 
43 Usage
44  \table
45  Property | Description | Required | Default value
46  planeType | the method of specification of the plane | yes |
47  filtering | the level of filtering to perform on the iso-surface \\
48  | no | full
49  interpolate | interpolate values to the surface points | no | no
50  \endtable
51 
52 See also
53  Foam::plane
54  Foam::isoSurface
55 
56 SourceFiles
57  sampledCuttingPlane.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef sampledCuttingPlane_H
62 #define sampledCuttingPlane_H
63 
64 #include "sampledSurface.H"
65 #include "isoSurface.H"
66 #include "fvMeshSubset.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 namespace sampledSurfaces
73 {
74 
75 /*---------------------------------------------------------------------------*\
76  Class cuttingPlane Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class cuttingPlane
80 :
81  public sampledSurface
82 {
83  // Private Data
84 
85  //- Plane
86  const plane plane_;
87 
88  //- Whether to coarsen
89  const isoSurface::filterType filter_;
90 
91  //- Whether to recalculate cell values as average of point values
92  const Switch average_;
93 
94  //- If restricted to zones, name of this zone or a regular expression
95  wordRe zoneKey_;
96 
97  //- For zones: patch to put exposed faces into
98  mutable word exposedPatchName_;
99 
100  //- Track if the surface needs an update
101  mutable bool needsUpdate_;
102 
103  //- Optional subsetted mesh
104  autoPtr<fvMeshSubset> subMeshPtr_;
105 
106  //- Distance to cell centres
107  autoPtr<volScalarField> cellDistancePtr_;
108 
109  //- Distance to points
110  scalarField pointDistance_;
111 
112  //- Constructed iso surface
113  autoPtr<isoSurface> isoSurfPtr_;
114 
115  //- Triangles converted to faceList
116  mutable autoPtr<faceList> facesPtr_;
117 
118 
119  // Private Member Functions
120 
121  //- Create iso surface
122  void createGeometry();
123 
124  //- Sample field on faces
125  template<class Type>
126  tmp<Field<Type>> sampleField
127  (
129  ) const;
130 
131 
132  template<class Type>
134  interpolateField(const interpolation<Type>&) const;
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("cuttingPlane");
141 
142 
143  // Constructors
144 
145  //- Construct from dictionary
147  (
148  const word& name,
149  const polyMesh& mesh,
150  const dictionary& dict
151  );
152 
153 
154  //- Destructor
155  virtual ~cuttingPlane();
156 
157 
158  // Member Functions
159 
160  //- Does the surface need an update?
161  virtual bool needsUpdate() const;
162 
163  //- Mark the surface as needing an update.
164  // May also free up unneeded data.
165  // Return false if surface was already marked as expired.
166  virtual bool expire();
167 
168  //- Update the surface as required.
169  // Do nothing (and return false) if no update was needed
170  virtual bool update();
171 
172  //- Points of surface
173  virtual const pointField& points() const
174  {
175  return surface().points();
176  }
177 
178  //- Faces of surface
179  virtual const faceList& faces() const
180  {
181  return surface().faces();
182  }
183 
184  const isoSurface& surface() const
185  {
186  return isoSurfPtr_();
187  }
188 
189  //- Sample field on surface
190  virtual tmp<scalarField> sample
191  (
192  const volScalarField&
193  ) const;
194 
195  //- Sample field on surface
196  virtual tmp<vectorField> sample
197  (
198  const volVectorField&
199  ) const;
200 
201  //- Sample field on surface
203  (
205  ) const;
206 
207  //- Sample field on surface
209  (
210  const volSymmTensorField&
211  ) const;
212 
213  //- Sample field on surface
214  virtual tmp<tensorField> sample
215  (
216  const volTensorField&
217  ) const;
218 
219 
220  //- Interpolate field on surface
222  (
223  const interpolation<scalar>&
224  ) const;
225 
226  //- Interpolate field on surface
228  (
229  const interpolation<vector>&
230  ) const;
231 
232  //- Interpolate field on surface
234  (
236  ) const;
237 
238  //- Interpolate field on surface
240  (
242  ) const;
243 
244  //- Interpolate field on surface
246  (
247  const interpolation<tensor>&
248  ) const;
249 
250  //- Write
251  virtual void print(Ostream&) const;
252 };
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace sampledSurfaces
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #ifdef NoRepository
264 #endif
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
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:156
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.
Generic GeometricField class.
TypeName("cuttingPlane")
Runtime type information.
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.
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:76
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
virtual bool expire()
Mark the surface as needing an update.