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-2025 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 Data
76 
77  //- Name of patches
78  const wordReList patchNames_;
79 
80  //- Corresponding patchIDs
81  mutable labelList patchIndices_;
82 
83  //- Triangulated faces or keep faces as is
84  bool triangulate_;
85 
86  //- Track if the surface needs an update
87  mutable bool needsUpdate_;
88 
89  //- For every face (or triangle) the originating patch
90  labelList patchIndex_;
91 
92  //- For every face (or triangle) the index in the originating patch
93  labelList patchFaceLabels_;
94 
95  //- Start indices (in patchFaceLabels_) of patches
96  labelList patchStart_;
97 
98 
99  // Private Member Functions
100 
101  //- Sample field on faces
102  template<class Type>
103  tmp<Field<Type>> sampleField
104  (
105  const VolField<Type>& vField
106  ) const;
107 
108  //- Sample surface field on faces
109  template<class Type>
110  tmp<Field<Type>> sampleField
111  (
112  const SurfaceField<Type>& sField
113  ) const;
114 
115  template<class Type>
116  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
117 
118  //- Re-map action on triangulation or cleanup
119  virtual void remapFaces(const labelUList& faceMap);
120 
121 
122 protected:
123 
124  const wordReList& patchNames() const
125  {
126  return patchNames_;
127  }
128 
129  const labelList& patchIndices() const;
130 
131  const labelList& patchStart() const
132  {
133  return patchStart_;
134  }
135 
136  const labelList& patchFaceLabels() const
137  {
138  return patchFaceLabels_;
139  }
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("patch");
146 
147 
148  // Constructors
149 
150  //- Construct from components
151  patch
152  (
153  const word& name,
154  const polyMesh& mesh,
156  const bool triangulate = false
157  );
158 
159  //- Construct from dictionary
160  patch
161  (
162  const word& name,
163  const polyMesh& mesh,
165  );
166 
167 
168  //- Destructor
169  virtual ~patch();
170 
171 
172  // Member Functions
173 
174  //- Does the surface need an update?
175  virtual bool needsUpdate() const;
176 
177  //- Mark the surface as needing an update.
178  // May also free up unneeded data.
179  // Return false if surface was already marked as expired.
180  virtual bool expire();
181 
182  //- Update the surface as required.
183  // Do nothing (and return false) if no update was needed
184  virtual bool update();
185 
186 
187  //- Points of surface
188  virtual const pointField& points() const
189  {
191  }
192 
193  //- Faces of surface
194  virtual const faceList& faces() const
195  {
197  }
198 
199 
200  // Sample
201  //- Sample field on surface
202  virtual tmp<scalarField> sample
203  (
204  const volScalarField&
205  ) const;
206 
207  //- Sample field on surface
208  virtual tmp<vectorField> sample
209  (
210  const volVectorField&
211  ) const;
212 
213  //- Sample field on surface
215  (
217  ) const;
218 
219  //- Sample field on surface
221  (
222  const volSymmTensorField&
223  ) const;
224 
225  //- Sample field on surface
226  virtual tmp<tensorField> sample
227  (
228  const volTensorField&
229  ) const;
230 
231  //- Surface sample field on surface
232  virtual tmp<scalarField> sample
233  (
234  const surfaceScalarField&
235  ) const;
236 
237  //- Surface Sample field on surface
238  virtual tmp<vectorField> sample
239  (
240  const surfaceVectorField&
241  ) const;
242 
243  //- Surface sample field on surface
245  (
247  ) const;
248 
249  //- Surface sample field on surface
251  (
253  ) const;
254 
255  //- Surface sample field on surface
256  virtual tmp<tensorField> sample
257  (
258  const surfaceTensorField&
259  ) const;
260 
261 
262  // Interpolate
263 
264  //- Interpolate field on surface
266  (
267  const interpolation<scalar>&
268  ) const;
269 
270  //- Interpolate field on surface
272  (
273  const interpolation<vector>&
274  ) const;
275 
276  //- Interpolate field on surface
278  (
280  ) const;
281 
282  //- Interpolate field on surface
284  (
286  ) const;
287 
288  //- Interpolate field on surface
290  (
291  const interpolation<tensor>&
292  ) const;
293 
294  //- Write
295  virtual void print(Ostream&) const;
296 };
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace sampledSurfaces
302 } // End namespace Foam
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #ifdef NoRepository
307  #include "sampledPatchTemplates.C"
308 #endif
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #endif
313 
314 // ************************************************************************* //
Generic GeometricField class.
const List< Face > & faces() const
Return const access to the faces.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const Field< PointType > & points() const
Return reference to global points.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for interpolation.
Definition: interpolation.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
bool interpolate() const
Interpolation requested for surface.
const word & name() const
Name of surface.
const polyMesh & mesh() const
Access to the underlying mesh.
const wordReList & patchNames() const
Definition: sampledPatch.H:143
const labelList & patchIndices() const
Definition: sampledPatch.C:81
virtual ~patch()
Destructor.
Definition: sampledPatch.C:75
TypeName("patch")
Runtime type information.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Definition: sampledPatch.C:234
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:101
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:95
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:122
virtual void print(Ostream &) const
Write.
Definition: sampledPatch.C:368
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:213
patch(const word &name, const polyMesh &mesh, const wordReList &patchNames, const bool triangulate=false)
Construct from components.
Definition: sampledPatch.C:45
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:207
const labelList & patchFaceLabels() const
Definition: sampledPatch.H:155
const labelList & patchStart() const
Definition: sampledPatch.H:150
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< wordRe > wordReList
A List of wordRe (word or regular expression)
Definition: wordReList.H:50
dictionary dict