ENH: patchCloudSet: new sampledSet
[OpenFOAM-1.7.x.git] / src / sampling / sampledSurface / sampledTriSurfaceMesh / sampledTriSurfaceMesh.H
blob0bdbf75b0c9091bd8578bd349242a18b2691cbc7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2010-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Class
25     Foam::sampledTriSurfaceMesh
27 Description
28     A sampledSurface from a triSurfaceMesh. It samples on the points/triangles
29     of the triSurface.
31     It samples using the cell nearest to the triangle centre so does
32     not check the cell the centre is actually in ...
34     In parallel every processor just operates on the part of the surface
35     where the face centres are inside the mesh. It is then up to the
36     caller to stitch the partial surfaces together.
38 SourceFiles
39     sampledTriSurfaceMesh.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef sampledTriSurfaceMesh_H
44 #define sampledTriSurfaceMesh_H
46 #include "sampledSurface.H"
47 #include "triSurfaceMesh.H"
48 #include "MeshedSurface.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 /*---------------------------------------------------------------------------*\
56                        Class sampledTriSurfaceMesh Declaration
57 \*---------------------------------------------------------------------------*/
59 class sampledTriSurfaceMesh
61     public sampledSurface,
62     public MeshedSurface<face>
64     //- Private typedefs for convenience
65         typedef MeshedSurface<face> MeshStorage;
67     // Private data
69         //- Surface to sample on
70         const triSurfaceMesh surface_;
72         //- Track if the surface needs an update
73         mutable bool needsUpdate_;
75         //- From local surface triangle to mesh cell.
76         labelList cellLabels_;
78         //- From local surface back to surface_
79         labelList pointToFace_;
82     // Private Member Functions
84         //- sample field on faces
85         template <class Type>
86         tmp<Field<Type> > sampleField
87         (
88             const GeometricField<Type, fvPatchField, volMesh>& vField
89         ) const;
92         template <class Type>
93         tmp<Field<Type> >
94         interpolateField(const interpolation<Type>&) const;
96 public:
98     //- Runtime type information
99     TypeName("sampledTriSurfaceMesh");
102     // Constructors
104         //- Construct from components
105         sampledTriSurfaceMesh
106         (
107             const word& name,
108             const polyMesh& mesh,
109             const word& surfaceName
110         );
112         //- Construct from dictionary
113         sampledTriSurfaceMesh
114         (
115             const word& name,
116             const polyMesh& mesh,
117             const dictionary& dict
118         );
121     // Destructor
123         virtual ~sampledTriSurfaceMesh();
126     // Member Functions
128         //- Does the surface need an update?
129         virtual bool needsUpdate() const;
131         //- Mark the surface as needing an update.
132         //  May also free up unneeded data.
133         //  Return false if surface was already marked as expired.
134         virtual bool expire();
136         //- Update the surface as required.
137         //  Do nothing (and return false) if no update was needed
138         virtual bool update();
141         //- Points of surface
142         virtual const pointField& points() const
143         {
144             return MeshStorage::points();
145         }
147         //- Faces of surface
148         virtual const faceList& faces() const
149         {
150             return MeshStorage::faces();
151         }
154         //- sample field on surface
155         virtual tmp<scalarField> sample
156         (
157             const volScalarField&
158         ) const;
160         //- sample field on surface
161         virtual tmp<vectorField> sample
162         (
163             const volVectorField&
164         ) const;
166         //- sample field on surface
167         virtual tmp<sphericalTensorField> sample
168         (
169             const volSphericalTensorField&
170         ) const;
172         //- sample field on surface
173         virtual tmp<symmTensorField> sample
174         (
175             const volSymmTensorField&
176         ) const;
178         //- sample field on surface
179         virtual tmp<tensorField> sample
180         (
181             const volTensorField&
182         ) const;
185         //- interpolate field on surface
186         virtual tmp<scalarField> interpolate
187         (
188             const interpolation<scalar>&
189         ) const;
192         //- interpolate field on surface
193         virtual tmp<vectorField> interpolate
194         (
195             const interpolation<vector>&
196         ) const;
198         //- interpolate field on surface
199         virtual tmp<sphericalTensorField> interpolate
200         (
201             const interpolation<sphericalTensor>&
202         ) const;
204         //- interpolate field on surface
205         virtual tmp<symmTensorField> interpolate
206         (
207             const interpolation<symmTensor>&
208         ) const;
210         //- interpolate field on surface
211         virtual tmp<tensorField> interpolate
212         (
213             const interpolation<tensor>&
214         ) const;
216         //- Write
217         virtual void print(Ostream&) const;
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 } // End namespace Foam
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 #ifdef NoRepository
228 #   include "sampledTriSurfaceMeshTemplates.C"
229 #endif
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 #endif
235 // ************************************************************************* //