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-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::sampledFaceZone
28 
29 Description
30  A sampledSurface defined by a faceZone or faceZones.
31 
32  This is often embedded as part of a sampled surfaces function object.
33 
34 Usage
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 
55 SourceFiles
56  sampledFaceZone.C
57  sampledFaceZoneTemplates.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef sampledFaceZone_H
62 #define sampledFaceZone_H
63 
64 #include "sampledSurface.H"
65 #include "MeshedSurfaces.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class sampledFaceZone Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class 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_;
95 
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  (
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 
134 protected:
135 
136  //- The selected face zones (sorted)
137  const labelList& zoneIDs() const;
138 
139 
140 public:
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,
162  const dictionary& dict
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
186  {
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
204  {
205  return Mesh::Sf();
206  }
207 
208  //- Face area magnitudes
209  virtual const scalarField& magSf() const
210  {
211  return Mesh::magSf();
212  }
213 
214  //- Face centres
215  virtual const vectorField& Cf() const
216  {
217  return Mesh::Cf();
218  }
219 
220 
221  // Sample
222 
223  //- Sample volume field onto surface faces
224  virtual tmp<scalarField> sample
225  (
226  const interpolation<scalar>& sampler
227  ) const;
228 
229  //- Sample volume field onto surface faces
230  virtual tmp<vectorField> sample
231  (
232  const interpolation<vector>& sampler
233  ) const;
234 
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
248  virtual tmp<tensorField> sample
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
259  virtual tmp<scalarField> sample
260  (
261  const surfaceScalarField&
262  ) const;
263 
264  //- Sample surface field on face zone
265  virtual tmp<vectorField> sample
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
283  virtual tmp<tensorField> sample
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
336  #include "sampledFaceZoneTemplates.C"
337 #endif
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #endif
342 
343 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::sampledFaceZone::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledFaceZone.H:216
Foam::sampledFaceZone::sampledFaceZone
sampledFaceZone(const word &name, const polyMesh &mesh, const UList< wordRe > &zoneNames, const bool triangulate=false)
Construct from components.
Definition: sampledFaceZone.C:57
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::sampledFaceZone::zoneIDs
const labelList & zoneIDs() const
The selected face zones (sorted)
Definition: sampledFaceZone.C:87
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
sampledFaceZoneTemplates.C
Foam::MeshedSurface< face >::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::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:435
Foam::sampledFaceZone::withSurfaceFields
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledFaceZone.C:297
Foam::MeshedSurface< face >::surfFaces
const List< face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:413
Foam::sampledFaceZone::Sf
virtual const vectorField & Sf() const
Face area vectors (normals)
Definition: sampledFaceZone.H:222
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sampledFaceZone::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledFaceZone.H:234
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::sampledFaceZone::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledFaceZone.C:105
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::sampledFaceZone
A sampledSurface defined by a faceZone or faceZones.
Definition: sampledFaceZone.H:95
Foam::sampledFaceZone::update
virtual bool update()
Update the surface as required.
Definition: sampledFaceZone.C:126
sampledSurface.H
Foam::sampledFaceZone::TypeName
TypeName("faceZone")
Runtime type information.
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
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::sampledFaceZone::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledFaceZone.C:253
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledFaceZone::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledFaceZone.H:228
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
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::sampledFaceZone::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledFaceZone.C:99
Foam::sampledFaceZone::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledFaceZone.C:393
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::sampledFaceZone::points
virtual const pointField & points() const
Points of surface.
Definition: sampledFaceZone.H:204
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::MeshedSurface< face >
Foam::sampledFaceZone::~sampledFaceZone
virtual ~sampledFaceZone()=default
Destructor.
Foam::sampledFaceZone::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledFaceZone.H:210