ENH: patchCloudSet: new sampledSet
[OpenFOAM-1.7.x.git] / src / sampling / sampledSurface / sampledCuttingPlane / sampledCuttingPlane.H
blobacf88855bf150f9061afd33b454d7d082df96390
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-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::sampledCuttingPlane
27 Description
28     A sampledSurface defined by a plane
30 SourceFiles
31     sampledCuttingPlane.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef sampledCuttingPlane_H
36 #define sampledCuttingPlane_H
38 #include "sampledSurface.H"
39 #include "isoSurface.H"
40 #include "plane.H"
41 #include "ZoneIDs.H"
42 #include "fvMeshSubset.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                        Class sampledCuttingPlane Declaration
51 \*---------------------------------------------------------------------------*/
53 class sampledCuttingPlane
55     public sampledSurface
57     // Private data
59         //- Plane
60         const plane plane_;
62         //- Merge tolerance
63         const scalar mergeTol_;
65         //- Whether to coarsen
66         const Switch regularise_;
68         //- zone name/index (if restricted to zones)
69         mutable cellZoneID zoneID_;
71         //- for zones: patch to put exposed faces into
72         mutable word exposedPatchName_;
74         //- Track if the surface needs an update
75         mutable bool needsUpdate_;
78         //- Optional subsetted mesh
79         autoPtr<fvMeshSubset> subMeshPtr_;
81         //- Distance to cell centres
82         autoPtr<volScalarField> cellDistancePtr_;
84         //- Distance to points
85         scalarField pointDistance_;
87         //- Constructed iso surface
88         autoPtr<isoSurface> isoSurfPtr_;
90         //- triangles converted to faceList
91         mutable autoPtr<faceList> facesPtr_;
94     // Private Member Functions
96         //- Create iso surface
97         void createGeometry();
99         //- sample field on faces
100         template <class Type>
101         tmp<Field<Type> > sampleField
102         (
103             const GeometricField<Type, fvPatchField, volMesh>& vField
104         ) const;
107         template <class Type>
108         tmp<Field<Type> >
109         interpolateField(const interpolation<Type>&) const;
112 public:
114     //- Runtime type information
115     TypeName("sampledCuttingPlane");
118     // Constructors
120         //- Construct from dictionary
121         sampledCuttingPlane
122         (
123             const word& name,
124             const polyMesh& mesh,
125             const dictionary& dict
126         );
129     // Destructor
131         virtual ~sampledCuttingPlane();
134     // Member Functions
136         //- Does the surface need an update?
137         virtual bool needsUpdate() const;
139         //- Mark the surface as needing an update.
140         //  May also free up unneeded data.
141         //  Return false if surface was already marked as expired.
142         virtual bool expire();
144         //- Update the surface as required.
145         //  Do nothing (and return false) if no update was needed
146         virtual bool update();
148         //- Points of surface
149         virtual const pointField& points() const
150         {
151             return surface().points();
152         }
154         //- Faces of surface
155         virtual const faceList& faces() const
156         {
157             if (facesPtr_.empty())
158             {
159                 const triSurface& s = surface();
161                 facesPtr_.reset(new faceList(s.size()));
163                 forAll(s, i)
164                 {
165                     facesPtr_()[i] = s[i].triFaceFace();
166                 }
167             }
168             return facesPtr_;
169         }
172         const isoSurface& surface() const
173         {
174             return isoSurfPtr_();
175         }
177         //- sample field on surface
178         virtual tmp<scalarField> sample
179         (
180             const volScalarField&
181         ) const;
183         //- sample field on surface
184         virtual tmp<vectorField> sample
185         (
186             const volVectorField&
187         ) const;
189         //- sample field on surface
190         virtual tmp<sphericalTensorField> sample
191         (
192             const volSphericalTensorField&
193         ) const;
195         //- sample field on surface
196         virtual tmp<symmTensorField> sample
197         (
198             const volSymmTensorField&
199         ) const;
201         //- sample field on surface
202         virtual tmp<tensorField> sample
203         (
204             const volTensorField&
205         ) const;
208         //- interpolate field on surface
209         virtual tmp<scalarField> interpolate
210         (
211             const interpolation<scalar>&
212         ) const;
214         //- interpolate field on surface
215         virtual tmp<vectorField> interpolate
216         (
217             const interpolation<vector>&
218         ) const;
220         //- interpolate field on surface
221         virtual tmp<sphericalTensorField> interpolate
222         (
223             const interpolation<sphericalTensor>&
224         ) const;
226         //- interpolate field on surface
227         virtual tmp<symmTensorField> interpolate
228         (
229             const interpolation<symmTensor>&
230         ) const;
232         //- interpolate field on surface
233         virtual tmp<tensorField> interpolate
234         (
235             const interpolation<tensor>&
236         ) const;
238         //- Write
239         virtual void print(Ostream&) const;
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 } // End namespace Foam
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 #ifdef NoRepository
250 #   include "sampledCuttingPlaneTemplates.C"
251 #endif
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 #endif
257 // ************************************************************************* //