sampledPatch.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sampledSurfaces::patch
26 
27 Description
28  A sampledSurface on patches. Non-triangulated by default.
29 
30  Example:
31  \verbatim
32  {
33  type patch;
34  patches (walls);
35  triangulate no;
36  interpolate yes;
37  }
38  \endverbatim
39 
40 Usage
41  \table
42  Property | Description | Required | Default value
43  patches | the names of patches on which to sample | yes |
44  triangulate | triangulate the output | no | no
45  interpolate | interpolate values to the surface points | no | no
46  \endtable
47 
48 SourceFiles
49  sampledPatch.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef sampledPatch_H
54 #define sampledPatch_H
55 
56 #include "sampledSurface.H"
57 #include "MeshedSurface.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 namespace sampledSurfaces
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class patch Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class patch
71 :
72  public MeshedSurface<face>,
73  public sampledSurface
74 {
75  // Private Typedefs
76 
77  typedef MeshedSurface<face> MeshStorage;
78 
79 
80  // Private Data
81 
82  //- Name of patches
83  const wordReList patchNames_;
84 
85  //- Corresponding patchIDs
86  mutable labelList patchIDs_;
87 
88  //- Triangulated faces or keep faces as is
89  bool triangulate_;
90 
91  //- Track if the surface needs an update
92  mutable bool needsUpdate_;
93 
94  //- For every face (or triangle) the originating patch
95  labelList patchIndex_;
96 
97  //- For every face (or triangle) the index in the originating patch
98  labelList patchFaceLabels_;
99 
100  //- Start indices (in patchFaceLabels_) of patches
101  labelList patchStart_;
102 
103 
104  // Private Member Functions
105 
106  //- Sample field on faces
107  template<class Type>
108  tmp<Field<Type>> sampleField
109  (
111  ) const;
112 
113  //- Sample surface field on faces
114  template<class Type>
115  tmp<Field<Type>> sampleField
116  (
118  ) const;
119 
120  template<class Type>
121  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
122 
123  //- Re-map action on triangulation or cleanup
124  virtual void remapFaces(const labelUList& faceMap);
125 
126 
127 protected:
128 
129  const wordReList& patchNames() const
130  {
131  return patchNames_;
132  }
133 
134  const labelList& patchIDs() const;
135 
136  const labelList& patchStart() const
137  {
138  return patchStart_;
139  }
140 
141  const labelList& patchFaceLabels() const
142  {
143  return patchFaceLabels_;
144  }
145 
146 
147 public:
149  //- Runtime type information
150  TypeName("patch");
151 
152 
153  // Constructors
154 
155  //- Construct from components
156  patch
157  (
158  const word& name,
159  const polyMesh& mesh,
161  const bool triangulate = false
162  );
163 
164  //- Construct from dictionary
165  patch
166  (
167  const word& name,
168  const polyMesh& mesh,
169  const dictionary& dict
170  );
171 
172 
173  //- Destructor
174  virtual ~patch();
175 
176 
177  // Member Functions
178 
179  //- Does the surface need an update?
180  virtual bool needsUpdate() const;
181 
182  //- Mark the surface as needing an update.
183  // May also free up unneeded data.
184  // Return false if surface was already marked as expired.
185  virtual bool expire();
186 
187  //- Update the surface as required.
188  // Do nothing (and return false) if no update was needed
189  virtual bool update();
190 
191 
192  //- Points of surface
193  virtual const pointField& points() const
194  {
195  return MeshStorage::points();
196  }
197 
198  //- Faces of surface
199  virtual const faceList& faces() const
200  {
201  return MeshStorage::faces();
202  }
203 
204 
205  // Sample
206  //- Sample field on surface
207  virtual tmp<scalarField> sample
208  (
209  const volScalarField&
210  ) const;
211 
212  //- Sample field on surface
213  virtual tmp<vectorField> sample
214  (
215  const volVectorField&
216  ) const;
217 
218  //- Sample field on surface
220  (
222  ) const;
223 
224  //- Sample field on surface
226  (
227  const volSymmTensorField&
228  ) const;
229 
230  //- Sample field on surface
231  virtual tmp<tensorField> sample
232  (
233  const volTensorField&
234  ) const;
235 
236  //- Surface sample field on surface
237  virtual tmp<scalarField> sample
238  (
239  const surfaceScalarField&
240  ) const;
241 
242  //- Surface Sample field on surface
243  virtual tmp<vectorField> sample
244  (
245  const surfaceVectorField&
246  ) const;
247 
248  //- Surface sample field on surface
250  (
252  ) const;
253 
254  //- Surface sample field on surface
256  (
258  ) const;
259 
260  //- Surface sample field on surface
261  virtual tmp<tensorField> sample
262  (
263  const surfaceTensorField&
264  ) const;
265 
266 
267  // Interpolate
268 
269  //- Interpolate field on surface
271  (
272  const interpolation<scalar>&
273  ) const;
274 
275  //- Interpolate field on surface
277  (
278  const interpolation<vector>&
279  ) const;
280 
281  //- Interpolate field on surface
283  (
285  ) const;
286 
287  //- Interpolate field on surface
289  (
291  ) const;
292 
293  //- Interpolate field on surface
295  (
296  const interpolation<tensor>&
297  ) const;
298 
299  //- Write
300  virtual void print(Ostream&) const;
301 };
302 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 } // End namespace sampledSurfaces
307 } // End namespace Foam
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #ifdef NoRepository
312  #include "sampledPatchTemplates.C"
313 #endif
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 #endif
318 
319 // ************************************************************************* //
virtual void print(Ostream &) const
Write.
Definition: sampledPatch.C:367
TypeName("patch")
Runtime type information.
dictionary dict
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:101
const labelList & patchIDs() const
Definition: sampledPatch.C:81
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Name of surface.
virtual ~patch()
Destructor.
Definition: sampledPatch.C:75
bool interpolate() const
Interpolation requested for surface.
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:95
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:212
Generic GeometricField class.
const wordReList & patchNames() const
Definition: sampledPatch.H:148
patch(const word &name, const polyMesh &mesh, const wordReList &patchNames, const bool triangulate=false)
Construct from components.
Definition: sampledPatch.C:45
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from string.
Definition: word.H:59
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
const Field< PointType > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Definition: sampledPatch.C:233
const polyMesh & mesh() const
Access to the underlying mesh.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:121
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const List< face > & faces() const
Return const access to the faces.
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:218
const labelList & patchStart() const
Definition: sampledPatch.H:155
Abstract base class for interpolation.
const labelList & patchFaceLabels() const
Definition: sampledPatch.H:160
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< wordRe > wordReList
A List of wordRe (word or regular expression)
Definition: wordReList.H:50
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.