OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

sampledSurface.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::sampledSurface
00027 
00028 Description
00029     An abstract class for surfaces with sampling.
00030 
00031     The constructors for the derived classes should generally start in a
00032     'expired' condition (ie, needsUpdate() == true) and rely on a
00033     subsequent call to the update() method to complete the initialization.
00034     Delaying the final construction as late as possible allows the
00035     construction of surfaces that may depend on intermediate calculation
00036     results (eg, iso-surfaces) and also avoids the unnecessary
00037     reconstruction of surfaces between sampling intervals.
00038 
00039     It is the responsibility of the caller to ensure that the surface
00040     update() is called before the surface is used.  The update() method
00041     implementation should do nothing when the surface is already
00042     up-to-date.
00043 
00044 SourceFiles
00045     sampledSurface.C
00046     sampledSurfaceTemplates.C
00047 
00048 \*---------------------------------------------------------------------------*/
00049 
00050 #ifndef sampledSurface_H
00051 #define sampledSurface_H
00052 
00053 #include "pointField.H"
00054 #include "word.H"
00055 #include "labelList.H"
00056 #include "faceList.H"
00057 #include "typeInfo.H"
00058 #include "runTimeSelectionTables.H"
00059 #include "autoPtr.H"
00060 #include "volFieldsFwd.H"
00061 #include "polyMesh.H"
00062 #include "coordinateSystems.H"
00063 #include "interpolation.H"
00064 
00065 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00066 
00067 namespace Foam
00068 {
00069 
00070 /*---------------------------------------------------------------------------*\
00071                       Class sampledSurface Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 class sampledSurface
00075 {
00076     // Private data
00077 
00078         //- Name of sample surface
00079         word name_;
00080 
00081         //- Reference to mesh
00082         const polyMesh& mesh_;
00083 
00084         //- Do we intend to interpolate the information?
00085         bool interpolate_;
00086 
00087 
00088     // Demand-driven data
00089 
00090         //- Face area vectors
00091         mutable vectorField* SfPtr_;
00092 
00093         //- Mag face area vectors
00094         mutable scalarField* magSfPtr_;
00095 
00096         //- Face centres
00097         mutable vectorField* CfPtr_;
00098 
00099         //- Total surface area
00100         mutable scalar area_;
00101 
00102     // Make geometric data
00103 
00104         //- Make Sf
00105         void makeSf() const;
00106 
00107         //- Make magSf
00108         void makeMagSf() const;
00109 
00110         //- Make Cf
00111         void makeCf() const;
00112 
00113     // Service methods
00114 
00115         //- Check field size matches surface size
00116         template<class Type>
00117         bool checkFieldSize(const Field<Type>&) const;
00118 
00119         //- Project field onto surface
00120         template<class ReturnType, class Type>
00121         void project
00122         (
00123             Field<ReturnType>&,
00124             const Field<Type>&
00125         ) const;
00126 
00127         //- Project field onto surface
00128         template<class ReturnType, class Type>
00129         void project
00130         (
00131             Field<ReturnType>&,
00132             const tmp<Field<Type> >&
00133         ) const;
00134 
00135         //- Project field onto surface
00136         template<class ReturnType, class Type>
00137         tmp<Field<ReturnType> > project(const tmp<Field<Type> >&) const;
00138 
00139 protected:
00140 
00141     // Protected Member functions
00142 
00143         virtual void clearGeom() const;
00144 
00145 public:
00146 
00147     //- Runtime type information
00148       TypeName("sampledSurface");
00149 
00150 
00151     // Declare run-time constructor selection table
00152 
00153         declareRunTimeSelectionTable
00154         (
00155             autoPtr,
00156             sampledSurface,
00157             word,
00158             (
00159                 const word& name,
00160                 const polyMesh& mesh,
00161                 const dictionary& dict
00162             ),
00163             (name, mesh, dict)
00164         );
00165 
00166 
00167         //- Class used for the PtrLists read-construction
00168         class iNew
00169         {
00170             //- Reference to the volume mesh
00171             const polyMesh& mesh_;
00172 
00173         public:
00174 
00175             iNew(const polyMesh& mesh)
00176             :
00177                 mesh_(mesh)
00178             {}
00179 
00180             autoPtr<sampledSurface> operator()(Istream& is) const
00181             {
00182                 word name(is);
00183                 dictionary dict(is);
00184 
00185                 return sampledSurface::New(name, mesh_, dict);
00186             }
00187         };
00188 
00189 
00190     // Constructors
00191 
00192         //- Construct from name, mesh
00193         sampledSurface
00194         (
00195             const word& name,
00196             const polyMesh&
00197         );
00198 
00199         //- Construct from dictionary
00200         sampledSurface
00201         (
00202             const word& name,
00203             const polyMesh&,
00204             const dictionary&
00205         );
00206 
00207         //- Clone
00208         autoPtr<sampledSurface> clone() const
00209         {
00210             notImplemented("autoPtr<sampledSurface> clone() const");
00211             return autoPtr<sampledSurface>(NULL);
00212         }
00213 
00214 
00215     // Selectors
00216 
00217         //- Return a reference to the selected surface
00218         static autoPtr<sampledSurface> New
00219         (
00220             const word& name,
00221             const polyMesh&,
00222             const dictionary&
00223         );
00224 
00225 
00226     // Destructor
00227 
00228         virtual ~sampledSurface();
00229 
00230 
00231     // Member Functions
00232 
00233       // Access
00234 
00235         //- Access to the underlying mesh
00236         const polyMesh& mesh() const
00237         {
00238             return mesh_;
00239         }
00240 
00241         //- Name of surface
00242         const word& name() const
00243         {
00244             return name_;
00245         }
00246 
00247         //- interpolation requested for surface
00248         bool interpolate() const
00249         {
00250             return interpolate_;
00251         }
00252 
00253         //- Does the surface need an update?
00254         virtual bool needsUpdate() const = 0;
00255 
00256         //- Mark the surface as needing an update.
00257         //  May also free up unneeded data.
00258         //  Return false if surface was already marked as expired.
00259         virtual bool expire() = 0;
00260 
00261         //- Update the surface as required.
00262         //  Do nothing (and return false) if no update was required
00263         virtual bool update() = 0;
00264 
00265 
00266         //- Points of surface
00267         virtual const pointField& points() const = 0;
00268 
00269         //- Faces of surface
00270         virtual const faceList& faces() const = 0;
00271 
00272         //- Return face area vectors
00273         virtual const vectorField& Sf() const;
00274 
00275         //- Return face area magnitudes
00276         virtual const scalarField& magSf() const;
00277 
00278         //- Return face centres as vectorField
00279         virtual const vectorField& Cf() const;
00280 
00281         //- The total surface area
00282         scalar area() const;
00283 
00284         //- Integration of a field across the surface
00285         template<class Type>
00286         Type integrate(const Field<Type>&) const;
00287 
00288         //- Integration of a field across the surface
00289         template<class Type>
00290         Type integrate(const tmp<Field<Type> >&) const;
00291 
00292         //- Area-averaged value of a field across the surface
00293         template<class Type>
00294         Type average(const Field<Type>&) const;
00295 
00296         //- Area-averaged value of a field across the surface
00297         template<class Type>
00298         Type average(const tmp<Field<Type> >&) const;
00299 
00300         //- Project field onto surface
00301         tmp<Field<scalar> > project(const Field<scalar>&) const;
00302 
00303         //- Project field onto surface
00304         tmp<Field<scalar> > project(const Field<vector>&) const;
00305 
00306         //- Project field onto surface
00307         tmp<Field<vector> > project(const Field<sphericalTensor>&) const;
00308 
00309         //- Project field onto surface
00310         tmp<Field<vector> > project(const Field<symmTensor>&) const;
00311 
00312         //- Project field onto surface
00313         tmp<Field<vector> > project(const Field<tensor>&) const;
00314 
00315         //- Sample field on surface
00316         virtual tmp<scalarField> sample
00317         (
00318             const volScalarField&
00319         ) const = 0;
00320 
00321         //- Sample field on surface
00322         virtual tmp<vectorField> sample
00323         (
00324             const volVectorField&
00325         ) const = 0;
00326 
00327         //- Sample field on surface
00328         virtual tmp<sphericalTensorField> sample
00329         (
00330             const volSphericalTensorField&
00331         ) const = 0;
00332 
00333         //- Sample field on surface
00334         virtual tmp<symmTensorField> sample
00335         (
00336             const volSymmTensorField&
00337         ) const = 0;
00338 
00339         //- Sample field on surface
00340         virtual tmp<tensorField> sample
00341         (
00342             const volTensorField&
00343         ) const = 0;
00344 
00345 
00346         //- Interpolate field on surface
00347         virtual tmp<scalarField> interpolate
00348         (
00349             const interpolation<scalar>&
00350         ) const = 0;
00351 
00352 
00353         //- Interpolate field on surface
00354         virtual tmp<vectorField> interpolate
00355         (
00356             const interpolation<vector>&
00357         ) const = 0;
00358 
00359         //- Interpolate field on surface
00360         virtual tmp<sphericalTensorField> interpolate
00361         (
00362             const interpolation<sphericalTensor>&
00363         ) const = 0;
00364 
00365         //- Interpolate field on surface
00366         virtual tmp<symmTensorField> interpolate
00367         (
00368             const interpolation<symmTensor>&
00369         ) const = 0;
00370 
00371         //- Interpolate field on surface
00372         virtual tmp<tensorField> interpolate
00373         (
00374             const interpolation<tensor>&
00375         ) const = 0;
00376 
00377 
00378       // Edit
00379 
00380         //- Rename
00381         virtual void rename(const word& newName)
00382         {
00383             name_ = newName;
00384         }
00385 
00386 
00387       // Write
00388 
00389         //- Write
00390         virtual void print(Ostream&) const;
00391 
00392 
00393        // IOstream operators
00394 
00395         friend Ostream& operator<<(Ostream&, const sampledSurface&);
00396 };
00397 
00398 
00399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00400 
00401 } // End namespace Foam
00402 
00403 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00404 
00405 #ifdef NoRepository
00406 #   include "sampledSurfaceTemplates.C"
00407 #endif
00408 
00409 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00410 
00411 #endif
00412 
00413 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd