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-2026 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  //- Time at last call, also track it surface needs an update
95  mutable label prevTimeIndex_;
96 
97  //- For every face the original cell in mesh
98  mutable labelList meshCells_;
99 
100 
101  // Private Member Functions
102 
103  //- Create surface (if time has changed)
104  // Do nothing (and return false) if no update was needed
105  bool updateGeometry() const;
106 
107  //- Sample field on faces
108  template<class Type>
109  tmp<Field<Type>> sampleField
110  (
111  const VolField<Type>& vField
112  ) const;
113 
114 
115  template<class Type>
117  interpolateField(const interpolation<Type>&) const;
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("thresholdCellFaces");
124 
125 
126  // Constructors
127 
128  //- Construct from dictionary
130  (
131  const word& name,
132  const polyMesh&,
133  const dictionary&
134  );
135 
136 
137  //- Destructor
138  virtual ~thresholdCellFaces();
139 
140 
141  // Member Functions
142 
143  //- Return the list of fields required
144  virtual wordList fields() const;
145 
146  //- Does the surface need an update?
147  virtual bool needsUpdate() const;
148 
149  //- Update the surface as required.
150  // Do nothing (and return false) if no update was needed
151  virtual bool update();
152 
153  //- Points of surface
154  virtual const pointField& points() const
155  {
157  }
158 
159  //- Faces of surface
160  virtual const faceList& faces() const
161  {
163  }
164 
165  //- Sample field on the surface's faces
166  #define DEFINE_SAMPLE(Type, nullArg) \
167  virtual tmp<Field<Type>> sample \
168  ( \
169  const VolField<Type>& \
170  ) const;
172  #undef DEFINE_SAMPLE
173 
174  //- Interpolate field to the surface's points
175  #define DEFINE_INTERPOLATE(Type, nullArg) \
176  virtual tmp<Field<Type>> interpolate \
177  ( \
178  const interpolation<Type>& \
179  ) const;
181  #undef DEFINE_INTERPOLATE
182 
183  //- Update for mesh point-motion
184  virtual void movePoints();
185 
186  //- Update topology using the given map
187  virtual void topoChange(const polyTopoChangeMap&);
188 
189  //- Update from another mesh using the given map
190  virtual void mapMesh(const polyMeshMap&);
191 
192  //- Redistribute or update using the given distribution map
193  virtual void distribute(const polyDistributionMap&);
194 
195  //- Write
196  virtual void print(Ostream&) const;
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace sampledSurfaces
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #ifdef NoRepository
209 #endif
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
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.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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 void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void movePoints()
Update for mesh point-motion.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
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:63
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
#define DEFINE_SAMPLE(Type, nullArg)
Sample field on the surface's faces.
#define DEFINE_INTERPOLATE(Type, nullArg)
Interpolate field to the surface's points.