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

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