FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

sampledIsoSurfaceCell.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::sampledIsoSurfaceCell
00026 
00027 Description
00028     A sampledSurface defined by a surface of iso value. Always triangulated.
00029     To be used in sampleSurfaces / functionObjects. Recalculates iso surface
00030     only if time changes.
00031 
00032 SourceFiles
00033     sampledIsoSurfaceCell.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef sampledIsoSurfaceCell_H
00038 #define sampledIsoSurfaceCell_H
00039 
00040 #include <sampling/sampledSurface.H>
00041 #include <triSurface/triSurface.H>
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 /*---------------------------------------------------------------------------*\
00049                     Class sampledIsoSurfaceCell Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class sampledIsoSurfaceCell
00053 :
00054     public sampledSurface,
00055     public triSurface
00056 {
00057     // Private data
00058 
00059         //- Field to get isoSurface of
00060         const word isoField_;
00061 
00062         //- iso value
00063         const scalar isoVal_;
00064 
00065         //- Whether to coarse
00066         const Switch regularise_;
00067 
00068         //- Whether to recalculate cell values as average of point values
00069         const Switch average_;
00070 
00071         //- zone name (if restricted to zones)
00072         word zoneName_;
00073 
00074         //- triangles converted to faceList
00075         mutable autoPtr<faceList> facesPtr_;
00076 
00077 
00078         // Recreated for every isoSurface
00079 
00080             //- Time at last call, also track it surface needs an update
00081             mutable label prevTimeIndex_;
00082 
00083             //- For every triangle the original cell in mesh
00084             mutable labelList meshCells_;
00085 
00086 
00087     // Private Member Functions
00088 
00089         //- Create iso surface (if time has changed)
00090         //  Do nothing (and return false) if no update was needed
00091         bool updateGeometry() const;
00092 
00093         //- sample field on faces
00094         template <class Type>
00095         tmp<Field<Type> > sampleField
00096         (
00097             const GeometricField<Type, fvPatchField, volMesh>& vField
00098         ) const;
00099 
00100 
00101         template <class Type>
00102         tmp<Field<Type> >
00103         interpolateField(const interpolation<Type>&) const;
00104 
00105 
00106 public:
00107 
00108     //- Runtime type information
00109     TypeName("sampledIsoSurfaceCell");
00110 
00111 
00112     // Constructors
00113 
00114         //- Construct from dictionary
00115         sampledIsoSurfaceCell
00116         (
00117             const word& name,
00118             const polyMesh& mesh,
00119             const dictionary& dict
00120         );
00121 
00122 
00123     // Destructor
00124 
00125         virtual ~sampledIsoSurfaceCell();
00126 
00127 
00128     // Member Functions
00129 
00130         //- Does the surface need an update?
00131         virtual bool needsUpdate() const;
00132 
00133         //- Mark the surface as needing an update.
00134         //  May also free up unneeded data.
00135         //  Return false if surface was already marked as expired.
00136         virtual bool expire();
00137 
00138         //- Update the surface as required.
00139         //  Do nothing (and return false) if no update was needed
00140         virtual bool update();
00141 
00142 
00143         //- Points of surface
00144         virtual const pointField& points() const
00145         {
00146             return triSurface::points();
00147         }
00148 
00149         //- Faces of surface
00150         virtual const faceList& faces() const
00151         {
00152             if (facesPtr_.empty())
00153             {
00154                 const triSurface& s = *this;
00155 
00156                 facesPtr_.reset(new faceList(s.size()));
00157 
00158                 forAll(s, i)
00159                 {
00160                     facesPtr_()[i] = s[i].triFaceFace();
00161                 }
00162             }
00163             return facesPtr_;
00164         }
00165 
00166 
00167         //- sample field on surface
00168         virtual tmp<scalarField> sample
00169         (
00170             const volScalarField&
00171         ) const;
00172 
00173         //- sample field on surface
00174         virtual tmp<vectorField> sample
00175         (
00176             const volVectorField&
00177         ) const;
00178 
00179         //- sample field on surface
00180         virtual tmp<sphericalTensorField> sample
00181         (
00182             const volSphericalTensorField&
00183         ) const;
00184 
00185         //- sample field on surface
00186         virtual tmp<symmTensorField> sample
00187         (
00188             const volSymmTensorField&
00189         ) const;
00190 
00191         //- sample field on surface
00192         virtual tmp<tensorField> sample
00193         (
00194             const volTensorField&
00195         ) const;
00196 
00197 
00198         //- interpolate field on surface
00199         virtual tmp<scalarField> interpolate
00200         (
00201             const interpolation<scalar>&
00202         ) const;
00203 
00204         //- interpolate field on surface
00205         virtual tmp<vectorField> interpolate
00206         (
00207             const interpolation<vector>&
00208         ) const;
00209 
00210         //- interpolate field on surface
00211         virtual tmp<sphericalTensorField> interpolate
00212         (
00213             const interpolation<sphericalTensor>&
00214         ) const;
00215 
00216         //- interpolate field on surface
00217         virtual tmp<symmTensorField> interpolate
00218         (
00219             const interpolation<symmTensor>&
00220         ) const;
00221 
00222         //- interpolate field on surface
00223         virtual tmp<tensorField> interpolate
00224         (
00225             const interpolation<tensor>&
00226         ) const;
00227 
00228         //- Write
00229         virtual void print(Ostream&) const;
00230 };
00231 
00232 
00233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00234 
00235 } // End namespace Foam
00236 
00237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00238 
00239 #ifdef NoRepository
00240 #   include "sampledIsoSurfaceCellTemplates.C"
00241 #endif
00242 
00243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00244 
00245 #endif
00246 
00247 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines