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

DimensionedField.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::DimensionedField
00026 
00027 Description
00028     Field with dimensions and associated with geometry type GeoMesh which is
00029     used to size the field and a reference to it is maintained.
00030 
00031 SourceFiles
00032     DimensionedFieldI.H
00033     DimensionedField.C
00034     DimensionedFieldIO.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef DimensionedField_H
00039 #define DimensionedField_H
00040 
00041 #include <OpenFOAM/regIOobject.H>
00042 #include <OpenFOAM/Field.H>
00043 #include <OpenFOAM/dimensionedType.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of friend functions and operators
00051 
00052 template<class Type, class GeoMesh> class DimensionedField;
00053 
00054 template<class Type, class GeoMesh> Ostream& operator<<
00055 (
00056     Ostream&,
00057     const DimensionedField<Type, GeoMesh>&
00058 );
00059 
00060 template<class Type, class GeoMesh> Ostream& operator<<
00061 (
00062     Ostream&,
00063     const tmp<DimensionedField<Type, GeoMesh> >&
00064 );
00065 
00066 
00067 /*---------------------------------------------------------------------------*\
00068                            Class DimensionedField Declaration
00069 \*---------------------------------------------------------------------------*/
00070 
00071 template<class Type, class GeoMesh>
00072 class DimensionedField
00073 :
00074     public regIOobject,
00075     public Field<Type>
00076 {
00077 
00078 public:
00079 
00080     // Public typedefs
00081 
00082         typedef typename GeoMesh::Mesh Mesh;
00083         typedef typename Field<Type>::cmptType cmptType;
00084 
00085 
00086 private:
00087 
00088     // Private data
00089 
00090         //- Reference to mesh
00091         const Mesh& mesh_;
00092 
00093         //- Dimension set for this field
00094         dimensionSet dimensions_;
00095 
00096 
00097 public:
00098 
00099     //- Runtime type information
00100     TypeName("DimensionedField");
00101 
00102     // Static Member Functions
00103 
00104         //- Return a null DimensionedField
00105         inline static const DimensionedField<Type, GeoMesh>& null();
00106 
00107 
00108     // Constructors
00109 
00110         //- Construct from components
00111         DimensionedField
00112         (
00113             const IOobject&,
00114             const Mesh& mesh,
00115             const dimensionSet&,
00116             const Field<Type>&
00117         );
00118 
00119         //- Construct from components
00120         //  Used for temporary fields which are initialised after construction
00121         DimensionedField
00122         (
00123             const IOobject&,
00124             const Mesh& mesh,
00125             const dimensionSet&
00126         );
00127 
00128         //- Construct from components
00129         DimensionedField
00130         (
00131             const IOobject&,
00132             const Mesh& mesh,
00133             const dimensioned<Type>&
00134         );
00135 
00136         //- Construct from Istream
00137         DimensionedField
00138         (
00139             const IOobject&,
00140             const Mesh& mesh,
00141             const word& fieldDictEntry="value"
00142         );
00143 
00144         void readField
00145         (
00146             const dictionary& fieldDict,
00147             const word& fieldDictEntry="value"
00148         );
00149 
00150         //- Construct as copy
00151         DimensionedField
00152         (
00153             const DimensionedField<Type, GeoMesh>&
00154         );
00155 
00156         //- Construct as copy or re-use as specified.
00157         DimensionedField
00158         (
00159             DimensionedField<Type, GeoMesh>&,
00160             bool reUse
00161         );
00162 
00163         //- Construct by transferring the DimensionedField
00164         DimensionedField
00165         (
00166             const Xfer<DimensionedField<Type, GeoMesh> >&
00167         );
00168 
00169         //- Construct as copy of tmp<DimensionedField> deleting argument
00170 #       ifdef ConstructFromTmp
00171         DimensionedField
00172         (
00173             const tmp<DimensionedField<Type, GeoMesh> >&
00174         );
00175 #       endif
00176 
00177         //- Construct as copy resetting IO parameters
00178         DimensionedField
00179         (
00180             const IOobject&,
00181             const DimensionedField<Type, GeoMesh>&
00182         );
00183 
00184         //- Construct as copy resetting name
00185         DimensionedField
00186         (
00187             const word& newName,
00188             const DimensionedField<Type, GeoMesh>&
00189         );
00190 
00191         //- Construct as copy resetting name and re-use as specified.
00192         DimensionedField
00193         (
00194             const word& newName,
00195             DimensionedField<Type, GeoMesh>&,
00196             bool reUse
00197         );
00198 
00199         //- Construct by transferring the DimensionedField with a new name
00200         DimensionedField
00201         (
00202             const word& newName,
00203             const Xfer<DimensionedField<Type, GeoMesh> >&
00204         );
00205 
00206         //- Construct as copy resetting name
00207 #       ifdef ConstructFromTmp
00208         DimensionedField
00209         (
00210             const word& newName,
00211             const tmp<DimensionedField<Type, GeoMesh> >&
00212         );
00213 #       endif
00214 
00215         //- Clone
00216         tmp<DimensionedField<Type, GeoMesh> > clone() const;
00217 
00218 
00219     //- Destructor
00220     virtual ~DimensionedField();
00221 
00222 
00223     // Member Functions
00224 
00225         //- Return mesh
00226         inline const Mesh& mesh() const;
00227 
00228         //- Return dimensions
00229         inline const dimensionSet& dimensions() const;
00230 
00231         //- Return non-const access to dimensions
00232         inline dimensionSet& dimensions();
00233 
00234         inline const Field<Type>& field() const;
00235 
00236         inline Field<Type>& field();
00237 
00238         //- Return a component field of the field
00239         tmp<DimensionedField<cmptType, GeoMesh> > component
00240         (
00241             const direction
00242         ) const;
00243 
00244         //- Replace a component field of the field
00245         void replace
00246         (
00247             const direction,
00248             const DimensionedField<cmptType, GeoMesh>&
00249         );
00250 
00251         //- Replace a component field of the field
00252         void replace
00253         (
00254             const direction,
00255             const tmp<DimensionedField<cmptType, GeoMesh> >&
00256         );
00257 
00258         //- Return the field transpose (only defined for second rank tensors)
00259         tmp<DimensionedField<Type, GeoMesh> > T() const;
00260 
00261         //- Calculate and return arithmetic average
00262         dimensioned<Type> average() const;
00263 
00264         //- Calculate and return weighted average
00265         dimensioned<Type> weightedAverage
00266         (
00267             const DimensionedField<scalar, GeoMesh>&
00268         ) const;
00269 
00270         //- Calculate and return weighted average
00271         dimensioned<Type> weightedAverage
00272         (
00273             const tmp<DimensionedField<scalar, GeoMesh> >&
00274         ) const;
00275 
00276 
00277         // Write
00278 
00279             bool writeData(Ostream&, const word& fieldDictEntry) const;
00280 
00281             bool writeData(Ostream&) const;
00282 
00283 
00284     // Member Operators
00285 
00286         void operator=(const DimensionedField<Type, GeoMesh>&);
00287         void operator=(const tmp<DimensionedField<Type, GeoMesh> >&);
00288         void operator=(const dimensioned<Type>&);
00289 
00290         void operator+=(const DimensionedField<Type, GeoMesh>&);
00291         void operator+=(const tmp<DimensionedField<Type, GeoMesh> >&);
00292 
00293         void operator-=(const DimensionedField<Type, GeoMesh>&);
00294         void operator-=(const tmp<DimensionedField<Type, GeoMesh> >&);
00295 
00296         void operator*=(const DimensionedField<scalar, GeoMesh>&);
00297         void operator*=(const tmp<DimensionedField<scalar, GeoMesh> >&);
00298 
00299         void operator/=(const DimensionedField<scalar, GeoMesh>&);
00300         void operator/=(const tmp<DimensionedField<scalar, GeoMesh> >&);
00301 
00302         void operator+=(const dimensioned<Type>&);
00303         void operator-=(const dimensioned<Type>&);
00304 
00305         void operator*=(const dimensioned<scalar>&);
00306         void operator/=(const dimensioned<scalar>&);
00307 
00308 
00309     // Ostream Operators
00310 
00311         friend Ostream& operator<< <Type, GeoMesh>
00312         (
00313             Ostream&,
00314             const DimensionedField<Type, GeoMesh>&
00315         );
00316 
00317         friend Ostream& operator<< <Type, GeoMesh>
00318         (
00319             Ostream&,
00320             const tmp<DimensionedField<Type, GeoMesh> >&
00321         );
00322 };
00323 
00324 
00325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00326 
00327 } // End namespace Foam
00328 
00329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00330 
00331 #include <OpenFOAM/DimensionedFieldI.H>
00332 #include <OpenFOAM/DimensionedFieldFunctions.H>
00333 
00334 #ifdef NoRepository
00335 #   include <OpenFOAM/DimensionedField.C>
00336 #endif
00337 
00338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00339 
00340 #endif
00341 
00342 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines