sampledPatch.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::sampledPatch
29
30Description
31 A sampledSurface on patches. Non-triangulated by default.
32
33 This is often embedded as part of a sampled surfaces function object.
34
35Usage
36 Example of function object partial specification:
37 \verbatim
38 surfaces
39 {
40 surface1
41 {
42 type patch;
43 patches (inlet "outlet.*");
44 }
45 }
46 \endverbatim
47
48 Where the sub-entries comprise:
49 \table
50 Property | Description | Required | Default
51 type | patch | yes |
52 patches | patch selection as word/regex list | yes |
53 triangulate | triangulate faces | no | false
54 \endtable
55
56SourceFiles
57 sampledPatch.C
58
59\*---------------------------------------------------------------------------*/
60
61#ifndef Foam_sampledPatch_H
62#define Foam_sampledPatch_H
63
64#include "sampledSurface.H"
65#include "MeshedSurfaces.H"
66
67// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68
69namespace Foam
70{
71
72/*---------------------------------------------------------------------------*\
73 Class sampledPatch Declaration
74\*---------------------------------------------------------------------------*/
75
76class sampledPatch
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 patches
88 const wordRes selectionNames_;
89
90 //- The IDs for selected patches. Sorted and no emptyPolyPatch
91 mutable labelList patchIDs_;
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 //- Start indices (in patchFaceLabels_) of patches
100 labelList patchStart_;
101
102 //- For every face (or triangle) the originating patch
103 labelList patchIndex_;
104
105 //- For every face (or triangle) the index in the originating patch
106 labelList patchFaceLabels_;
107
108
109 // Private Member Functions
110
111 //- Sample boundary field (from volume field) onto surface faces
112 template<class Type>
113 tmp<Field<Type>> sampleOnFaces
114 (
115 const interpolation<Type>& sampler
116 ) const;
117
118 //- Sample boundary field (from surface field) onto surface faces
119 template<class Type>
120 tmp<Field<Type>> sampleOnFaces
121 (
122 const SurfaceField<Type>& sField
123 ) const;
124
125 //- Interpolate boundary field (from volume field) onto surface points
126 template<class Type>
127 tmp<Field<Type>> sampleOnPoints
128 (
129 const interpolation<Type>& interpolator
130 ) const;
131
132
133 //- Re-map action on triangulation or cleanup
134 virtual void remapFaces(const labelUList& faceMap);
135
136
137protected:
138
139 //- The selection (word/regex) of patches
140 const wordRes& patchNames() const
141 {
142 return selectionNames_;
143 }
144
145 //- The patches selected
146 const labelList& patchIDs() const;
147
148 //- The offset into patchIndex, patchFaceLabels
149 const labelList& patchStart() const
150 {
151 return patchStart_;
152 }
153
154 //- For each face, the patch ID
155 const labelList& patchIndex() const
156 {
157 return patchIndex_;
158 }
160 //- For each face, the patch local face ID
161 const labelList& patchFaceLabels() const
162 {
163 return patchFaceLabels_;
164 }
165
166
167public:
169 //- Runtime type information
170 TypeName("sampledPatch");
171
172
173 // Constructors
175 //- Construct from components
177 (
178 const word& name,
179 const polyMesh& mesh,
181 const bool triangulate = false
182 );
183
184 //- Construct from dictionary
186 (
187 const word& name,
188 const polyMesh& mesh,
190 );
191
192
193 //- Destructor
194 virtual ~sampledPatch() = default;
195
196
197 // Member Functions
198
199 //- Does the surface need an update?
200 virtual bool needsUpdate() const;
201
202 //- Mark the surface as needing an update.
203 // May also free up unneeded data.
204 // Return false if surface was already marked as expired.
205 virtual bool expire();
206
207 //- Update the surface as required.
208 // Do nothing (and return false) if no update was needed
209 virtual bool update();
210
211
212 //- Points of surface
213 virtual const pointField& points() const
214 {
215 return Mesh::points();
216 }
217
218 //- Faces of surface
219 virtual const faceList& faces() const
220 {
221 return Mesh::surfFaces();
222 }
223
224 //- Per-face zone/region information
225 virtual const labelList& zoneIds() const
226 {
227 return labelList::null();
228 }
229
230 //- Face area vectors
231 virtual const vectorField& Sf() const
233 return Mesh::Sf();
234 }
235
236 //- Face area magnitudes
237 virtual const scalarField& magSf() const
239 return Mesh::magSf();
240 }
241
242 //- Face centres
243 virtual const vectorField& Cf() const
245 return Mesh::Cf();
246 }
247
248
249 // Sample
251 //- Sample boundary of volume field onto surface faces
253 (
254 const interpolation<scalar>& sampler
255 ) const;
257 //- Sample boundary of volume field onto surface faces
259 (
260 const interpolation<vector>& sampler
261 ) const;
263 //- Sample boundary of volume field onto surface faces
265 (
266 const interpolation<sphericalTensor>& sampler
267 ) const;
268
269 //- Sample boundary of volume field onto surface faces
271 (
272 const interpolation<symmTensor>& sampler
273 ) const;
274
275 //- Sample boundary of volume field onto surface faces
277 (
278 const interpolation<tensor>& sampler
279 ) const;
280
281
282 //- Can it sample surface-fields?
283 virtual bool withSurfaceFields() const;
284
285
286 //- Sample boundary of surface field on surface
288 (
289 const surfaceScalarField&
290 ) const;
291
292 //- Sample boundary of surface field on surface
294 (
295 const surfaceVectorField&
296 ) const;
297
298 //- Sample boundary of surface field on surface
300 (
302 ) const;
303
304 //- Sample boundary of surface field on surface
306 (
308 ) const;
309
310 //- Sample boundary of surface field on surface
312 (
313 const surfaceTensorField&
314 ) const;
315
316
317 // Interpolate
318
319 //- Interpolate boundary of volume field onto surface points
321 (
322 const interpolation<scalar>& interpolator
323 ) const;
324
325 //- Interpolate boundary of volume field onto surface points
327 (
328 const interpolation<vector>& interpolator
329 ) const;
330
331 //- Interpolate boundary of volume field onto surface points
333 (
334 const interpolation<sphericalTensor>& interpolator
335 ) const;
336
337 //- Interpolate boundary of volume field onto surface points
339 (
340 const interpolation<symmTensor>& interpolator
341 ) const;
342
343 //- Interpolate boundary of volume field onto surface points
345 (
346 const interpolation<tensor>& interpolator
347 ) const;
348
349
350 // Output
351
352 //- Print information
353 virtual void print(Ostream& os, int level=0) const;
354};
355
356
357// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358
359} // End namespace Foam
360
361// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362
363#ifdef NoRepository
364 #include "sampledPatchTemplates.C"
365#endif
366
367// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368
369#endif
370
371// ************************************************************************* //
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 on patches. Non-triangulated by default.
Definition: sampledPatch.H:99
const labelList & patchStart() const
The offset into patchIndex, patchFaceLabels.
Definition: sampledPatch.H:168
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:232
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledPatch.C:417
const labelList & patchIDs() const
The patches selected.
Definition: sampledPatch.C:81
virtual ~sampledPatch()=default
Destructor.
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:238
virtual const vectorField & Cf() const
Face centres.
Definition: sampledPatch.H:262
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledPatch.H:244
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledPatch.H:256
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:152
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:146
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledPatch.C:321
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:174
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledPatch.H:250
const wordRes & patchNames() const
The selection (word/regex) of patches.
Definition: sampledPatch.H:159
const labelList & patchFaceLabels() const
For each face, the patch local face ID.
Definition: sampledPatch.H:180
TypeName("sampledPatch")
Runtime type information.
const labelList & patchIndex() const
For each face, the patch ID.
Definition: sampledPatch.H:174
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