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-2020 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 isoSurface of
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  (
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  //- Does the surface need an update?
151  virtual bool needsUpdate() const;
152 
153  //- Mark the surface as needing an update.
154  // May also free up unneeded data.
155  // Return false if surface was already marked as expired.
156  virtual bool expire();
157 
158  //- Update the surface as required.
159  // Do nothing (and return false) if no update was needed
160  virtual bool update();
161 
162  //- Points of surface
163  virtual const pointField& points() const
164  {
165  return MeshStorage::points();
166  }
167 
168  //- Faces of surface
169  virtual const faceList& faces() const
170  {
171  return MeshStorage::faces();
172  }
173 
174  //- Sample field on surface
175  virtual tmp<scalarField> sample(const volScalarField&) const;
176 
177  //- Sample field on surface
178  virtual tmp<vectorField> sample( const volVectorField&) const;
179 
180  //- Sample field on surface
182  (
184  ) const;
186  //- Sample field on surface
187  virtual tmp<symmTensorField> sample(const volSymmTensorField&) const;
188 
189  //- Sample field on surface
190  virtual tmp<tensorField> sample
191  (
192  const volTensorField&
193  ) const;
194 
195  //- Interpolate field on surface
197  (
198  const interpolation<scalar>&
199  ) const;
200 
201  //- Interpolate field on surface
203  (
204  const interpolation<vector>&
205  ) const;
206 
207  //- Interpolate field on surface
209  (
211  ) const;
212 
213  //- Interpolate field on surface
215  (
217  ) const;
218 
219  //- Interpolate field on surface
221  (
222  const interpolation<tensor>&
223  ) const;
224 
225  //- Write
226  virtual void print(Ostream&) const;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace sampledSurfaces
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #ifdef NoRepository
239 #endif
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
virtual bool update()
Update the surface as required.
thresholdCellFaces(const word &name, const polyMesh &, const dictionary &)
Construct from dictionary.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Name of surface.
bool interpolate() const
Interpolation requested for surface.
Generic GeometricField class.
virtual bool needsUpdate() const
Does the surface need an update?
TypeName("thresholdCellFaces")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:59
const Field< PointType > & points() const
Return reference to global points.
virtual const faceList & faces() const
Faces of surface.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual const pointField & points() const
Points of surface.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
const List< face > & faces() const
Return const access to the faces.
virtual bool expire()
Mark the surface as needing an update.
Abstract base class for interpolation.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void print(Ostream &) const
Write.
Namespace for OpenFOAM.