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 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 the cell faces corresponding to a threshold
31  value.
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 faceZones;
43  zones (zone1 "sides.*");
44  }
45  }
46  \endverbatim
47 
48  Where the sub-entries comprise:
49  \table
50  Property | Description | Required | Default
51  type | faceZones | yes |
52  zones | zone selection as word/regex list | yes |
53  triangulate | triangulate faces | no | false
54  \endtable
55 
56 SourceFiles
57  sampledFaceZone.C
58  sampledFaceZoneTemplates.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef sampledFaceZone_H
63 #define sampledFaceZone_H
64 
65 #include "sampledSurface.H"
66 #include "MeshedSurfaces.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class sampledFaceZone Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class sampledFaceZone
78 :
79  public meshedSurface,
80  public sampledSurface
81 {
82  //- Mesh storage type
83  typedef meshedSurface Mesh;
84 
85 
86  // Private Data
87 
88  //- Selection (word/regex) of face zones
89  const wordRes selectionNames_;
90 
91  //- IDs for selected face zones (sorted)
92  mutable labelList zoneIds_;
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  //- Local list of face IDs
101  labelList faceId_;
102 
103  //- Local list of patch ID per face. Is -1 for internal face
104  labelList facePatchId_;
105 
106 
107  // Private Member Functions
108 
109  //- Sample volume/boundary field onto surface faces
110  template<class Type>
111  tmp<Field<Type>> sampleOnFaces
112  (
113  const interpolation<Type>& sampler
114  ) const;
115 
116  //- Sample surface field onto surface faces
117  template<class Type>
118  tmp<Field<Type>> sampleOnFaces
119  (
121  ) const;
122 
123  //- Interpolate volume/boundary field onto surface points
124  template<class Type>
125  tmp<Field<Type>> sampleOnPoints
126  (
127  const interpolation<Type>& interpolator
128  ) const;
129 
130 
131  //- Re-map action on triangulation or cleanup
132  virtual void remapFaces(const labelUList& faceMap);
133 
134 
135 protected:
136 
137  //- The selected face zones (sorted)
138  const labelList& zoneIDs() const;
139 
140 
141 public:
142 
143  //- Runtime type information
144  TypeName("faceZone");
145 
146 
147  // Constructors
148 
149  //- Construct from components
151  (
152  const word& name,
153  const polyMesh& mesh,
154  const UList<wordRe>& zoneNames,
155  const bool triangulate = false
156  );
157 
158  //- Construct from dictionary
160  (
161  const word& name,
162  const polyMesh& mesh,
163  const dictionary& dict
164  );
165 
166 
167  //- Destructor
168  virtual ~sampledFaceZone() = default;
169 
170 
171  // Member Functions
172 
173  //- Does the surface need an update?
174  virtual bool needsUpdate() const;
175 
176  //- Mark the surface as needing an update.
177  // May also free up unneeded data.
178  // Return false if surface was already marked as expired.
179  virtual bool expire();
180 
181  //- Update the surface as required.
182  // Do nothing (and return false) if no update was needed
183  virtual bool update();
184 
185  //- Points of surface
186  virtual const pointField& points() const
187  {
188  return Mesh::points();
189  }
190 
191  //- Faces of surface
192  virtual const faceList& faces() const
193  {
194  return Mesh::surfFaces();
195  }
196 
197  //- Per-face zone/region information
198  virtual const labelList& zoneIds() const
199  {
200  return labelList::null();
201  }
202 
203  //- Face area vectors (normals)
204  virtual const vectorField& Sf() const
205  {
206  return Mesh::Sf();
207  }
208 
209  //- Face area magnitudes
210  virtual const scalarField& magSf() const
211  {
212  return Mesh::magSf();
213  }
214 
215  //- Face centres
216  virtual const vectorField& Cf() const
217  {
218  return Mesh::Cf();
219  }
220 
221 
222  // Sample
223 
224  //- Sample volume field onto surface faces
225  virtual tmp<scalarField> sample
226  (
227  const interpolation<scalar>& sampler
228  ) const;
229 
230  //- Sample volume field onto surface faces
231  virtual tmp<vectorField> sample
232  (
233  const interpolation<vector>& sampler
234  ) const;
235 
236  //- Sample volume field onto surface faces
238  (
239  const interpolation<sphericalTensor>& sampler
240  ) const;
241 
242  //- Sample volume field onto surface faces
244  (
245  const interpolation<symmTensor>& sampler
246  ) const;
247 
248  //- Sample volume field onto surface faces
249  virtual tmp<tensorField> sample
250  (
251  const interpolation<tensor>& sampler
252  ) const;
253 
254 
255  //- Can it sample surface-fields?
256  virtual bool withSurfaceFields() const;
257 
258 
259  //- Sample surface field on face zone
260  virtual tmp<scalarField> sample
261  (
262  const surfaceScalarField&
263  ) const;
264 
265  //- Sample surface field on face zone
266  virtual tmp<vectorField> sample
267  (
268  const surfaceVectorField&
269  ) const;
270 
271  //- Sample surface field on face zone
273  (
275  ) const;
276 
277  //- Sample surface field on face zone
279  (
281  ) const;
282 
283  //- Sample surface field on face zone
284  virtual tmp<tensorField> sample
285  (
286  const surfaceTensorField&
287  ) const;
288 
289 
290 
291  // Interpolate
292 
293  //- Interpolate volume field onto surface points
295  (
296  const interpolation<scalar>& interpolator
297  ) const;
298 
299  //- Interpolate volume field onto surface points
301  (
302  const interpolation<vector>& interpolator
303  ) const;
304 
305  //- Interpolate volume field onto surface points
307  (
308  const interpolation<sphericalTensor>& interpolator
309  ) const;
310 
311  //- Interpolate volume field onto surface points
313  (
314  const interpolation<symmTensor>& interpolator
315  ) const;
316 
317  //- Interpolate volume field onto surface points
319  (
320  const interpolation<tensor>& interpolator
321  ) const;
322 
323 
324  // Output
325 
326  //- Print information
327  virtual void print(Ostream& os) const;
328 };
329 
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 } // End namespace Foam
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #ifdef NoRepository
338  #include "sampledFaceZoneTemplates.C"
339 #endif
340 
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
342 
343 #endif
344 
345 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::sampledFaceZone::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledFaceZone.H:217
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< 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::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:62
sampledFaceZoneTemplates.C
Foam::MeshedSurface::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:61
Foam::MeshedSurface< face >::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:433
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:411
Foam::sampledFaceZone::Sf
virtual const vectorField & Sf() const
Face area vectors (normals)
Definition: sampledFaceZone.H:223
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:235
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:439
Foam::Field< vector >
Foam::sampledFaceZone
A sampledSurface defined by the cell faces corresponding to a threshold value.
Definition: sampledFaceZone.H:96
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:120
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:121
Foam::sampledFaceZone::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledFaceZone.C:253
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledFaceZone::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledFaceZone.H:229
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::List< label >
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:321
Foam::sampledFaceZone::print
virtual void print(Ostream &os) const
Print information.
Definition: sampledFaceZone.C:393
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::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:315
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:205
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::MeshedSurface< face >
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:339
Foam::sampledFaceZone::~sampledFaceZone
virtual ~sampledFaceZone()=default
Destructor.
Foam::sampledFaceZone::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledFaceZone.H:211