sampledThresholdCellFaces.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-2022 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::thresholdCellFaces
26 
27 Description
28  A sampledSurface defined by the cell faces corresponding to a threshold
29  value.
30 
31  Example:
32  \verbatim
33  {
34  type thresholdCellFaces;
35  field p;
36  lowerLimit 5;
37  upperLimit 10;
38  interpolate yes;
39  }
40  \endverbatim
41 
42 Usage
43  \table
44  Property | Description | Required | Default value
45  field | the field to threshold | yes |
46  lowerLimit | the limit below which cells are omitted \\
47  | if no upperLimit | -vGreat
48  upperLimit | the limit above which cells are omitted \\
49  | if no lowerLimit | +vGreat
50  interpolate | interpolate values to the surface points | no | no
51  \endtable
52 
53 SourceFiles
54  sampledThresholdCellFaces.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef sampledThresholdCellFaces_H
59 #define sampledThresholdCellFaces_H
60 
61 #include "sampledSurface.H"
62 #include "MeshedSurface.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace sampledSurfaces
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class thresholdCellFaces Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class thresholdCellFaces
76 :
77  public sampledSurface,
78  public MeshedSurface<face>
79 {
80  // Private Typedefs
81 
82  typedef MeshedSurface<face> MeshStorage;
83 
84 
85  // Private Data
86 
87  //- Field to get threshold
88  const word fieldName_;
89 
90  //- Threshold value
91  const scalar lowerThreshold_;
92 
93  //- Threshold value
94  const scalar upperThreshold_;
95 
96  //- Triangulated faces or keep faces as is
97  bool triangulate_;
98 
99  // Recreated for every time-step
100 
101  //- Time at last call, also track it surface needs an update
102  mutable label prevTimeIndex_;
103 
104  //- For every face the original cell in mesh
105  mutable labelList meshCells_;
106 
107 
108  // Private Member Functions
109 
110  //- Create surface (if time has changed)
111  // Do nothing (and return false) if no update was needed
112  bool updateGeometry() const;
113 
114  //- Sample field on faces
115  template<class Type>
116  tmp<Field<Type>> sampleField
117  (
118  const VolField<Type>& vField
119  ) const;
120 
121 
122  template<class Type>
124  interpolateField(const interpolation<Type>&) const;
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("thresholdCellFaces");
131 
132 
133  // Constructors
134 
135  //- Construct from dictionary
137  (
138  const word& name,
139  const polyMesh&,
140  const dictionary&
141  );
142 
143 
144  //- Destructor
145  virtual ~thresholdCellFaces();
146 
147 
148  // Member Functions
149 
150  //- Return the list of fields required
151  virtual wordList fields() const;
152 
153  //- Does the surface need an update?
154  virtual bool needsUpdate() const;
155 
156  //- Mark the surface as needing an update.
157  // May also free up unneeded data.
158  // Return false if surface was already marked as expired.
159  virtual bool expire();
160 
161  //- Update the surface as required.
162  // Do nothing (and return false) if no update was needed
163  virtual bool update();
164 
165  //- Points of surface
166  virtual const pointField& points() const
167  {
168  return MeshStorage::points();
169  }
170 
171  //- Faces of surface
172  virtual const faceList& faces() const
173  {
174  return MeshStorage::faces();
175  }
176 
177  //- Sample field on surface
178  virtual tmp<scalarField> sample(const volScalarField&) const;
179 
180  //- Sample field on surface
181  virtual tmp<vectorField> sample( const volVectorField&) const;
182 
183  //- Sample field on surface
185  (
187  ) const;
188 
189  //- Sample field on surface
190  virtual tmp<symmTensorField> sample(const volSymmTensorField&) const;
191 
192  //- Sample field on surface
193  virtual tmp<tensorField> sample
194  (
195  const volTensorField&
196  ) const;
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 // ************************************************************************* //
Generic GeometricField class.
const List< face > & faces() const
Return const access to the faces.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const Field< PointType > & points() const
Return reference to global points.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base class for interpolation.
Definition: interpolation.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
bool interpolate() const
Interpolation requested for surface.
const word & name() const
Name of surface.
TypeName("thresholdCellFaces")
Runtime type information.
thresholdCellFaces(const word &name, const polyMesh &, const dictionary &)
Construct from dictionary.
virtual wordList fields() const
Return the list of fields required.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool update()
Update the surface as required.
virtual void print(Ostream &) const
Write.
virtual const faceList & faces() const
Faces of surface.
virtual const pointField & points() const
Points of surface.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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