initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / sampling / sampledSurface / isoSurface / sampledIsoSurface.H
blobccaa4d875005b3189692fa4a34799970a5450acb
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::sampledIsoSurface
28 Description
29     A sampledSurface defined by a surface of iso value. Always triangulated.
30     To be used in sampleSurfaces / functionObjects. Recalculates iso surface
31     only if time changes.
33 SourceFiles
34     sampledIsoSurface.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef sampledIsoSurface_H
39 #define sampledIsoSurface_H
41 #include "isoSurface.H"
42 #include "sampledSurface.H"
43 #include "ZoneIDs.H"
44 #include "fvMeshSubset.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 /*---------------------------------------------------------------------------*\
52                        Class sampledIsoSurface Declaration
53 \*---------------------------------------------------------------------------*/
55 class sampledIsoSurface
57     public sampledSurface
59     // Private data
61         //- Field to get isoSurface of
62         const word isoField_;
64         //- iso value
65         const scalar isoVal_;
67         //- Merge tolerance
68         const scalar mergeTol_;
70         //- Whether to coarse
71         const Switch regularise_;
73         //- Whether to recalculate cell values as average of point values
74         const Switch average_;
76         //- zone name/index (if restricted to zones)
77         mutable cellZoneID zoneID_;
79         //- for zones: patch to put exposed faces into
80         mutable word exposedPatchName_;
82         mutable autoPtr<isoSurface> surfPtr_;
84         //- triangles converted to faceList
85         mutable autoPtr<faceList> facesPtr_;
88         // Recreated for every isoSurface
90             //- Time at last call, also track if surface needs an update
91             mutable label prevTimeIndex_;
93             //- Cached volfield
94             mutable autoPtr<volScalarField> storedVolFieldPtr_;
95             mutable const volScalarField* volFieldPtr_;
97             //- Cached pointfield
98             mutable autoPtr<pointScalarField> storedPointFieldPtr_;
99             mutable const pointScalarField* pointFieldPtr_;
101             // And on subsetted mesh
103                 //- Cached submesh
104                 mutable autoPtr<fvMeshSubset> subMeshPtr_;
106                 //- Cached volfield
107                 mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
108                 mutable const volScalarField* volSubFieldPtr_;
110                 //- Cached pointfield
111                 mutable autoPtr<pointScalarField> storedPointSubFieldPtr_;
112                 mutable const pointScalarField* pointSubFieldPtr_;
116     // Private Member Functions
118         //- Get fields needed to recreate iso surface.
119         void getIsoFields() const;
121         tmp<volScalarField> average
122         (
123             const fvMesh&,
124             const pointScalarField&
125         ) const;
127         tmp<pointScalarField> average
128         (
129             const pointMesh&,
130             const volScalarField& fld
131         ) const;
133         //- Create iso surface (if time has changed)
134         //  Do nothing (and return false) if no update was needed
135         bool updateGeometry() const;
137         //- sample field on faces
138         template <class Type>
139         tmp<Field<Type> > sampleField
140         (
141             const GeometricField<Type, fvPatchField, volMesh>& vField
142         ) const;
145         template <class Type>
146         tmp<Field<Type> >
147         interpolateField(const interpolation<Type>&) const;
150 public:
152     //- Runtime type information
153     TypeName("sampledIsoSurface");
156     // Constructors
158         //- Construct from dictionary
159         sampledIsoSurface
160         (
161             const word& name,
162             const polyMesh& mesh,
163             const dictionary& dict
164         );
167     // Destructor
169         virtual ~sampledIsoSurface();
172     // Member Functions
174         //- Does the surface need an update?
175         virtual bool needsUpdate() const;
177         //- Mark the surface as needing an update.
178         //  May also free up unneeded data.
179         //  Return false if surface was already marked as expired.
180         virtual bool expire();
182         //- Update the surface as required.
183         //  Do nothing (and return false) if no update was needed
184         virtual bool update();
187         //- Points of surface
188         virtual const pointField& points() const
189         {
190             return surface().points();
191         }
193         //- Faces of surface
194         virtual const faceList& faces() const
195         {
196             if (facesPtr_.empty())
197             {
198                 const triSurface& s = surface();
200                 facesPtr_.reset(new faceList(s.size()));
202                 forAll(s, i)
203                 {
204                     facesPtr_()[i] = s[i].triFaceFace();
205                 }
206             }
207             return facesPtr_;
208         }
211         const isoSurface& surface() const
212         {
213             return surfPtr_();
214         }
216         //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
217         void getIsoField();
220         //- sample field on surface
221         virtual tmp<scalarField> sample
222         (
223             const volScalarField&
224         ) const;
226         //- sample field on surface
227         virtual tmp<vectorField> sample
228         (
229             const volVectorField&
230         ) const;
232         //- sample field on surface
233         virtual tmp<sphericalTensorField> sample
234         (
235             const volSphericalTensorField&
236         ) const;
238         //- sample field on surface
239         virtual tmp<symmTensorField> sample
240         (
241             const volSymmTensorField&
242         ) const;
244         //- sample field on surface
245         virtual tmp<tensorField> sample
246         (
247             const volTensorField&
248         ) const;
251         //- interpolate field on surface
252         virtual tmp<scalarField> interpolate
253         (
254             const interpolation<scalar>&
255         ) const;
257         //- interpolate field on surface
258         virtual tmp<vectorField> interpolate
259         (
260             const interpolation<vector>&
261         ) const;
263         //- interpolate field on surface
264         virtual tmp<sphericalTensorField> interpolate
265         (
266             const interpolation<sphericalTensor>&
267         ) const;
269         //- interpolate field on surface
270         virtual tmp<symmTensorField> interpolate
271         (
272             const interpolation<symmTensor>&
273         ) const;
275         //- interpolate field on surface
276         virtual tmp<tensorField> interpolate
277         (
278             const interpolation<tensor>&
279         ) const;
281         //- Write
282         virtual void print(Ostream&) const;
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 } // End namespace Foam
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 #ifdef NoRepository
293 #   include "sampledIsoSurfaceTemplates.C"
294 #endif
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 #endif
300 // ************************************************************************* //