OpenFOAM logo
Open Source CFD Toolkit

FieldField.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     FieldField<T>
00027 
00028 Description
00029     Generic field type.
00030 
00031 SourceFiles
00032     FieldField.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef FieldField_H
00037 #define FieldField_H
00038 
00039 #include "tmp.H"
00040 #include "PtrList.H"
00041 #include "scalar.H"
00042 #include "direction.H"
00043 #include "VectorSpace.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00051 
00052 template<template<class> class Field, class Type>
00053 class FieldField;
00054 
00055 template<template<class> class Field, class Type>
00056 Ostream& operator<<
00057 (
00058     Ostream&,
00059     const FieldField<Field, Type>&
00060 );
00061 
00062 template<template<class> class Field, class Type>
00063 Ostream& operator<<
00064 (
00065     Ostream&,
00066     const tmp<FieldField<Field, Type> >&
00067 );
00068 
00069 
00070 /*---------------------------------------------------------------------------*\
00071                            Class FieldField Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 template<template<class> class Field, class Type>
00075 class FieldField
00076 :
00077     public refCount,
00078     public PtrList<Field<Type> >
00079 {
00080 
00081 public:
00082 
00083     //- Component type
00084     typedef typename pTraits<Type>::cmptType cmptType;
00085 
00086 
00087     // Constructors
00088 
00089         //- Construct null
00090         //  Used for temporary fields which are initialised after construction
00091         FieldField();
00092 
00093         //- Construct given size
00094         //  Used for temporary fields which are initialised after construction
00095         explicit FieldField(const label);
00096 
00097         //- Construct using the Field sizes from the given FieldField
00098         //  and the given Field type.
00099         //  Used for temporary fields which are initialised after construction
00100         FieldField(const word&, const FieldField<Field, Type>&);
00101 
00102         //- Construct as copy
00103         FieldField(const FieldField<Field, Type>&);
00104 
00105         //- Construct as copy or re-use as specified.
00106         FieldField(FieldField<Field, Type>&, bool reUse);
00107 
00108         //- Construct as copy of a PtrList<Field, Type>
00109         FieldField(const PtrList<Field<Type> >&);
00110 
00111         //- Construct as copy of tmp<FieldField>
00112 #       ifdef ConstructFromTmp
00113         FieldField(const tmp<FieldField<Field, Type> >&);
00114 #       endif
00115 
00116         //- Construct from Istream
00117         FieldField(Istream&);
00118 
00119         //- Clone
00120         tmp<FieldField<Field, Type> > clone() const;
00121 
00122         //- Return a pointer to a new calculatedFvPatchFieldField created on
00123         //  freestore without setting patchField values
00124         template<class Type2>
00125         static tmp<FieldField<Field, Type> > NewCalculatedType
00126         (
00127             const FieldField<Field, Type2>& ff
00128         )
00129         {
00130             FieldField<Field, Type>* nffPtr
00131             (
00132                 new FieldField<Field, Type>(ff.size())
00133             );
00134 
00135             forAll(*nffPtr, i)
00136             { 
00137                 nffPtr->hook(Field<Type>::NewCalculatedType(ff[i]).ptr());
00138             }
00139 
00140             return tmp<FieldField<Field, Type> >(nffPtr);
00141         }
00142 
00143 
00144     // Member functions
00145 
00146         //- Negate this field
00147         void negate();
00148 
00149         //- Return a component field of the field
00150         tmp<FieldField<Field, cmptType> > component(const direction) const;
00151 
00152         //- Replace a component field of the field
00153         void replace(const direction, const FieldField<Field, cmptType>&);
00154 
00155         //- Return the field transpose (only defined for second rank tensors)
00156         tmp<FieldField<Field, Type> > T() const;
00157 
00158 
00159     // Member operators
00160 
00161         void operator=(const FieldField<Field, Type>&);
00162         void operator=(const tmp<FieldField<Field, Type> >&);
00163         void operator=(const Type&);
00164 
00165         void operator+=(const FieldField<Field, Type>&);
00166         void operator+=(const tmp<FieldField<Field, Type> >&);
00167 
00168         void operator-=(const FieldField<Field, Type>&);
00169         void operator-=(const tmp<FieldField<Field, Type> >&);
00170 
00171         void operator*=(const FieldField<Field, scalar>&);
00172         void operator*=(const tmp<FieldField<Field, scalar> >&);
00173 
00174         void operator/=(const FieldField<Field, scalar>&);
00175         void operator/=(const tmp<FieldField<Field, scalar> >&);
00176 
00177         void operator+=(const Type&);
00178         void operator-=(const Type&);
00179 
00180         void operator*=(const scalar&);
00181         void operator/=(const scalar&);
00182 
00183 
00184     // IOstream operators
00185 
00186         friend Ostream& operator<< <Field, Type>
00187         (
00188             Ostream&,
00189             const FieldField<Field, Type>&
00190         );
00191 
00192         friend Ostream& operator<< <Field, Type>
00193         (
00194             Ostream&,
00195             const tmp<FieldField<Field, Type> >&
00196         );
00197 };
00198 
00199 
00200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00201 
00202 } // End namespace Foam
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 #include "FieldFieldFunctions.H"
00207 
00208 #ifdef NoRepository
00209 #   include "FieldField.C"
00210 #endif
00211 
00212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00213 
00214 #endif
00215 
00216 // ************************************************************************* //
For further information go to www.openfoam.org