OpenFOAM logo
Open Source CFD Toolkit

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-2005 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
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 "dimensionSet.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 Istream
00125         DimensionedField
00126         (
00127             const IOobject&,
00128             const Mesh& mesh,
00129             const word& fieldDictEntry="value"
00130         );
00131 
00132         //- Construct as copy
00133         DimensionedField(const DimensionedField&);
00134 
00135 
00136     // Destructor
00137 
00138         ~DimensionedField();
00139 
00140 
00141     // Member Functions
00142 
00143         //- Return mesh
00144         inline const Mesh& mesh() const;
00145 
00146         //- Return dimensions
00147         inline const dimensionSet& dimensions() const;
00148 
00149         //- Return non-const access to dimensions
00150         inline dimensionSet& dimensions();
00151 
00152         //- Return a component field of the field
00153         tmp<DimensionedField<cmptType, GeoMesh> > component
00154         (
00155             const direction
00156         ) const;
00157 
00158         //- Replace a component field of the field
00159         void replace
00160         (
00161             const direction,
00162             const DimensionedField<cmptType, GeoMesh>&
00163         );
00164 
00165         //- Return the field transpose (only defined for second rank tensors)
00166         tmp<DimensionedField<Type, GeoMesh> > T() const;
00167 
00168 
00169         // Write
00170 
00171             bool writeData(Ostream&, const word& fieldDictEntry) const;
00172 
00173             bool writeData(Ostream&) const;
00174 
00175 
00176     // Member Operators
00177 
00178         void operator=(const DimensionedField<Type, GeoMesh>&);
00179         void operator=(const tmp<DimensionedField<Type, GeoMesh> >&);
00180         void operator=(const dimensioned<Type>&);
00181 
00182         void operator+=(const DimensionedField<Type, GeoMesh>&);
00183         void operator+=(const tmp<DimensionedField<Type, GeoMesh> >&);
00184 
00185         void operator-=(const DimensionedField<Type, GeoMesh>&);
00186         void operator-=(const tmp<DimensionedField<Type, GeoMesh> >&);
00187 
00188         void operator*=(const DimensionedField<scalar, GeoMesh>&);
00189         void operator*=(const tmp<DimensionedField<scalar, GeoMesh> >&);
00190 
00191         void operator/=(const DimensionedField<scalar, GeoMesh>&);
00192         void operator/=(const tmp<DimensionedField<scalar, GeoMesh> >&);
00193 
00194         void operator+=(const dimensioned<Type>&);
00195         void operator-=(const dimensioned<Type>&);
00196 
00197         void operator*=(const dimensioned<scalar>&);
00198         void operator/=(const dimensioned<scalar>&);
00199 
00200 
00201     // Ostream Operators
00202 
00203         friend Ostream& operator<< <Type, GeoMesh>
00204         (
00205             Ostream&,
00206             const DimensionedField<Type, GeoMesh>&
00207         );
00208 
00209         friend Ostream& operator<< <Type, GeoMesh>
00210         (
00211             Ostream&,
00212             const tmp<DimensionedField<Type, GeoMesh> >&
00213         );
00214 };
00215 
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 } // End namespace Foam
00220 
00221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00222 
00223 #include "DimensionedFieldI.H"
00224 
00225 #ifdef NoRepository
00226 #   include "DimensionedField.C"
00227 #endif
00228 
00229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00230 
00231 #endif
00232 
00233 // ************************************************************************* //
For further information go to www.openfoam.org