sampledTriSurfaceMesh.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-2015 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::sampledTriSurfaceMesh
26 
27 Description
28  A sampledSurface from a triSurfaceMesh. It samples on the points/triangles
29  of the triSurface.
30 
31  - it either samples cells or (non-coupled) boundary faces
32 
33  - 6 different modes:
34  - source=cells, interpolate=false:
35  finds per triangle centre the nearest cell centre and uses its value
36  - source=cells, interpolate=true
37  finds per triangle centre the nearest cell centre.
38  Per surface point checks if this nearest cell is the one containing
39  point; otherwise projects the point onto the nearest point on
40  the boundary of the cell (to make sure interpolateCellPoint
41  gets a valid location)
42 
43  - source=insideCells, interpolate=false:
44  finds per triangle centre the cell containing it and uses its value.
45  Trims triangles outside mesh.
46  - source=insideCells, interpolate=true
47  Per surface point interpolate cell containing it.
48 
49  - source=boundaryFaces, interpolate=false:
50  finds per triangle centre the nearest point on the boundary
51  (uncoupled faces only) and uses the value (or 0 if the nearest
52  is on an empty boundary)
53  - source=boundaryFaces, interpolate=true:
54  finds per triangle centre the nearest point on the boundary
55  (uncoupled faces only).
56  Per surface point projects the point onto this boundary face
57  (to make sure interpolateCellPoint gets a valid location)
58 
59  - since it finds a nearest per triangle each triangle is guaranteed
60  to be on one processor only. So after stitching (by sampledSurfaces)
61  the original surface should be complete.
62 
63 SourceFiles
64  sampledTriSurfaceMesh.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef sampledTriSurfaceMesh_H
69 #define sampledTriSurfaceMesh_H
70 
71 #include "sampledSurface.H"
72 #include "triSurfaceMesh.H"
73 #include "MeshedSurface.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 class treeDataFace;
81 class meshSearch;
82 
83 /*---------------------------------------------------------------------------*\
84  Class sampledTriSurfaceMesh Declaration
85 \*---------------------------------------------------------------------------*/
86 
88 :
89  public sampledSurface,
90  public MeshedSurface<face>
91 {
92 public:
93  //- Types of communications
94  enum samplingSource
95  {
99  };
100 
101 private:
102 
103  //- Private typedefs for convenience
105 
106 
107  // Private data
108 
109  static const NamedEnum<samplingSource, 3> samplingSourceNames_;
110 
111  //- Surface to sample on
112  const triSurfaceMesh surface_;
113 
114  //- Whether to sample internal cell values or boundary values
115  const samplingSource sampleSource_;
116 
117  //- Track if the surface needs an update
118  mutable bool needsUpdate_;
119 
120  //- Search tree for all non-coupled boundary faces
121  mutable autoPtr<indexedOctree<treeDataFace> > boundaryTreePtr_;
122 
123  //- From local surface triangle to mesh cell/face.
124  labelList sampleElements_;
125 
126  //- Local points to sample per point
127  pointField samplePoints_;
128 
129 
130  // Private Member Functions
131 
132  //- Get tree of all non-coupled boundary faces
133  const indexedOctree<treeDataFace>& nonCoupledboundaryTree() const;
134 
135  //- Sample field on faces
136  template<class Type>
137  tmp<Field<Type> > sampleField
138  (
140  ) const;
141 
142 
143  template<class Type>
145  interpolateField(const interpolation<Type>&) const;
146 
147  bool update(const meshSearch& meshSearcher);
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("sampledTriSurfaceMesh");
153 
154 
155  // Constructors
156 
157  //- Construct from components
159  (
160  const word& name,
161  const polyMesh& mesh,
162  const word& surfaceName,
163  const samplingSource sampleSource
164  );
165 
166  //- Construct from dictionary
168  (
169  const word& name,
170  const polyMesh& mesh,
171  const dictionary& dict
172  );
173 
174  //- Construct from triSurface
176  (
177  const word& name,
178  const polyMesh& mesh,
179  const triSurface& surface,
180  const word& sampleSourceName
181  );
182 
183 
184  //- Destructor
185  virtual ~sampledTriSurfaceMesh();
186 
187 
188  // Member Functions
189 
190  //- Does the surface need an update?
191  virtual bool needsUpdate() const;
192 
193  //- Mark the surface as needing an update.
194  // May also free up unneeded data.
195  // Return false if surface was already marked as expired.
196  virtual bool expire();
197 
198  //- Update the surface as required.
199  // Do nothing (and return false) if no update was needed
200  virtual bool update();
201 
202  //- Update the surface using a bound box to limit the searching.
203  // For direct use, i.e. not through sample.
204  // Do nothing (and return false) if no update was needed
205  bool update(const treeBoundBox&);
206 
207  //- Points of surface
208  virtual const pointField& points() const
209  {
210  return MeshStorage::points();
211  }
212 
213  //- Faces of surface
214  virtual const faceList& faces() const
215  {
216  return MeshStorage::faces();
217  }
218 
219 
220  //- Sample field on surface
221  virtual tmp<scalarField> sample
222  (
223  const volScalarField&
224  ) const;
225 
226  //- Sample field on surface
227  virtual tmp<vectorField> sample
228  (
229  const volVectorField&
230  ) const;
231 
232  //- Sample field on surface
234  (
236  ) const;
237 
238  //- Sample field on surface
240  (
241  const volSymmTensorField&
242  ) const;
243 
244  //- Sample field on surface
245  virtual tmp<tensorField> sample
246  (
247  const volTensorField&
248  ) const;
249 
250 
251  //- Interpolate field on surface
253  (
254  const interpolation<scalar>&
255  ) const;
256 
257 
258  //- Interpolate field on surface
260  (
261  const interpolation<vector>&
262  ) const;
263 
264  //- Interpolate field on surface
266  (
268  ) const;
269 
270  //- Interpolate field on surface
272  (
274  ) const;
275 
276  //- Interpolate field on surface
278  (
279  const interpolation<tensor>&
280  ) const;
281 
282  //- Write
283  virtual void print(Ostream&) const;
284 };
285 
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 } // End namespace Foam
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #ifdef NoRepository
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
virtual bool needsUpdate() const
Does the surface need an update?
An abstract class for surfaces with sampling.
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles of the triSurface...
virtual const faceList & faces() const
Faces of surface.
TypeName("sampledTriSurfaceMesh")
Runtime type information.
Triangulated surface description with patch information.
Definition: triSurface.H:57
A class for handling words, derived from string.
Definition: word.H:59
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
const word & name() const
Name of surface.
Abstract base class for interpolation.
const polyMesh & mesh() const
Access to the underlying mesh.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual const pointField & points() const
Points of surface.
Namespace for OpenFOAM.
virtual ~sampledTriSurfaceMesh()
Destructor.
dictionary dict
virtual void print(Ostream &) const
Write.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
const List< face > & faces() const
Return const access to the faces.
sampledTriSurfaceMesh(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
virtual bool update()
Update the surface as required.
virtual bool expire()
Mark the surface as needing an update.
bool interpolate() const
Interpolation requested for surface.
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
Generic GeometricField class.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
samplingSource
Types of communications.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
IOoject and searching on triSurface.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
const Field< PointType > & points() const
Return reference to global points.