initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / sampling / sampledSurface / distanceSurface / distanceSurface.H
blobb46546abbf29243420d9bf8211574a0292c2476d
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::distanceSurface
28 Description
29     A sampledSurface defined by a distance to a surface.
31 SourceFiles
32     distanceSurface.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef distanceSurface_H
37 #define distanceSurface_H
39 #include "sampledSurface.H"
40 #include "searchableSurface.H"
41 //#include "isoSurfaceCell.H"
42 #include "isoSurface.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                        Class distanceSurface Declaration
51 \*---------------------------------------------------------------------------*/
53 class distanceSurface
55     public sampledSurface
57     // Private data
59         //- Surface
60         const autoPtr<searchableSurface> surfPtr_;
62         //- distance value
63         const scalar distance_;
65         //- signed distance
66         const bool signed_;
68         //- Whether to coarsen
69         const Switch regularise_;
71         //- zone name (if restricted to zones)
72         word zoneName_;
74         //- Track if the surface needs an update
75         mutable bool needsUpdate_;
78         //- Distance to cell centres
79         autoPtr<volScalarField> cellDistancePtr_;
81         //- Distance to points
82         scalarField pointDistance_;
84         //- Constructed iso surface
85         autoPtr<isoSurface> isoSurfPtr_;
87         //- triangles converted to faceList
88         mutable autoPtr<faceList> facesPtr_;
91     // Private Member Functions
93         //- Create iso surface
94         void createGeometry();
96         //- sample field on faces
97         template <class Type>
98         tmp<Field<Type> > sampleField
99         (
100             const GeometricField<Type, fvPatchField, volMesh>& vField
101         ) const;
104         template <class Type>
105         tmp<Field<Type> >
106         interpolateField(const interpolation<Type>&) const;
109 public:
111     //- Runtime type information
112     TypeName("distanceSurface");
115     // Constructors
117         //- Construct from dictionary
118         distanceSurface
119         (
120             const word& name,
121             const polyMesh& mesh,
122             const dictionary& dict
123         );
126     // Destructor
128         virtual ~distanceSurface();
131     // Member Functions
133         //- Does the surface need an update?
134         virtual bool needsUpdate() const;
136         //- Mark the surface as needing an update.
137         //  May also free up unneeded data.
138         //  Return false if surface was already marked as expired.
139         virtual bool expire();
141         //- Update the surface as required.
142         //  Do nothing (and return false) if no update was needed
143         virtual bool update();
145         //- Points of surface
146         virtual const pointField& points() const
147         {
148             return surface().points();
149         }
151         //- Faces of surface
152         virtual const faceList& faces() const
153         {
154             if (facesPtr_.empty())
155             {
156                 const triSurface& s = surface();
158                 facesPtr_.reset(new faceList(s.size()));
160                 forAll(s, i)
161                 {
162                     facesPtr_()[i] = s[i].triFaceFace();
163                 }
164             }
165             return facesPtr_;
166         }
169         const isoSurface& surface() const
170         {
171             return isoSurfPtr_();
172         }
174         //- sample field on surface
175         virtual tmp<scalarField> sample
176         (
177             const volScalarField&
178         ) const;
180         //- sample field on surface
181         virtual tmp<vectorField> sample
182         (
183             const volVectorField&
184         ) const;
186         //- sample field on surface
187         virtual tmp<sphericalTensorField> sample
188         (
189             const volSphericalTensorField&
190         ) const;
192         //- sample field on surface
193         virtual tmp<symmTensorField> sample
194         (
195             const volSymmTensorField&
196         ) const;
198         //- sample field on surface
199         virtual tmp<tensorField> sample
200         (
201             const volTensorField&
202         ) const;
205         //- interpolate field on surface
206         virtual tmp<scalarField> interpolate
207         (
208             const interpolation<scalar>&
209         ) const;
211         //- interpolate field on surface
212         virtual tmp<vectorField> interpolate
213         (
214             const interpolation<vector>&
215         ) const;
217         //- interpolate field on surface
218         virtual tmp<sphericalTensorField> interpolate
219         (
220             const interpolation<sphericalTensor>&
221         ) const;
223         //- interpolate field on surface
224         virtual tmp<symmTensorField> interpolate
225         (
226             const interpolation<symmTensor>&
227         ) const;
229         //- interpolate field on surface
230         virtual tmp<tensorField> interpolate
231         (
232             const interpolation<tensor>&
233         ) const;
235         //- Write
236         virtual void print(Ostream&) const;
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 #ifdef NoRepository
247 #   include "distanceSurfaceTemplates.C"
248 #endif
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 #endif
254 // ************************************************************************* //