sampledDiscreteSurface.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::sampledDiscreteSurface
29 
30 Description
31  A sampledSurface from a triSurfaceMesh.
32  It samples on the points/triangles of a triSurfaceMesh.
33 
34 See Also
35  discreteSurface, sampledSurface
36 
37 SourceFiles
38  sampledDiscreteSurface.C
39  sampledDiscreteSurfaceTemplates.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef sampledDiscreteSurface_H
44 #define sampledDiscreteSurface_H
45 
46 #include "sampledSurface.H"
47 #include "discreteSurface.H"
48 #include "triSurfaceMesh.H"
49 #include "MeshedSurface.H"
50 #include "MeshedSurfacesFwd.H"
51 
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 class sampledDiscreteSurface;
59 
60 /*---------------------------------------------------------------------------*\
61  Class sampledDiscreteSurface Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 :
66  public sampledSurface,
67  public discreteSurface
68 {
69  //- Private typedefs for convenience
72 
73 
74  // Private Member Functions
75 
76  //- Sample volume field onto surface faces
77  template<class Type>
78  tmp<Field<Type>> sampleOnFaces
79  (
80  const interpolation<Type>& sampler
81  ) const;
82 
83  //- Interpolate volume field onto surface points
84  template<class Type>
85  tmp<Field<Type>> sampleOnPoints
86  (
87  const interpolation<Type>& interpolator
88  ) const;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("sampledDiscreteSurface");
95 
96 
97  // Constructors
98 
99  //- Construct from components
101  (
102  const word& name,
103  const polyMesh& mesh,
104  const word& surfaceName,
105  const discreteSurface::samplingSource sampleSource
106  );
107 
108  //- Construct from dictionary
110  (
111  const word& name,
112  const polyMesh& mesh,
113  const dictionary& dict
114  );
115 
116  //- Construct from triSurface
118  (
119  const word& name,
120  const polyMesh& mesh,
121  const triSurface& surface,
122  const word& sampleSourceName
123  );
124 
125 
126  //- Destructor
127  virtual ~sampledDiscreteSurface();
128 
129 
130  // Member Functions
131 
132  //- Does the surface need an update?
133  virtual bool needsUpdate() const;
134 
135  //- Mark the surface as needing an update.
136  // May also free up unneeded data.
137  // Return false if surface was already marked as expired.
138  virtual bool expire();
139 
140  //- Update the surface as required.
141  // Do nothing (and return false) if no update was needed
142  virtual bool update();
143 
144  //- Update the surface using a bound box to limit the searching.
145  // For direct use, i.e. not through sample.
146  // Do nothing (and return false) if no update was needed
147  bool update(const treeBoundBox&);
148 
149  //- Points of surface
150  virtual const pointField& points() const
151  {
152  return MeshStorage::points();
153  }
154 
155  //- Faces of surface
156  virtual const faceList& faces() const
157  {
158  return MeshStorage::surfFaces();
159  }
160 
161  //- Per-face zone/region information
162  virtual const labelList& zoneIds() const
163  {
164  return MeshStorage::zoneIds();
165  }
166 
167  //- Face area vectors
168  virtual const vectorField& Sf() const
169  {
170  return MeshStorage::Sf();
171  }
172 
173  //- Face area magnitudes
174  virtual const scalarField& magSf() const
175  {
176  return MeshStorage::magSf();
177  }
178 
179  //- Face centres
180  virtual const vectorField& Cf() const
181  {
182  return MeshStorage::Cf();
183  }
184 
185  //- If element ids/order of the original surface are kept
186  virtual bool hasFaceIds() const
187  {
188  return MeshStorage::hasFaceIds();
189  }
190 
191  //- List of element ids/order of the original surface,
192  // when keepIds is active.
193  virtual const labelList& originalIds() const
194  {
195  return MeshStorage::originalIds();
196  }
197 
198  //- Sample the volume field onto surface,
199  // store it (temporarily) onto the given registry
200  virtual bool sampleAndStore
201  (
202  const objectRegistry& store,
203  const word& fieldName
204  ) const;
205 
206 
207  // Sample
208 
209  //- Sample volume field onto surface faces
210  virtual tmp<scalarField> sample
211  (
212  const interpolation<scalar>& sampler
213  ) const;
214 
215  //- Sample volume field onto surface faces
216  virtual tmp<vectorField> sample
217  (
218  const interpolation<vector>& sampler
219  ) const;
220 
221  //- Sample volume field onto surface faces
223  (
224  const interpolation<sphericalTensor>& sampler
225  ) const;
226 
227  //- Sample volume field onto surface faces
229  (
230  const interpolation<symmTensor>& sampler
231  ) const;
232 
233  //- Sample volume field onto surface faces
234  virtual tmp<tensorField> sample
235  (
236  const interpolation<tensor>& sampler
237  ) const;
238 
239 
240  // Interpolate
241 
242  //- Interpolate volume field onto surface points
244  (
245  const interpolation<scalar>& interpolator
246  ) const;
247 
248  //- Interpolate volume field onto surface points
250  (
251  const interpolation<vector>& interpolator
252  ) const;
253 
254  //- Interpolate volume field onto surface points
256  (
257  const interpolation<sphericalTensor>& interpolator
258  ) const;
259 
260  //- Interpolate volume field onto surface points
262  (
263  const interpolation<symmTensor>& interpolator
264  ) const;
265 
266  //- Interpolate volume field onto surface points
268  (
269  const interpolation<tensor>& interpolator
270  ) const;
271 
272 
273  // Output
274 
275  //- Write
276  virtual void print(Ostream& os) const;
277 };
278 
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 } // End namespace Foam
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 // #ifdef NoRepository
287 // #include "sampledDiscreteSurfaceTemplates.C"
288 // #endif
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #endif
293 
294 // ************************************************************************* //
Foam::sampledDiscreteSurface::~sampledDiscreteSurface
virtual ~sampledDiscreteSurface()
Destructor.
Definition: sampledDiscreteSurface.C:93
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::discreteSurface::hasFaceIds
virtual bool hasFaceIds() const
If element ids/order of the original surface are kept.
Definition: discreteSurface.H:280
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:87
Foam::sampledDiscreteSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: sampledDiscreteSurface.H:161
Foam::MeshedSurface::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:376
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:362
Foam::sampledDiscreteSurface::print
virtual void print(Ostream &os) const
Write.
Definition: sampledDiscreteSurface.C:229
Foam::sampledDiscreteSurface::sampleAndStore
virtual bool sampleAndStore(const objectRegistry &store, const word &fieldName) const
Sample the volume field onto surface,.
Definition: sampledDiscreteSurface.C:132
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sampledDiscreteSurface::sampledDiscreteSurface
sampledDiscreteSurface(const word &name, const polyMesh &mesh, const word &surfaceName, const discreteSurface::samplingSource sampleSource)
Construct from components.
Definition: sampledDiscreteSurface.C:54
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::sampledDiscreteSurface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledDiscreteSurface.H:173
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:382
Foam::Field< vector >
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:70
sampledSurface.H
Foam::discreteSurface
The basis for sampling from triSurfaceMesh. It samples on the points/triangles of the triSurface.
Definition: discreteSurface.H:91
Foam::sampledDiscreteSurface::Sf
virtual const vectorField & Sf() const
Face area vectors.
Definition: sampledDiscreteSurface.H:167
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
Foam::sampledDiscreteSurface
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles of a triSurfaceMesh.
Definition: sampledDiscreteSurface.H:63
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::discreteSurface::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: discreteSurface.H:274
Foam::sampledDiscreteSurface::TypeName
TypeName("sampledDiscreteSurface")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledDiscreteSurface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledDiscreteSurface.H:149
Foam::sampledDiscreteSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledDiscreteSurface.C:142
Foam::sampledDiscreteSurface::originalIds
virtual const labelList & originalIds() const
List of element ids/order of the original surface,.
Definition: sampledDiscreteSurface.H:192
discreteSurface.H
Foam::sampledDiscreteSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledDiscreteSurface.C:105
Foam::sampledDiscreteSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledDiscreteSurface.C:119
Foam::List< face >
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:308
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::discreteSurface::originalIds
virtual const labelList & originalIds() const
List of element ids/order of the original surface,.
Definition: discreteSurface.H:287
Foam::sampledDiscreteSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledDiscreteSurface.C:99
Foam::MeshedSurface::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:388
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:302
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::sampledDiscreteSurface::hasFaceIds
virtual bool hasFaceIds() const
If element ids/order of the original surface are kept.
Definition: sampledDiscreteSurface.H:185
MeshedSurfacesFwd.H
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation to nodes requested for surface.
Definition: sampledSurface.H:326
triSurfaceMesh.H
Foam::discreteSurface::samplingSource
samplingSource
Types of communications.
Definition: discreteSurface.H:97
Foam::sampledDiscreteSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledDiscreteSurface.H:155
Foam::sampledDiscreteSurface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledDiscreteSurface.H:179
MeshedSurface.H