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-2019 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 "MeshedSurface.H"
66 #include "wordRes.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class sampledPatch Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class sampledPatch
78 :
79  public MeshedSurface<face>,
80  public sampledSurface
81 {
82  //- Private typedefs for convenience
83  typedef MeshedSurface<face> MeshStorage;
84 
85 
86  // Private data
87 
88  //- Name of patches
89  const wordRes patchNames_;
90 
91  //- Corresponding patchIDs
92  mutable labelList patchIDs_;
93 
94  //- Triangulated faces or keep faces as is
95  bool triangulate_;
96 
97  //- Track if the surface needs an update
98  mutable bool needsUpdate_;
99 
100  //- For every face (or triangle) the originating patch
101  labelList patchIndex_;
102 
103  //- For every face (or triangle) the index in the originating patch
104  labelList patchFaceLabels_;
105 
106  //- Start indices (in patchFaceLabels_) of patches
107  labelList patchStart_;
108 
109 
110  // Private Member Functions
111 
112  //- Sample boundary field (from volume field) onto surface faces
113  template<class Type>
114  tmp<Field<Type>> sampleOnFaces
115  (
116  const interpolation<Type>& sampler
117  ) const;
118 
119  //- Sample boundary field (from surface field) onto surface faces
120  template<class Type>
121  tmp<Field<Type>> sampleOnFaces
122  (
124  ) const;
125 
126  //- Interpolate boundary field (from volume field) onto surface points
127  template<class Type>
128  tmp<Field<Type>> sampleOnPoints
129  (
130  const interpolation<Type>& interpolator
131  ) const;
132 
133 
134  //- Re-map action on triangulation or cleanup
135  virtual void remapFaces(const labelUList& faceMap);
136 
137 
138 protected:
139 
140  const wordRes& patchNames() const
141  {
142  return patchNames_;
143  }
144 
145  const labelList& patchIDs() const;
146 
147  const labelList& patchStart() const
148  {
149  return patchStart_;
150  }
151 
152  const labelList& patchIndex() const
153  {
154  return patchIndex_;
155  }
156 
157  const labelList& patchFaceLabels() const
158  {
159  return patchFaceLabels_;
160  }
161 
162 
163 public:
164 
165  //- Runtime type information
166  TypeName("sampledPatch");
167 
168 
169  // Constructors
170 
171  //- Construct from components
173  (
174  const word& name,
175  const polyMesh& mesh,
177  const bool triangulate = false
178  );
179 
180  //- Construct from dictionary
182  (
183  const word& name,
184  const polyMesh& mesh,
185  const dictionary& dict
186  );
187 
188 
189  //- Destructor
190  virtual ~sampledPatch() = default;
191 
192 
193  // Member Functions
194 
195  //- Does the surface need an update?
196  virtual bool needsUpdate() const;
197 
198  //- Mark the surface as needing an update.
199  // May also free up unneeded data.
200  // Return false if surface was already marked as expired.
201  virtual bool expire();
202 
203  //- Update the surface as required.
204  // Do nothing (and return false) if no update was needed
205  virtual bool update();
206 
207 
208  //- Points of surface
209  virtual const pointField& points() const
210  {
211  return MeshStorage::points();
212  }
213 
214  //- Faces of surface
215  virtual const faceList& faces() const
216  {
217  return MeshStorage::surfFaces();
218  }
219 
220  //- Per-face zone/region information
221  virtual const labelList& zoneIds() const
222  {
223  return labelList::null();
224  }
225 
226  //- Face area vectors
227  virtual const vectorField& Sf() const
228  {
229  return MeshStorage::Sf();
230  }
231 
232  //- Face area magnitudes
233  virtual const scalarField& magSf() const
234  {
235  return MeshStorage::magSf();
236  }
237 
238  //- Face centres
239  virtual const vectorField& Cf() const
240  {
241  return MeshStorage::Cf();
242  }
243 
244 
245  // Sample
246 
247  //- Sample boundary of volume field onto surface faces
248  virtual tmp<scalarField> sample
249  (
250  const interpolation<scalar>& sampler
251  ) const;
252 
253  //- Sample boundary of volume field onto surface faces
254  virtual tmp<vectorField> sample
255  (
256  const interpolation<vector>& sampler
257  ) const;
258 
259  //- Sample boundary of volume field onto surface faces
261  (
262  const interpolation<sphericalTensor>& sampler
263  ) const;
264 
265  //- Sample boundary of volume field onto surface faces
267  (
268  const interpolation<symmTensor>& sampler
269  ) const;
270 
271  //- Sample boundary of volume field onto surface faces
272  virtual tmp<tensorField> sample
273  (
274  const interpolation<tensor>& sampler
275  ) const;
276 
277 
278  //- Can it sample surface-fields?
279  virtual bool withSurfaceFields() const;
280 
281 
282  //- Sample boundary of surface field on surface
283  virtual tmp<scalarField> sample
284  (
285  const surfaceScalarField&
286  ) const;
287 
288  //- Sample boundary of surface field on surface
289  virtual tmp<vectorField> sample
290  (
291  const surfaceVectorField&
292  ) const;
293 
294  //- Sample boundary of surface field on surface
296  (
298  ) const;
299 
300  //- Sample boundary of surface field on surface
302  (
304  ) const;
305 
306  //- Sample boundary of surface field on surface
307  virtual tmp<tensorField> sample
308  (
309  const surfaceTensorField&
310  ) const;
311 
312 
313  // Interpolate
314 
315  //- Interpolate boundary of volume field onto surface points
317  (
318  const interpolation<scalar>& interpolator
319  ) const;
320 
321  //- Interpolate boundary of volume field onto surface points
323  (
324  const interpolation<vector>& interpolator
325  ) const;
326 
327  //- Interpolate boundary of volume field onto surface points
329  (
330  const interpolation<sphericalTensor>& interpolator
331  ) const;
332 
333  //- Interpolate boundary of volume field onto surface points
335  (
336  const interpolation<symmTensor>& interpolator
337  ) const;
338 
339  //- Interpolate boundary of volume field onto surface points
341  (
342  const interpolation<tensor>& interpolator
343  ) const;
344 
345 
346  // Output
347 
348  //- Write
349  virtual void print(Ostream&) const;
350 };
351 
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 } // End namespace Foam
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #ifdef NoRepository
360  #include "sampledPatchTemplates.C"
361 #endif
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #endif
366 
367 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
wordRes.H
Foam::sampledPatch::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:90
Foam::sampledPatch::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledPatch.H:258
Foam::List< label >::null
static const List< label > & null()
Return a null List.
Definition: ListI.H:108
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:62
Foam::sampledPatch::patchIDs
const labelList & patchIDs() const
Definition: sampledPatch.C:80
Foam::MeshedSurface< face >::triangulate
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Definition: MeshedSurface.C:972
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::sampledPatch::patchFaceLabels
const labelList & patchFaceLabels() const
Definition: sampledPatch.H:176
Foam::sampledPatch::patchNames
const wordRes & patchNames() const
Definition: sampledPatch.H:159
Foam::sampledPatch::Sf
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledPatch.H:246
Foam::sampledPatch::~sampledPatch
virtual ~sampledPatch()=default
Destructor.
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:433
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:411
Foam::sampledPatch::points
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:228
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:252
Foam::sampledPatch::patchStart
const labelList & patchStart() const
Definition: sampledPatch.H:166
Foam::sampledPatch::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample boundary of volume field onto surface faces.
Definition: sampledPatch.C:227
Foam::MeshedSurface< face >::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:439
Foam::sampledPatch::print
virtual void print(Ostream &) const
Write.
Definition: sampledPatch.C:367
Foam::Field< vector >
Foam::sampledPatch::withSurfaceFields
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledPatch.C:271
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:50
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
sampledPatchTemplates.C
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledPatch::update
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:116
Foam::sampledPatch::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledPatch.H:240
Foam::List< label >
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:308
Foam::UList< label >
Foam::sampledPatch::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:96
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::MeshedSurface< face >::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:445
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:302
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
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: triSurfaceTools.H:80
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:326
Foam::sampledPatch::TypeName
TypeName("sampledPatch")
Runtime type information.
Foam::sampledPatch::patchIndex
const labelList & patchIndex() const
Definition: sampledPatch.H:171
MeshedSurface.H
Foam::sampledPatch
A sampledSurface on patches. Non-triangulated by default.
Definition: sampledPatch.H:96
Foam::sampledPatch::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:234