initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / DimensionedFields / DimensionedField / DimensionedField.H
blob1d26e508a53093541135f65409ddd7a80a72b5be
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::DimensionedField
28 Description
29     Field with dimensions and associated with geometry type GeoMesh which is
30     used to size the field and a reference to it is maintained.
32 SourceFiles
33     DimensionedFieldI.H
34     DimensionedField.C
35     DimensionedFieldIO.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef DimensionedField_H
40 #define DimensionedField_H
42 #include "regIOobject.H"
43 #include "Field.H"
44 #include "dimensionedType.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of friend functions and operators
53 template<class Type, class GeoMesh> class DimensionedField;
55 template<class Type, class GeoMesh> Ostream& operator<<
57     Ostream&,
58     const DimensionedField<Type, GeoMesh>&
61 template<class Type, class GeoMesh> Ostream& operator<<
63     Ostream&,
64     const tmp<DimensionedField<Type, GeoMesh> >&
68 /*---------------------------------------------------------------------------*\
69                            Class DimensionedField Declaration
70 \*---------------------------------------------------------------------------*/
72 template<class Type, class GeoMesh>
73 class DimensionedField
75     public regIOobject,
76     public Field<Type>
79 public:
81     // Public typedefs
83         typedef typename GeoMesh::Mesh Mesh;
84         typedef typename Field<Type>::cmptType cmptType;
87 private:
89     // Private data
91         //- Reference to mesh
92         const Mesh& mesh_;
94         //- Dimension set for this field
95         dimensionSet dimensions_;
98 public:
100     //- Runtime type information
101     TypeName("DimensionedField");
103     // Static Member Functions
105         //- Return a null DimensionedField
106         inline static const DimensionedField<Type, GeoMesh>& null();
109     // Constructors
111         //- Construct from components
112         DimensionedField
113         (
114             const IOobject&,
115             const Mesh& mesh,
116             const dimensionSet&,
117             const Field<Type>&
118         );
120         //- Construct from components
121         //  Used for temporary fields which are initialised after construction
122         DimensionedField
123         (
124             const IOobject&,
125             const Mesh& mesh,
126             const dimensionSet&
127         );
129         //- Construct from components
130         DimensionedField
131         (
132             const IOobject&,
133             const Mesh& mesh,
134             const dimensioned<Type>&
135         );
137         //- Construct from Istream
138         DimensionedField
139         (
140             const IOobject&,
141             const Mesh& mesh,
142             const word& fieldDictEntry="value"
143         );
145         void readField
146         (
147             const dictionary& fieldDict,
148             const word& fieldDictEntry="value"
149         );
151         //- Construct as copy
152         DimensionedField
153         (
154             const DimensionedField<Type, GeoMesh>&
155         );
157         //- Construct as copy or re-use as specified.
158         DimensionedField
159         (
160             DimensionedField<Type, GeoMesh>&,
161             bool reUse
162         );
164         //- Construct by transferring the DimensionedField
165         DimensionedField
166         (
167             const Xfer<DimensionedField<Type, GeoMesh> >&
168         );
170         //- Construct as copy of tmp<DimensionedField> deleting argument
171 #       ifdef ConstructFromTmp
172         DimensionedField
173         (
174             const tmp<DimensionedField<Type, GeoMesh> >&
175         );
176 #       endif
178         //- Construct as copy resetting IO parameters
179         DimensionedField
180         (
181             const IOobject&,
182             const DimensionedField<Type, GeoMesh>&
183         );
185         //- Construct as copy resetting name
186         DimensionedField
187         (
188             const word& newName,
189             const DimensionedField<Type, GeoMesh>&
190         );
192         //- Construct as copy resetting name and re-use as specified.
193         DimensionedField
194         (
195             const word& newName,
196             DimensionedField<Type, GeoMesh>&,
197             bool reUse
198         );
200         //- Construct by transferring the DimensionedField with a new name
201         DimensionedField
202         (
203             const word& newName,
204             const Xfer<DimensionedField<Type, GeoMesh> >&
205         );
207         //- Construct as copy resetting name
208 #       ifdef ConstructFromTmp
209         DimensionedField
210         (
211             const word& newName,
212             const tmp<DimensionedField<Type, GeoMesh> >&
213         );
214 #       endif
216         //- Clone
217         tmp<DimensionedField<Type, GeoMesh> > clone() const;
220     //- Destructor
221     virtual ~DimensionedField();
224     // Member Functions
226         //- Return mesh
227         inline const Mesh& mesh() const;
229         //- Return dimensions
230         inline const dimensionSet& dimensions() const;
232         //- Return non-const access to dimensions
233         inline dimensionSet& dimensions();
235         inline const Field<Type>& field() const;
237         inline Field<Type>& field();
239         //- Return a component field of the field
240         tmp<DimensionedField<cmptType, GeoMesh> > component
241         (
242             const direction
243         ) const;
245         //- Replace a component field of the field
246         void replace
247         (
248             const direction,
249             const DimensionedField<cmptType, GeoMesh>&
250         );
252         //- Replace a component field of the field
253         void replace
254         (
255             const direction,
256             const tmp<DimensionedField<cmptType, GeoMesh> >&
257         );
259         //- Return the field transpose (only defined for second rank tensors)
260         tmp<DimensionedField<Type, GeoMesh> > T() const;
262         //- Calculate and return arithmetic average
263         dimensioned<Type> average() const;
265         //- Calculate and return weighted average
266         dimensioned<Type> weightedAverage
267         (
268             const DimensionedField<scalar, GeoMesh>&
269         ) const;
271         //- Calculate and return weighted average
272         dimensioned<Type> weightedAverage
273         (
274             const tmp<DimensionedField<scalar, GeoMesh> >&
275         ) const;
278         // Write
280             bool writeData(Ostream&, const word& fieldDictEntry) const;
282             bool writeData(Ostream&) const;
285     // Member Operators
287         void operator=(const DimensionedField<Type, GeoMesh>&);
288         void operator=(const tmp<DimensionedField<Type, GeoMesh> >&);
289         void operator=(const dimensioned<Type>&);
291         void operator+=(const DimensionedField<Type, GeoMesh>&);
292         void operator+=(const tmp<DimensionedField<Type, GeoMesh> >&);
294         void operator-=(const DimensionedField<Type, GeoMesh>&);
295         void operator-=(const tmp<DimensionedField<Type, GeoMesh> >&);
297         void operator*=(const DimensionedField<scalar, GeoMesh>&);
298         void operator*=(const tmp<DimensionedField<scalar, GeoMesh> >&);
300         void operator/=(const DimensionedField<scalar, GeoMesh>&);
301         void operator/=(const tmp<DimensionedField<scalar, GeoMesh> >&);
303         void operator+=(const dimensioned<Type>&);
304         void operator-=(const dimensioned<Type>&);
306         void operator*=(const dimensioned<scalar>&);
307         void operator/=(const dimensioned<scalar>&);
310     // Ostream Operators
312         friend Ostream& operator<< <Type, GeoMesh>
313         (
314             Ostream&,
315             const DimensionedField<Type, GeoMesh>&
316         );
318         friend Ostream& operator<< <Type, GeoMesh>
319         (
320             Ostream&,
321             const tmp<DimensionedField<Type, GeoMesh> >&
322         );
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 } // End namespace Foam
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 #include "DimensionedFieldI.H"
333 #include "DimensionedFieldFunctions.H"
335 #ifdef NoRepository
336 #   include "DimensionedField.C"
337 #endif
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 #endif
343 // ************************************************************************* //