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-2026 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  //- Update the surface as required.
178  // Do nothing (and return false) if no update was needed
179  virtual bool update();
180 
181  //- Points of surface
182  virtual const pointField& points() const
183  {
185  }
186 
187  //- Faces of surface
188  virtual const faceList& faces() const
189  {
191  }
192 
193  //- Sample field on the surface's faces
194  #define DEFINE_SAMPLE(Type, nullArg) \
195  virtual tmp<Field<Type>> sample \
196  ( \
197  const VolField<Type>& \
198  ) const; \
199  \
200  virtual tmp<Field<Type>> sample \
201  ( \
202  const SurfaceField<Type>& \
203  ) const;
205  #undef DEFINE_SAMPLE
206 
207  //- Interpolate field to the surface's points
208  #define DEFINE_INTERPOLATE(Type, nullArg) \
209  virtual tmp<Field<Type>> interpolate \
210  ( \
211  const interpolation<Type>& \
212  ) const;
214  #undef DEFINE_INTERPOLATE
215 
216  //- Update for mesh point-motion
217  virtual void movePoints();
218 
219  //- Update topology using the given map
220  virtual void topoChange(const polyTopoChangeMap&);
221 
222  //- Update from another mesh using the given map
223  virtual void mapMesh(const polyMeshMap&);
224 
225  //- Redistribute or update using the given distribution map
226  virtual void distribute(const polyDistributionMap&);
227 
228  //- Write
229  virtual void print(Ostream&) const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace sampledSurfaces
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #ifdef NoRepository
241  #include "sampledPatchTemplates.C"
242 #endif
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
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.
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.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
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 void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledPatch.C:258
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledPatch.C:270
virtual void movePoints()
Update for mesh point-motion.
Definition: sampledPatch.C:244
FOR_ALL_FIELD_TYPES(DEFINE_SAMPLE)
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledPatch.C:264
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:92
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:98
virtual void print(Ostream &) const
Write.
Definition: sampledPatch.C:276
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:207
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:201
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:63
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
#define DEFINE_SAMPLE(Type, nullArg)
Sample field on the surface's faces.
Definition: sampledPatch.H:213
#define DEFINE_INTERPOLATE(Type, nullArg)
Interpolate field to the surface's points.
Definition: sampledPatch.H:227
dictionary dict