All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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 SourceFiles
31  sampledPatch.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sampledPatch_H
36 #define sampledPatch_H
37 
38 #include "sampledSurface.H"
39 #include "MeshedSurface.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace sampledSurfaces
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class patch Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class patch
53 :
54  public MeshedSurface<face>,
55  public sampledSurface
56 {
57  // Private Typedefs
58 
60 
61 
62  // Private Data
63 
64  //- Name of patches
65  const wordReList patchNames_;
66 
67  //- Corresponding patchIDs
68  mutable labelList patchIDs_;
69 
70  //- Triangulated faces or keep faces as is
71  bool triangulate_;
72 
73  //- Track if the surface needs an update
74  mutable bool needsUpdate_;
75 
76  //- For every face (or triangle) the originating patch
77  labelList patchIndex_;
78 
79  //- For every face (or triangle) the index in the originating patch
80  labelList patchFaceLabels_;
81 
82  //- Start indices (in patchFaceLabels_) of patches
83  labelList patchStart_;
84 
85 
86  // Private Member Functions
87 
88  //- Sample field on faces
89  template<class Type>
90  tmp<Field<Type>> sampleField
91  (
93  ) const;
94 
95  //- Sample surface field on faces
96  template<class Type>
97  tmp<Field<Type>> sampleField
98  (
100  ) const;
101 
102  template<class Type>
103  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
104 
105  //- Re-map action on triangulation or cleanup
106  virtual void remapFaces(const labelUList& faceMap);
107 
108 
109 protected:
111  const wordReList& patchNames() const
112  {
113  return patchNames_;
114  }
115 
116  const labelList& patchIDs() const;
118  const labelList& patchStart() const
119  {
120  return patchStart_;
121  }
123  const labelList& patchFaceLabels() const
124  {
125  return patchFaceLabels_;
126  }
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName("patch");
133 
134 
135  // Constructors
136 
137  //- Construct from components
138  patch
139  (
140  const word& name,
141  const polyMesh& mesh,
142  const wordReList& patchNames,
143  const bool triangulate = false
144  );
145 
146  //- Construct from dictionary
147  patch
148  (
149  const word& name,
150  const polyMesh& mesh,
151  const dictionary& dict
152  );
153 
154 
155  //- Destructor
156  virtual ~patch();
157 
158 
159  // Member Functions
160 
161  //- Does the surface need an update?
162  virtual bool needsUpdate() const;
163 
164  //- Mark the surface as needing an update.
165  // May also free up unneeded data.
166  // Return false if surface was already marked as expired.
167  virtual bool expire();
168 
169  //- Update the surface as required.
170  // Do nothing (and return false) if no update was needed
171  virtual bool update();
172 
173 
174  //- Points of surface
175  virtual const pointField& points() const
176  {
177  return MeshStorage::points();
178  }
179 
180  //- Faces of surface
181  virtual const faceList& faces() const
182  {
183  return MeshStorage::faces();
184  }
185 
186 
187  // Sample
188  //- Sample field on surface
189  virtual tmp<scalarField> sample
190  (
191  const volScalarField&
192  ) const;
193 
194  //- Sample field on surface
195  virtual tmp<vectorField> sample
196  (
197  const volVectorField&
198  ) const;
199 
200  //- Sample field on surface
202  (
204  ) const;
205 
206  //- Sample field on surface
208  (
209  const volSymmTensorField&
210  ) const;
211 
212  //- Sample field on surface
213  virtual tmp<tensorField> sample
214  (
215  const volTensorField&
216  ) const;
217 
218  //- Surface sample field on surface
219  virtual tmp<scalarField> sample
220  (
221  const surfaceScalarField&
222  ) const;
223 
224  //- Surface Sample field on surface
225  virtual tmp<vectorField> sample
226  (
227  const surfaceVectorField&
228  ) const;
229 
230  //- Surface sample field on surface
232  (
234  ) const;
235 
236  //- Surface sample field on surface
238  (
240  ) const;
241 
242  //- Surface sample field on surface
243  virtual tmp<tensorField> sample
244  (
245  const surfaceTensorField&
246  ) const;
247 
248 
249  // Interpolate
250 
251  //- Interpolate field on surface
253  (
254  const interpolation<scalar>&
255  ) const;
256 
257  //- Interpolate field on surface
259  (
260  const interpolation<vector>&
261  ) const;
262 
263  //- Interpolate field on surface
265  (
267  ) const;
268 
269  //- Interpolate field on surface
271  (
273  ) const;
274 
275  //- Interpolate field on surface
277  (
278  const interpolation<tensor>&
279  ) const;
280 
281  //- Write
282  virtual void print(Ostream&) const;
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace sampledSurfaces
289 } // End namespace Foam
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #ifdef NoRepository
294  #include "sampledPatchTemplates.C"
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
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:158
An abstract class for surfaces with sampling.
const word & name() const
Name of surface.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
A sampledSurface on patches. Non-triangulated by default.
Definition: sampledPatch.H:51
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:174
Generic GeometricField class.
const wordReList & patchNames() const
Definition: sampledPatch.H:110
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)
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
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
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:180
const labelList & patchStart() const
Definition: sampledPatch.H:117
Abstract base class for interpolation.
const labelList & patchFaceLabels() const
Definition: sampledPatch.H:122
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.