initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / sampling / sampledSurface / sampledCuttingPlane / sampledCuttingPlane.H
blobfcf14db8bd7f1dfe02602eef6867b0a0c1733c47
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::sampledCuttingPlane
28 Description
29     A sampledSurface defined by a plane
31 SourceFiles
32     sampledCuttingPlane.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef sampledCuttingPlane_H
37 #define sampledCuttingPlane_H
39 #include "sampledSurface.H"
40 #include "isoSurface.H"
41 #include "plane.H"
42 #include "ZoneIDs.H"
43 #include "fvMeshSubset.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                        Class sampledCuttingPlane Declaration
52 \*---------------------------------------------------------------------------*/
54 class sampledCuttingPlane
56     public sampledSurface
58     // Private data
60         //- Plane
61         const plane plane_;
63         //- Merge tolerance
64         const scalar mergeTol_;
66         //- Whether to coarsen
67         const Switch regularise_;
69         //- zone name/index (if restricted to zones)
70         mutable cellZoneID zoneID_;
72         //- for zones: patch to put exposed faces into
73         mutable word exposedPatchName_;
75         //- Track if the surface needs an update
76         mutable bool needsUpdate_;
79         //- Optional subsetted mesh
80         autoPtr<fvMeshSubset> subMeshPtr_;
82         //- Distance to cell centres
83         autoPtr<volScalarField> cellDistancePtr_;
85         //- Distance to points
86         scalarField pointDistance_;
88         //- Constructed iso surface
89         autoPtr<isoSurface> isoSurfPtr_;
91         //- triangles converted to faceList
92         mutable autoPtr<faceList> facesPtr_;
95     // Private Member Functions
97         //- Create iso surface
98         void createGeometry();
100         //- sample field on faces
101         template <class Type>
102         tmp<Field<Type> > sampleField
103         (
104             const GeometricField<Type, fvPatchField, volMesh>& vField
105         ) const;
108         template <class Type>
109         tmp<Field<Type> >
110         interpolateField(const interpolation<Type>&) const;
113 public:
115     //- Runtime type information
116     TypeName("sampledCuttingPlane");
119     // Constructors
121         //- Construct from dictionary
122         sampledCuttingPlane
123         (
124             const word& name,
125             const polyMesh& mesh,
126             const dictionary& dict
127         );
130     // Destructor
132         virtual ~sampledCuttingPlane();
135     // Member Functions
137         //- Does the surface need an update?
138         virtual bool needsUpdate() const;
140         //- Mark the surface as needing an update.
141         //  May also free up unneeded data.
142         //  Return false if surface was already marked as expired.
143         virtual bool expire();
145         //- Update the surface as required.
146         //  Do nothing (and return false) if no update was needed
147         virtual bool update();
149         //- Points of surface
150         virtual const pointField& points() const
151         {
152             return surface().points();
153         }
155         //- Faces of surface
156         virtual const faceList& faces() const
157         {
158             if (facesPtr_.empty())
159             {
160                 const triSurface& s = surface();
162                 facesPtr_.reset(new faceList(s.size()));
164                 forAll(s, i)
165                 {
166                     facesPtr_()[i] = s[i].triFaceFace();
167                 }
168             }
169             return facesPtr_;
170         }
173         const isoSurface& surface() const
174         {
175             return isoSurfPtr_();
176         }
178         //- sample field on surface
179         virtual tmp<scalarField> sample
180         (
181             const volScalarField&
182         ) const;
184         //- sample field on surface
185         virtual tmp<vectorField> sample
186         (
187             const volVectorField&
188         ) const;
190         //- sample field on surface
191         virtual tmp<sphericalTensorField> sample
192         (
193             const volSphericalTensorField&
194         ) const;
196         //- sample field on surface
197         virtual tmp<symmTensorField> sample
198         (
199             const volSymmTensorField&
200         ) const;
202         //- sample field on surface
203         virtual tmp<tensorField> sample
204         (
205             const volTensorField&
206         ) const;
209         //- interpolate field on surface
210         virtual tmp<scalarField> interpolate
211         (
212             const interpolation<scalar>&
213         ) const;
215         //- interpolate field on surface
216         virtual tmp<vectorField> interpolate
217         (
218             const interpolation<vector>&
219         ) const;
221         //- interpolate field on surface
222         virtual tmp<sphericalTensorField> interpolate
223         (
224             const interpolation<sphericalTensor>&
225         ) const;
227         //- interpolate field on surface
228         virtual tmp<symmTensorField> interpolate
229         (
230             const interpolation<symmTensor>&
231         ) const;
233         //- interpolate field on surface
234         virtual tmp<tensorField> interpolate
235         (
236             const interpolation<tensor>&
237         ) const;
239         //- Write
240         virtual void print(Ostream&) const;
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 } // End namespace Foam
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 #ifdef NoRepository
251 #   include "sampledCuttingPlaneTemplates.C"
252 #endif
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 #endif
258 // ************************************************************************* //