sampledThresholdCellFaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::sampledThresholdCellFaces
29 
30 Description
31  A sampledSurface defined by the cell faces corresponding to a threshold
32  value.
33 
34  This is often embedded as part of a sampled surfaces function object.
35 
36 Usage
37  Example of function object partial specification:
38  \verbatim
39  surfaces
40  {
41  surface1
42  {
43  type thresholdCellFaces;
44  field rho;
45  lowerLimit 0.1;
46  }
47  }
48  \endverbatim
49 
50  Where the sub-entries comprise:
51  \table
52  Property | Description | Required | Default
53  type | thresholdCellFaces | yes |
54  field | field name for threshold | yes |
55  lowerLimit | lower limit for threshold | partly | -Inf
56  upperLimit | upper limit for threshold | partly | +Inf
57  triangulate | triangulate faces | no | false
58  \endtable
59 
60 Note
61  Must specify at least one or both of \c lowerLimit or \c upperLimit
62 
63 SeeAlso
64  Foam::thresholdCellFaces
65 
66 SourceFiles
67  sampledThresholdCellFaces.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef sampledThresholdCellFaces_H
72 #define sampledThresholdCellFaces_H
73 
74 #include "sampledSurface.H"
75 #include "MeshedSurface.H"
76 #include "MeshedSurfacesFwd.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class sampledThresholdCellFaces Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class sampledThresholdCellFaces
88 :
89  public sampledSurface,
90  public meshedSurface
91 {
92  // Private typedef for convenience
93  typedef meshedSurface Mesh;
94 
95 
96  // Private Data
97 
98  //- Threshold field
99  const word fieldName_;
100 
101  //- Threshold value
102  const scalar lowerThreshold_;
103 
104  //- Threshold value
105  const scalar upperThreshold_;
106 
107  //- Triangulated faces or keep faces as is
108  bool triangulate_;
109 
110  // Recreated for every time-step
111 
112  //- Time at last call, also track it surface needs an update
113  mutable label prevTimeIndex_;
114 
115  //- For every face the original cell in mesh
116  mutable labelList meshCells_;
117 
118 
119  // Private Member Functions
120 
121  //- Create surface (if time has changed)
122  // Do nothing (and return false) if no update was needed
123  bool updateGeometry() const;
124 
125  //- Sample volume field onto surface faces
126  template<class Type>
127  tmp<Field<Type>> sampleOnFaces
128  (
129  const interpolation<Type>& sampler
130  ) const;
131 
132  //- Interpolate volume field onto surface points
133  template<class Type>
134  tmp<Field<Type>> sampleOnPoints
135  (
136  const interpolation<Type>& interpolator
137  ) const;
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("sampledThresholdCellFaces");
144 
145 
146  // Constructors
147 
148  //- Construct from dictionary
150  (
151  const word& name,
152  const polyMesh&,
153  const dictionary&
154  );
155 
156 
157  //- Destructor
158  virtual ~sampledThresholdCellFaces() = default;
159 
160 
161  // Member Functions
162 
163  //- Does the surface need an update?
164  virtual bool needsUpdate() const;
165 
166  //- Mark the surface as needing an update.
167  // May also free up unneeded data.
168  // Return false if surface was already marked as expired.
169  virtual bool expire();
170 
171  //- Update the surface as required.
172  // Do nothing (and return false) if no update was needed
173  virtual bool update();
174 
175  //- Points of surface
176  virtual const pointField& points() const
177  {
178  return Mesh::points();
179  }
180 
181  //- Faces of surface
182  virtual const faceList& faces() const
183  {
184  return Mesh::surfFaces();
185  }
186 
187  //- Per-face zone/region information
188  virtual const labelList& zoneIds() const
189  {
190  return labelList::null();
191  }
192 
193  //- Face area vectors (normals)
194  virtual const vectorField& Sf() const
195  {
196  return Mesh::Sf();
197  }
198 
199  //- Face area magnitudes
200  virtual const scalarField& magSf() const
201  {
202  return Mesh::magSf();
203  }
204 
205  //- Face centres
206  virtual const vectorField& Cf() const
207  {
208  return Mesh::Cf();
209  }
210 
211 
212  // Sample
213 
214  //- Sample volume field onto surface faces
215  virtual tmp<scalarField> sample
216  (
217  const interpolation<scalar>& sampler
218  ) const;
219 
220  //- Sample volume field onto surface faces
221  virtual tmp<vectorField> sample
222  (
223  const interpolation<vector>& sampler
224  ) const;
225 
226  //- Sample volume field onto surface faces
228  (
230  ) const;
231 
232  //- Sample volume field onto surface faces
234  (
236  ) const;
237 
238  //- Sample volume field onto surface faces
239  virtual tmp<tensorField> sample
240  (
241  const interpolation<tensor>& sampler
242  ) const;
243 
244 
245  // Interpolate
246 
247  //- Interpolate volume field onto surface points
249  (
250  const interpolation<scalar>& interpolator
251  ) const;
252 
253  //- Interpolate volume field onto surface points
255  (
256  const interpolation<vector>& interpolator
257  ) const;
258 
259  //- Interpolate volume field onto surface points
261  (
262  const interpolation<sphericalTensor>& interpolator
263  ) const;
264 
265  //- Interpolate volume field onto surface points
267  (
268  const interpolation<symmTensor>& interpolator
269  ) const;
270 
271  //- Interpolate volume field onto surface points
273  (
274  const interpolation<tensor>& interpolator
275  ) const;
276 
277 
278  // Output
279 
280  //- Print information
281  virtual void print(Ostream& os, int level=0) const;
282 };
283 
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #ifdef NoRepository
293 #endif
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::sampledThresholdCellFaces::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledThresholdCellFaces.H:217
Foam::List::null
static const List< T > & null()
Return a null List.
Definition: ListI.H:109
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::sampledThresholdCellFaces::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledThresholdCellFaces.H:229
Foam::sampledThresholdCellFaces::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledThresholdCellFaces.C:289
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:435
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:413
Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
sampledThresholdCellFaces(const word &name, const polyMesh &, const dictionary &)
Construct from dictionary.
Definition: sampledThresholdCellFaces.C:146
Foam::sampledThresholdCellFaces::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledThresholdCellFaces.C:171
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sampledThresholdCellFaces::update
virtual bool update()
Update the surface as required.
Definition: sampledThresholdCellFaces.C:193
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::sampledThresholdCellFaces::Sf
virtual const vectorField & Sf() const
Face area vectors (normals)
Definition: sampledThresholdCellFaces.H:223
Foam::sampledThresholdCellFaces::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledThresholdCellFaces.C:200
Foam::sampledThresholdCellFaces::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledThresholdCellFaces.C:179
Foam::MeshedSurface< face >::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:441
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::Field< vector >
Foam::sampledThresholdCellFaces::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledThresholdCellFaces.H:235
sampledSurface.H
Foam::sampledThresholdCellFaces::TypeName
TypeName("sampledThresholdCellFaces")
Runtime type information.
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::sampledThresholdCellFaces::~sampledThresholdCellFaces
virtual ~sampledThresholdCellFaces()=default
Destructor.
os
OBJstream os(runTime.globalPath()/outputName)
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::sampledThresholdCellFaces
A sampledSurface defined by the cell faces corresponding to a threshold value.
Definition: sampledThresholdCellFaces.H:116
Foam::List< label >
sampledThresholdCellFacesTemplates.C
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::sampledThresholdCellFaces::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledThresholdCellFaces.H:211
Foam::MeshedSurface< face >::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:447
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
MeshedSurfacesFwd.H
Foam::MeshedSurface< face >
Foam::sampledThresholdCellFaces::points
virtual const pointField & points() const
Points of surface.
Definition: sampledThresholdCellFaces.H:205
MeshedSurface.H