OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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