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-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::sampledPatch
29 
30 Description
31  A sampledSurface on patches. Non-triangulated by default.
32 
33  This is often embedded as part of a sampled surfaces function object.
34 
35 Usage
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 
56 SourceFiles
57  sampledPatch.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef sampledPatch_H
62 #define sampledPatch_H
63 
64 #include "sampledSurface.H"
65 #include "MeshedSurfaces.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class sampledPatch Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class 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  (
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 
137 protected:
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 
167 public:
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();
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
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
252  virtual tmp<scalarField> sample
253  (
254  const interpolation<scalar>& sampler
255  ) const;
256 
257  //- Sample boundary of volume field onto surface faces
258  virtual tmp<vectorField> sample
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
276  virtual tmp<tensorField> sample
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
287  virtual tmp<scalarField> sample
288  (
289  const surfaceScalarField&
290  ) const;
291 
292  //- Sample boundary of surface field on surface
293  virtual tmp<vectorField> sample
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
311  virtual tmp<tensorField> sample
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 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::sampledPatch::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:146
Foam::sampledPatch::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledPatch.H:262
Foam::List::null
static const List< T > & null()
Return a null List.
Definition: ListI.H:109
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::sampledPatch::patchIDs
const labelList & patchIDs() const
The patches selected.
Definition: sampledPatch.C:81
Foam::MeshedSurface::triangulate
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Definition: MeshedSurface.C:1015
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::sampledPatch::patchFaceLabels
const labelList & patchFaceLabels() const
For each face, the patch local face ID.
Definition: sampledPatch.H:180
Foam::sampledPatch::patchNames
const wordRes & patchNames() const
The selection (word/regex) of patches.
Definition: sampledPatch.H:159
Foam::sampledPatch::Sf
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledPatch.H:250
Foam::sampledPatch::~sampledPatch
virtual ~sampledPatch()=default
Destructor.
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:435
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:413
Foam::sampledPatch::points
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:232
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::sampledPatch::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledPatch.H:256
Foam::sampledPatch::patchStart
const labelList & patchStart() const
The offset into patchIndex, patchFaceLabels.
Definition: sampledPatch.H:168
Foam::sampledPatch::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample boundary of volume field onto surface faces.
Definition: sampledPatch.C:277
Foam::MeshedSurface< face >::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:441
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::Field< vector >
Foam::sampledPatch::withSurfaceFields
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledPatch.C:321
sampledSurface.H
Foam::sampledPatch::sampledPatch
sampledPatch(const word &name, const polyMesh &mesh, const UList< wordRe > &patchNames, const bool triangulate=false)
Construct from components.
Definition: sampledPatch.C:51
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
sampledPatchTemplates.C
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledPatch::update
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:174
Foam::sampledPatch::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledPatch.H:244
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::List< label >
Foam::sampledSurface::mesh
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
Definition: sampledSurface.H:316
Foam::UList< label >
MeshedSurfaces.H
Foam::sampledPatch::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:152
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::sampledPatch::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledPatch.C:417
Foam::MeshedSurface< face >::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:447
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::MeshedSurface< face >
Foam::sampledPatch::TypeName
TypeName("sampledPatch")
Runtime type information.
Foam::sampledPatch::patchIndex
const labelList & patchIndex() const
For each face, the patch ID.
Definition: sampledPatch.H:174
Foam::sampledPatch
A sampledSurface on patches. Non-triangulated by default.
Definition: sampledPatch.H:95
Foam::sampledPatch::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:238