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

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