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-2019 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 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class sampledThresholdCellFaces Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class sampledThresholdCellFaces
87 :
88  public sampledSurface,
89  public MeshedSurface<face>
90 {
91  //- Private typedefs for convenience
92  typedef MeshedSurface<face> MeshStorage;
93 
94  // Private data
95 
96  //- Threshold field
97  const word fieldName_;
98 
99  //- Threshold value
100  const scalar lowerThreshold_;
101 
102  //- Threshold value
103  const scalar upperThreshold_;
104 
105  //- Triangulated faces or keep faces as is
106  bool triangulate_;
107 
108  // Recreated for every time-step
109 
110  //- Time at last call, also track it surface needs an update
111  mutable label prevTimeIndex_;
112 
113  //- For every face the original cell in mesh
114  mutable labelList meshCells_;
115 
116 
117  // Private Member Functions
118 
119  //- Create surface (if time has changed)
120  // Do nothing (and return false) if no update was needed
121  bool updateGeometry() const;
122 
123  //- Sample volume field onto surface faces
124  template<class Type>
125  tmp<Field<Type>> sampleOnFaces
126  (
127  const interpolation<Type>& sampler
128  ) const;
129 
130  //- Interpolate volume field onto surface points
131  template<class Type>
132  tmp<Field<Type>> sampleOnPoints
133  (
134  const interpolation<Type>& interpolator
135  ) const;
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("sampledThresholdCellFaces");
142 
143 
144  // Constructors
145 
146  //- Construct from dictionary
148  (
149  const word& name,
150  const polyMesh&,
151  const dictionary&
152  );
153 
154 
155  //- Destructor
156  virtual ~sampledThresholdCellFaces() = default;
157 
158 
159  // Member Functions
160 
161  //- Does the surface need an update?
162  virtual bool needsUpdate() const;
163 
164  //- Mark the surface as needing an update.
165  // May also free up unneeded data.
166  // Return false if surface was already marked as expired.
167  virtual bool expire();
168 
169  //- Update the surface as required.
170  // Do nothing (and return false) if no update was needed
171  virtual bool update();
172 
173  //- Points of surface
174  virtual const pointField& points() const
175  {
176  return MeshStorage::points();
177  }
178 
179  //- Faces of surface
180  virtual const faceList& faces() const
181  {
182  return MeshStorage::surfFaces();
183  }
184 
185  //- Per-face zone/region information
186  virtual const labelList& zoneIds() const
187  {
188  return labelList::null();
189  }
190 
191  //- Face area vectors (normals)
192  virtual const vectorField& Sf() const
193  {
194  return MeshStorage::Sf();
195  }
196 
197  //- Face area magnitudes
198  virtual const scalarField& magSf() const
199  {
200  return MeshStorage::magSf();
201  }
202 
203  //- Face centres
204  virtual const vectorField& Cf() const
205  {
206  return MeshStorage::Cf();
207  }
208 
209 
210  // Sample
211 
212  //- Sample volume field onto surface faces
213  virtual tmp<scalarField> sample
214  (
215  const interpolation<scalar>& sampler
216  ) const;
217 
218  //- Sample volume field onto surface faces
219  virtual tmp<vectorField> sample
220  (
221  const interpolation<vector>& sampler
222  ) const;
223 
224  //- Sample volume field onto surface faces
226  (
228  ) const;
229 
230  //- Sample volume field onto surface faces
232  (
234  ) const;
235 
236  //- Sample volume field onto surface faces
237  virtual tmp<tensorField> sample
238  (
239  const interpolation<tensor>& sampler
240  ) const;
241 
242 
243  // Interpolate
244 
245  //- Interpolate volume field onto surface points
247  (
248  const interpolation<scalar>& interpolator
249  ) const;
250 
251  //- Interpolate volume field onto surface points
253  (
254  const interpolation<vector>& interpolator
255  ) const;
256 
257  //- Interpolate volume field onto surface points
259  (
260  const interpolation<sphericalTensor>& interpolator
261  ) const;
262 
263  //- Interpolate volume field onto surface points
265  (
266  const interpolation<symmTensor>& interpolator
267  ) const;
268 
269  //- Interpolate volume field onto surface points
271  (
272  const interpolation<tensor>& interpolator
273  ) const;
274 
275 
276  // Output
277 
278  //- Print information
279  virtual void print(Ostream& os) const;
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #ifdef NoRepository
291 #endif
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
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:215
Foam::List< label >::null
static const List< label > & null()
Return a null List.
Definition: ListI.H:108
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::sampledThresholdCellFaces::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledThresholdCellFaces.H:227
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:433
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:411
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:221
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:439
Foam::sampledThresholdCellFaces::print
virtual void print(Ostream &os) const
Print information.
Definition: sampledThresholdCellFaces.C:289
Foam::Field< vector >
Foam::sampledThresholdCellFaces::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledThresholdCellFaces.H:233
sampledSurface.H
Foam::sampledThresholdCellFaces::TypeName
TypeName("sampledThresholdCellFaces")
Runtime type information.
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::sampledThresholdCellFaces::~sampledThresholdCellFaces
virtual ~sampledThresholdCellFaces()=default
Destructor.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledThresholdCellFaces
A sampledSurface defined by the cell faces corresponding to a threshold value.
Definition: sampledThresholdCellFaces.H:115
Foam::List< label >
sampledThresholdCellFacesTemplates.C
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:308
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::sampledThresholdCellFaces::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledThresholdCellFaces.H:209
Foam::MeshedSurface< face >::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:445
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::MeshedSurface
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: triSurfaceTools.H:80
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:326
Foam::sampledThresholdCellFaces::points
virtual const pointField & points() const
Points of surface.
Definition: sampledThresholdCellFaces.H:203
MeshedSurface.H