ENH: patchCloudSet: new sampledSet
[OpenFOAM-1.7.x.git] / src / sampling / sampledSurface / isoSurface / sampledIsoSurfaceCell.H
blob9b6e311811fd993e22d797e4bb5ca2b6161243ed
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::sampledIsoSurfaceCell
27 Description
28     A sampledSurface defined by a surface of iso value. Always triangulated.
29     To be used in sampleSurfaces / functionObjects. Recalculates iso surface
30     only if time changes.
32 SourceFiles
33     sampledIsoSurfaceCell.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef sampledIsoSurfaceCell_H
38 #define sampledIsoSurfaceCell_H
40 #include "sampledSurface.H"
41 #include "triSurface.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                     Class sampledIsoSurfaceCell Declaration
50 \*---------------------------------------------------------------------------*/
52 class sampledIsoSurfaceCell
54     public sampledSurface,
55     public triSurface
57     // Private data
59         //- Field to get isoSurface of
60         const word isoField_;
62         //- iso value
63         const scalar isoVal_;
65         //- Whether to coarse
66         const Switch regularise_;
68         //- Whether to recalculate cell values as average of point values
69         const Switch average_;
71         //- zone name (if restricted to zones)
72         word zoneName_;
74         //- triangles converted to faceList
75         mutable autoPtr<faceList> facesPtr_;
78         // Recreated for every isoSurface
80             //- Time at last call, also track it surface needs an update
81             mutable label prevTimeIndex_;
83             //- For every triangle the original cell in mesh
84             mutable labelList meshCells_;
87     // Private Member Functions
89         //- Create iso surface (if time has changed)
90         //  Do nothing (and return false) if no update was needed
91         bool updateGeometry() const;
93         //- sample field on faces
94         template <class Type>
95         tmp<Field<Type> > sampleField
96         (
97             const GeometricField<Type, fvPatchField, volMesh>& vField
98         ) const;
101         template <class Type>
102         tmp<Field<Type> >
103         interpolateField(const interpolation<Type>&) const;
106 public:
108     //- Runtime type information
109     TypeName("sampledIsoSurfaceCell");
112     // Constructors
114         //- Construct from dictionary
115         sampledIsoSurfaceCell
116         (
117             const word& name,
118             const polyMesh& mesh,
119             const dictionary& dict
120         );
123     // Destructor
125         virtual ~sampledIsoSurfaceCell();
128     // Member Functions
130         //- Does the surface need an update?
131         virtual bool needsUpdate() const;
133         //- Mark the surface as needing an update.
134         //  May also free up unneeded data.
135         //  Return false if surface was already marked as expired.
136         virtual bool expire();
138         //- Update the surface as required.
139         //  Do nothing (and return false) if no update was needed
140         virtual bool update();
143         //- Points of surface
144         virtual const pointField& points() const
145         {
146             return triSurface::points();
147         }
149         //- Faces of surface
150         virtual const faceList& faces() const
151         {
152             if (facesPtr_.empty())
153             {
154                 const triSurface& s = *this;
156                 facesPtr_.reset(new faceList(s.size()));
158                 forAll(s, i)
159                 {
160                     facesPtr_()[i] = s[i].triFaceFace();
161                 }
162             }
163             return facesPtr_;
164         }
167         //- sample field on surface
168         virtual tmp<scalarField> sample
169         (
170             const volScalarField&
171         ) const;
173         //- sample field on surface
174         virtual tmp<vectorField> sample
175         (
176             const volVectorField&
177         ) const;
179         //- sample field on surface
180         virtual tmp<sphericalTensorField> sample
181         (
182             const volSphericalTensorField&
183         ) const;
185         //- sample field on surface
186         virtual tmp<symmTensorField> sample
187         (
188             const volSymmTensorField&
189         ) const;
191         //- sample field on surface
192         virtual tmp<tensorField> sample
193         (
194             const volTensorField&
195         ) const;
198         //- interpolate field on surface
199         virtual tmp<scalarField> interpolate
200         (
201             const interpolation<scalar>&
202         ) const;
204         //- interpolate field on surface
205         virtual tmp<vectorField> interpolate
206         (
207             const interpolation<vector>&
208         ) const;
210         //- interpolate field on surface
211         virtual tmp<sphericalTensorField> interpolate
212         (
213             const interpolation<sphericalTensor>&
214         ) const;
216         //- interpolate field on surface
217         virtual tmp<symmTensorField> interpolate
218         (
219             const interpolation<symmTensor>&
220         ) const;
222         //- interpolate field on surface
223         virtual tmp<tensorField> interpolate
224         (
225             const interpolation<tensor>&
226         ) const;
228         //- Write
229         virtual void print(Ostream&) const;
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 } // End namespace Foam
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 #ifdef NoRepository
240 #   include "sampledIsoSurfaceCellTemplates.C"
241 #endif
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 #endif
247 // ************************************************************************* //