Loading...
Searching...
No Matches
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_;
95
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 }
159
160 //- For each face, the patch local face ID
161 const labelList& patchFaceLabels() const
162 {
163 return patchFaceLabels_;
164 }
165
166
167public:
168
169 //- Runtime type information
170 TypeName("sampledPatch");
171
172
173 // Constructors
174
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,
189 const dictionary& dict
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();
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 {
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
232 {
233 return Mesh::Sf();
234 }
235
236 //- Face area magnitudes
237 virtual const scalarField& magSf() const
238 {
239 return Mesh::magSf();
240 }
241
242 //- Face centres
243 virtual const vectorField& Cf() const
244 {
245 return Mesh::Cf();
246 }
247
248
249 // Sample
250
251 //- Sample boundary of volume field onto surface faces
253 (
254 const interpolation<scalar>& sampler
255 ) const;
256
257 //- Sample boundary of volume field onto surface faces
259 (
260 const interpolation<vector>& sampler
261 ) const;
262
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;
281
282 //- Can it sample surface-fields?
283 virtual bool withSurfaceFields() const;
284
285
286 //- Sample boundary of surface field on surface
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
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// ************************************************************************* //
static const List< label > & null() noexcept
Definition List.H:138
const vectorField & Sf() const
const scalarField & magSf() const
virtual label triangulate()
const vectorField & Cf() const
const List< face > & surfFaces() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
const Field< point_type > & points() const noexcept
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
UList(const UList< face > &) noexcept=default
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Abstract base class for volume field interpolation.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A sampledSurface on patches. Non-triangulated by default.
const labelList & patchStart() const
The offset into patchIndex, patchFaceLabels.
virtual const pointField & points() const
Points of surface.
virtual void print(Ostream &os, int level=0) const
Print information.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample boundary of volume field onto surface faces.
const labelList & patchIDs() const
The patches selected.
virtual ~sampledPatch()=default
Destructor.
virtual tmp< tensorField > sample(const surfaceTensorField &) const
Sample boundary of surface field on surface.
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 tmp< symmTensorField > sample(const surfaceSymmTensorField &) const
Sample boundary of surface field on surface.
virtual const scalarField & magSf() const
Face area magnitudes.
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.
const wordRes & patchNames() const
The selection (word/regex) of patches.
const labelList & patchFaceLabels() const
For each face, the patch local face ID.
TypeName("sampledPatch")
Runtime type information.
const labelList & patchIndex() const
For each face, the patch ID.
sampledPatch(const word &name, const polyMesh &mesh, const UList< wordRe > &patchNames, const bool triangulate=false)
Construct from components.
An abstract class for surfaces with sampling.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
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:75
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
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:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
MeshedSurface< face > meshedSurface
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
GeometricField< Type, fvsPatchField, surfaceMesh > SurfaceField
A (volume) surface field for a given type.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68