initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / FieldFields / FieldField / FieldField.H
blob4d1d66be28e9f1d1955e8d6fc197d075369a80b0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::FieldField
28 Description
29     Generic field type.
31 SourceFiles
32     FieldField.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef FieldField_H
37 #define FieldField_H
39 #include "tmp.H"
40 #include "PtrList.H"
41 #include "scalar.H"
42 #include "direction.H"
43 #include "VectorSpace.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of friend functions and operators
52 template<template<class> class Field, class Type>
53 class FieldField;
55 template<template<class> class Field, class Type>
56 Ostream& operator<<
58     Ostream&,
59     const FieldField<Field, Type>&
62 template<template<class> class Field, class Type>
63 Ostream& operator<<
65     Ostream&,
66     const tmp<FieldField<Field, Type> >&
70 /*---------------------------------------------------------------------------*\
71                            Class FieldField Declaration
72 \*---------------------------------------------------------------------------*/
74 template<template<class> class Field, class Type>
75 class FieldField
77     public refCount,
78     public PtrList<Field<Type> >
81 public:
83     //- Component type
84     typedef typename pTraits<Type>::cmptType cmptType;
87     // Constructors
89         //- Construct null
90         //  Used for temporary fields which are initialised after construction
91         FieldField();
93         //- Construct given size
94         //  Used for temporary fields which are initialised after construction
95         explicit FieldField(const label);
97         //- Construct using the Field sizes from the given FieldField
98         //  and the given Field type.
99         //  Used for temporary fields which are initialised after construction
100         FieldField(const word&, const FieldField<Field, Type>&);
102         //- Construct as copy
103         FieldField(const FieldField<Field, Type>&);
105         //- Construct as copy or re-use as specified.
106         FieldField(FieldField<Field, Type>&, bool reUse);
108         //- Construct as copy of a PtrList<Field, Type>
109         FieldField(const PtrList<Field<Type> >&);
111         //- Construct as copy of tmp<FieldField>
112 #       ifdef ConstructFromTmp
113         FieldField(const tmp<FieldField<Field, Type> >&);
114 #       endif
116         //- Construct from Istream
117         FieldField(Istream&);
119         //- Clone
120         tmp<FieldField<Field, Type> > clone() const;
122         //- Return a pointer to a new calculatedFvPatchFieldField created on
123         //  freestore without setting patchField values
124         template<class Type2>
125         static tmp<FieldField<Field, Type> > NewCalculatedType
126         (
127             const FieldField<Field, Type2>& ff
128         )
129 #       ifdef __INTEL_COMPILER
130         {
131             FieldField<Field, Type>* nffPtr
132             (
133                 new FieldField<Field, Type>(ff.size())
134             );
136             forAll(*nffPtr, i)
137             {
138                 nffPtr->set(i, Field<Type>::NewCalculatedType(ff[i]).ptr());
139             }
141             return tmp<FieldField<Field, Type> >(nffPtr);
142         }
143 #       else
144         ;
145 #       endif
147     // Member functions
149         //- Negate this field
150         void negate();
152         //- Return a component field of the field
153         tmp<FieldField<Field, cmptType> > component(const direction) const;
155         //- Replace a component field of the field
156         void replace(const direction, const FieldField<Field, cmptType>&);
158         //- Replace a component field of the field
159         void replace(const direction, const cmptType&);
161         //- Return the field transpose (only defined for second rank tensors)
162         tmp<FieldField<Field, Type> > T() const;
165     // Member operators
167         void operator=(const FieldField<Field, Type>&);
168         void operator=(const tmp<FieldField<Field, Type> >&);
169         void operator=(const Type&);
171         void operator+=(const FieldField<Field, Type>&);
172         void operator+=(const tmp<FieldField<Field, Type> >&);
174         void operator-=(const FieldField<Field, Type>&);
175         void operator-=(const tmp<FieldField<Field, Type> >&);
177         void operator*=(const FieldField<Field, scalar>&);
178         void operator*=(const tmp<FieldField<Field, scalar> >&);
180         void operator/=(const FieldField<Field, scalar>&);
181         void operator/=(const tmp<FieldField<Field, scalar> >&);
183         void operator+=(const Type&);
184         void operator-=(const Type&);
186         void operator*=(const scalar&);
187         void operator/=(const scalar&);
190     // IOstream operators
192         friend Ostream& operator<< <Field, Type>
193         (
194             Ostream&,
195             const FieldField<Field, Type>&
196         );
198         friend Ostream& operator<< <Field, Type>
199         (
200             Ostream&,
201             const tmp<FieldField<Field, Type> >&
202         );
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 } // End namespace Foam
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 #include "FieldFieldFunctions.H"
214 #ifdef NoRepository
215 #   include "FieldField.C"
216 #endif
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 #endif
222 // ************************************************************************* //