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-2025 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 Data
81 
82  //- Field to get threshold
83  const word fieldName_;
84 
85  //- Threshold value
86  const scalar lowerThreshold_;
87 
88  //- Threshold value
89  const scalar upperThreshold_;
90 
91  //- Triangulated faces or keep faces as is
92  bool triangulate_;
93 
94  // Recreated for every time-step
95 
96  //- Time at last call, also track it surface needs an update
97  mutable label prevTimeIndex_;
98 
99  //- For every face the original cell in mesh
100  mutable labelList meshCells_;
101 
102 
103  // Private Member Functions
104 
105  //- Create surface (if time has changed)
106  // Do nothing (and return false) if no update was needed
107  bool updateGeometry() const;
108 
109  //- Sample field on faces
110  template<class Type>
111  tmp<Field<Type>> sampleField
112  (
113  const VolField<Type>& vField
114  ) const;
115 
116 
117  template<class Type>
119  interpolateField(const interpolation<Type>&) const;
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("thresholdCellFaces");
126 
127 
128  // Constructors
129 
130  //- Construct from dictionary
132  (
133  const word& name,
134  const polyMesh&,
135  const dictionary&
136  );
137 
138 
139  //- Destructor
140  virtual ~thresholdCellFaces();
141 
142 
143  // Member Functions
144 
145  //- Return the list of fields required
146  virtual wordList fields() const;
147 
148  //- Does the surface need an update?
149  virtual bool needsUpdate() const;
150 
151  //- Mark the surface as needing an update.
152  // May also free up unneeded data.
153  // Return false if surface was already marked as expired.
154  virtual bool expire();
155 
156  //- Update the surface as required.
157  // Do nothing (and return false) if no update was needed
158  virtual bool update();
159 
160  //- Points of surface
161  virtual const pointField& points() const
162  {
164  }
165 
166  //- Faces of surface
167  virtual const faceList& faces() const
168  {
170  }
171 
172  //- Sample field on surface
173  virtual tmp<scalarField> sample(const volScalarField&) const;
174 
175  //- Sample field on surface
176  virtual tmp<vectorField> sample( const volVectorField&) const;
177 
178  //- Sample field on surface
180  (
182  ) const;
183 
184  //- Sample field on surface
185  virtual tmp<symmTensorField> sample(const volSymmTensorField&) const;
186 
187  //- Sample field on surface
188  virtual tmp<tensorField> sample
189  (
190  const volTensorField&
191  ) const;
192 
193  //- Interpolate field on surface
195  (
196  const interpolation<scalar>&
197  ) const;
198 
199  //- Interpolate field on surface
201  (
202  const interpolation<vector>&
203  ) const;
204 
205  //- Interpolate field on surface
207  (
209  ) const;
210 
211  //- Interpolate field on surface
213  (
215  ) const;
216 
217  //- Interpolate field on surface
219  (
220  const interpolation<tensor>&
221  ) const;
222 
223  //- Write
224  virtual void print(Ostream&) const;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace sampledSurfaces
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #ifdef NoRepository
237 #endif
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for interpolation.
Definition: interpolation.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
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