sampledPatch.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 | Copyright (C) 2011-2016 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::sampledPatch
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 
46 /*---------------------------------------------------------------------------*\
47  Class sampledPatch Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class sampledPatch
51 :
52  public MeshedSurface<face>,
53  public sampledSurface
54 {
55  //- Private typedefs for convenience
57 
58 
59  // Private data
60 
61  //- Name of patches
62  const wordReList patchNames_;
63 
64  //- Corresponding patchIDs
65  mutable labelList patchIDs_;
66 
67  //- Triangulated faces or keep faces as is
68  bool triangulate_;
69 
70  //- Track if the surface needs an update
71  mutable bool needsUpdate_;
72 
73  //- For every face (or triangle) the originating patch
74  labelList patchIndex_;
75 
76  //- For every face (or triangle) the index in the originating patch
77  labelList patchFaceLabels_;
78 
79  //- Start indices (in patchFaceLabels_) of patches
80  labelList patchStart_;
81 
82 
83  // Private Member Functions
84 
85  //- Sample field on faces
86  template<class Type>
87  tmp<Field<Type>> sampleField
88  (
90  ) const;
91 
92  //- Sample surface field on faces
93  template<class Type>
94  tmp<Field<Type>> sampleField
95  (
97  ) const;
98 
99  template<class Type>
100  tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
101 
102  //- Re-map action on triangulation or cleanup
103  virtual void remapFaces(const labelUList& faceMap);
104 
105 
106 protected:
108  const wordReList& patchNames() const
109  {
110  return patchNames_;
111  }
112 
113  const labelList& patchIDs() const;
115  const labelList& patchStart() const
116  {
117  return patchStart_;
118  }
120  const labelList& patchFaceLabels() const
121  {
122  return patchFaceLabels_;
123  }
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("sampledPatch");
130 
131 
132  // Constructors
133 
134  //- Construct from components
136  (
137  const word& name,
138  const polyMesh& mesh,
139  const wordReList& patchNames,
140  const bool triangulate = false
141  );
142 
143  //- Construct from dictionary
145  (
146  const word& name,
147  const polyMesh& mesh,
148  const dictionary& dict
149  );
150 
151 
152  //- Destructor
153  virtual ~sampledPatch();
154 
155 
156  // Member Functions
157 
158  //- Does the surface need an update?
159  virtual bool needsUpdate() const;
160 
161  //- Mark the surface as needing an update.
162  // May also free up unneeded data.
163  // Return false if surface was already marked as expired.
164  virtual bool expire();
165 
166  //- Update the surface as required.
167  // Do nothing (and return false) if no update was needed
168  virtual bool update();
169 
170 
171  //- Points of surface
172  virtual const pointField& points() const
173  {
174  return MeshStorage::points();
175  }
176 
177  //- Faces of surface
178  virtual const faceList& faces() const
179  {
180  return MeshStorage::faces();
181  }
182 
183 
184  // Sample
185  //- Sample field on surface
186  virtual tmp<scalarField> sample
187  (
188  const volScalarField&
189  ) const;
190 
191  //- Sample field on surface
192  virtual tmp<vectorField> sample
193  (
194  const volVectorField&
195  ) const;
196 
197  //- Sample field on surface
199  (
201  ) const;
202 
203  //- Sample field on surface
205  (
206  const volSymmTensorField&
207  ) const;
208 
209  //- Sample field on surface
210  virtual tmp<tensorField> sample
211  (
212  const volTensorField&
213  ) const;
214 
215  //- Surface sample field on surface
216  virtual tmp<scalarField> sample
217  (
218  const surfaceScalarField&
219  ) const;
220 
221  //- Surface Sample field on surface
222  virtual tmp<vectorField> sample
223  (
224  const surfaceVectorField&
225  ) const;
226 
227  //- Surface sample field on surface
229  (
231  ) const;
232 
233  //- Surface sample field on surface
235  (
237  ) const;
238 
239  //- Surface sample field on surface
240  virtual tmp<tensorField> sample
241  (
242  const surfaceTensorField&
243  ) const;
244 
245 
246  // Interpolate
247 
248  //- Interpolate field on surface
250  (
251  const interpolation<scalar>&
252  ) const;
253 
254  //- Interpolate field on surface
256  (
257  const interpolation<vector>&
258  ) const;
259 
260  //- Interpolate field on surface
262  (
264  ) const;
265 
266  //- Interpolate field on surface
268  (
270  ) const;
271 
272  //- Interpolate field on surface
274  (
275  const interpolation<tensor>&
276  ) const;
277 
278  //- Write
279  virtual void print(Ostream&) const;
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #ifdef NoRepository
290  #include "sampledPatchTemplates.C"
291 #endif
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
dictionary dict
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Definition: sampledPatch.C:235
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An abstract class for surfaces with sampling.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
const List< face > & faces() const
Return const access to the faces.
virtual ~sampledPatch()
Destructor.
Definition: sampledPatch.C:77
const Field< PointType > & points() const
Return reference to global points.
Generic GeometricField class.
const labelList & patchFaceLabels() const
Definition: sampledPatch.H:119
virtual const faceList & faces() const
Faces of surface.
Definition: sampledPatch.H:177
const wordReList & patchNames() const
Definition: sampledPatch.H:107
virtual void print(Ostream &) const
Write.
Definition: sampledPatch.C:369
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A sampledSurface on patches. Non-triangulated by default.
Definition: sampledPatch.H:49
const polyMesh & mesh() const
Access to the underlying mesh.
A class for handling words, derived from string.
Definition: word.H:59
const word & name() const
Name of surface.
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledPatch.C:97
virtual bool update()
Update the surface as required.
Definition: sampledPatch.C:123
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
virtual const pointField & points() const
Points of surface.
Definition: sampledPatch.H:171
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledPatch.C:103
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("sampledPatch")
Runtime type information.
bool interpolate() const
Interpolation requested for surface.
Abstract base class for interpolation.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const labelList & patchIDs() const
Definition: sampledPatch.C:83
A class for managing temporary objects.
Definition: PtrList.H:54
sampledPatch(const word &name, const polyMesh &mesh, const wordReList &patchNames, const bool triangulate=false)
Construct from components.
Definition: sampledPatch.C:47
Namespace for OpenFOAM.
const labelList & patchStart() const
Definition: sampledPatch.H:114