sampledFaceZone.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) 2020-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::sampledFaceZone
28
29Description
30 A sampledSurface defined by a faceZone or faceZones.
31
32 This is often embedded as part of a sampled surfaces function object.
33
34Usage
35 Example of function object partial specification:
36 \verbatim
37 surfaces
38 {
39 surface1
40 {
41 type faceZones;
42 zones (zone1 "sides.*");
43 }
44 }
45 \endverbatim
46
47 Where the sub-entries comprise:
48 \table
49 Property | Description | Required | Default
50 type | faceZones | yes |
51 zones | zone selection as word/regex list | yes |
52 triangulate | triangulate faces | no | false
53 \endtable
54
55SourceFiles
56 sampledFaceZone.C
57 sampledFaceZoneTemplates.C
58
59\*---------------------------------------------------------------------------*/
60
61#ifndef Foam_sampledFaceZone_H
62#define Foam_sampledFaceZone_H
63
64#include "sampledSurface.H"
65#include "MeshedSurfaces.H"
66
67// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68
69namespace Foam
70{
71
72/*---------------------------------------------------------------------------*\
73 Class sampledFaceZone Declaration
74\*---------------------------------------------------------------------------*/
75
76class sampledFaceZone
77:
78 public meshedSurface,
79 public sampledSurface
80{
81 //- Mesh storage type
82 typedef meshedSurface Mesh;
83
84
85 // Private Data
86
87 //- Selection (word/regex) of face zones
88 const wordRes selectionNames_;
89
90 //- IDs for selected face zones (sorted)
91 mutable labelList zoneIds_;
92
93 //- Triangulated faces or keep faces as is
94 bool triangulate_;
96 //- Track if the surface needs an update
97 mutable bool needsUpdate_;
98
99 //- Local list of face IDs
100 labelList faceId_;
101
102 //- Local list of patch ID per face. Is -1 for internal face
103 labelList facePatchId_;
104
105
106 // Private Member Functions
107
108 //- Sample volume/boundary field onto surface faces
109 template<class Type>
110 tmp<Field<Type>> sampleOnFaces
111 (
112 const interpolation<Type>& sampler
113 ) const;
114
115 //- Sample surface field onto surface faces
116 template<class Type>
117 tmp<Field<Type>> sampleOnFaces
118 (
119 const SurfaceField<Type>& sField
120 ) const;
121
122 //- Interpolate volume/boundary field onto surface points
123 template<class Type>
124 tmp<Field<Type>> sampleOnPoints
125 (
126 const interpolation<Type>& interpolator
127 ) const;
128
129
130 //- Re-map action on triangulation or cleanup
131 virtual void remapFaces(const labelUList& faceMap);
132
133
134protected:
135
136 //- The selected face zones (sorted)
137 const labelList& zoneIDs() const;
138
139
140public:
141
142 //- Runtime type information
143 TypeName("faceZone");
144
145
146 // Constructors
147
148 //- Construct from components
150 (
151 const word& name,
152 const polyMesh& mesh,
153 const UList<wordRe>& zoneNames,
154 const bool triangulate = false
155 );
156
157 //- Construct from dictionary
159 (
160 const word& name,
161 const polyMesh& mesh,
163 );
164
165
166 //- Destructor
167 virtual ~sampledFaceZone() = default;
168
169
170 // Member Functions
171
172 //- Does the surface need an update?
173 virtual bool needsUpdate() const;
174
175 //- Mark the surface as needing an update.
176 // May also free up unneeded data.
177 // Return false if surface was already marked as expired.
178 virtual bool expire();
179
180 //- Update the surface as required.
181 // Do nothing (and return false) if no update was needed
182 virtual bool update();
183
184 //- Points of surface
185 virtual const pointField& points() const
187 return Mesh::points();
188 }
189
190 //- Faces of surface
191 virtual const faceList& faces() const
192 {
193 return Mesh::surfFaces();
194 }
195
196 //- Per-face zone/region information
197 virtual const labelList& zoneIds() const
198 {
199 return labelList::null();
200 }
201
202 //- Face area vectors (normals)
203 virtual const vectorField& Sf() const
205 return Mesh::Sf();
206 }
207
208 //- Face area magnitudes
209 virtual const scalarField& magSf() const
211 return Mesh::magSf();
212 }
213
214 //- Face centres
215 virtual const vectorField& Cf() const
217 return Mesh::Cf();
218 }
219
220
221 // Sample
223 //- Sample volume field onto surface faces
225 (
226 const interpolation<scalar>& sampler
227 ) const;
229 //- Sample volume field onto surface faces
231 (
232 const interpolation<vector>& sampler
233 ) const;
235 //- Sample volume field onto surface faces
237 (
238 const interpolation<sphericalTensor>& sampler
239 ) const;
240
241 //- Sample volume field onto surface faces
243 (
244 const interpolation<symmTensor>& sampler
245 ) const;
246
247 //- Sample volume field onto surface faces
249 (
250 const interpolation<tensor>& sampler
251 ) const;
252
253
254 //- Can it sample surface-fields?
255 virtual bool withSurfaceFields() const;
256
257
258 //- Sample surface field on face zone
260 (
261 const surfaceScalarField&
262 ) const;
263
264 //- Sample surface field on face zone
266 (
267 const surfaceVectorField&
268 ) const;
269
270 //- Sample surface field on face zone
272 (
274 ) const;
275
276 //- Sample surface field on face zone
278 (
280 ) const;
281
282 //- Sample surface field on face zone
284 (
285 const surfaceTensorField&
286 ) const;
287
288
289 // Interpolate
290
291 //- Interpolate volume field onto surface points
293 (
294 const interpolation<scalar>& interpolator
295 ) const;
296
297 //- Interpolate volume field onto surface points
299 (
300 const interpolation<vector>& interpolator
301 ) const;
302
303 //- Interpolate volume field onto surface points
305 (
306 const interpolation<sphericalTensor>& interpolator
307 ) const;
308
309 //- Interpolate volume field onto surface points
311 (
312 const interpolation<symmTensor>& interpolator
313 ) const;
314
315 //- Interpolate volume field onto surface points
317 (
318 const interpolation<tensor>& interpolator
319 ) const;
320
321
322 // Output
323
324 //- Print information
325 virtual void print(Ostream& os, int level=0) const;
326};
327
328
329// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330
331} // End namespace Foam
332
333// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334
335#ifdef NoRepository
337#endif
338
339// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340
341#endif
342
343// ************************************************************************* //
Minimal example by using system/controlDict.functions:
Generic GeometricField class.
static const List< label > & null()
Return a null List.
Definition: ListI.H:109
const vectorField & Sf() const
Face area vectors (normals)
const scalarField & magSf() const
Face area magnitudes.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
const vectorField & Cf() const
Face centres.
const List< face > & surfFaces() 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:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base class for volume field interpolation.
Definition: interpolation.H:60
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A sampledSurface defined by a faceZone or faceZones.
virtual const pointField & points() const
Points of surface.
virtual void print(Ostream &os, int level=0) const
Print information.
virtual const faceList & faces() const
Faces of surface.
virtual const vectorField & Cf() const
Face centres.
virtual const labelList & zoneIds() const
Per-face zone/region information.
virtual const scalarField & magSf() const
Face area magnitudes.
const labelList & zoneIDs() const
The selected face zones (sorted)
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool withSurfaceFields() const
Can it sample surface-fields?
virtual bool update()
Update the surface as required.
virtual const vectorField & Sf() const
Face area vectors (normals)
virtual ~sampledFaceZone()=default
Destructor.
TypeName("faceZone")
Runtime type information.
An abstract class for surfaces with sampling.
const word & name() const noexcept
Name of surface.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
bool interpolate() const noexcept
Same as isPointData()
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
Definition: List.H:66
MeshedSurface< face > meshedSurface
Field< vector > vectorField
Specialisation of Field<T> for vector.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73