1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Foam::DimensionedField
28 Field with dimensions and associated with geometry type GeoMesh which is
29 used to size the field and a reference to it is maintained.
36 \*---------------------------------------------------------------------------*/
38 #ifndef DimensionedField_H
39 #define DimensionedField_H
41 #include "regIOobject.H"
43 #include "dimensionedType.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declaration of friend functions and operators
52 template<class Type, class GeoMesh> class DimensionedField;
54 template<class Type, class GeoMesh> Ostream& operator<<
57 const DimensionedField<Type, GeoMesh>&
60 template<class Type, class GeoMesh> Ostream& operator<<
63 const tmp<DimensionedField<Type, GeoMesh> >&
67 /*---------------------------------------------------------------------------*\
68 Class DimensionedField Declaration
69 \*---------------------------------------------------------------------------*/
71 template<class Type, class GeoMesh>
72 class DimensionedField
82 typedef typename GeoMesh::Mesh Mesh;
83 typedef typename Field<Type>::cmptType cmptType;
93 //- Dimension set for this field
94 dimensionSet dimensions_;
97 // Private Member Functions
99 void readIfPresent(const word& fieldDictEntry = "value");
104 //- Runtime type information
105 TypeName("DimensionedField");
107 // Static Member Functions
109 //- Return a null DimensionedField
110 inline static const DimensionedField<Type, GeoMesh>& null();
115 //- Construct from components
124 //- Construct from components
125 // Used for temporary fields which are initialised after construction
131 const bool checkIOFlags = true
134 //- Construct from components
139 const dimensioned<Type>&,
140 const bool checkIOFlags = true
143 //- Construct from Istream
148 const word& fieldDictEntry="value"
151 //- Construct as copy
154 const DimensionedField<Type, GeoMesh>&
157 //- Construct as copy or re-use as specified.
160 DimensionedField<Type, GeoMesh>&,
164 //- Construct by transferring the DimensionedField
167 const Xfer<DimensionedField<Type, GeoMesh> >&
170 //- Construct as copy of tmp<DimensionedField> deleting argument
171 # ifdef ConstructFromTmp
174 const tmp<DimensionedField<Type, GeoMesh> >&
178 //- Construct as copy resetting IO parameters
182 const DimensionedField<Type, GeoMesh>&
185 //- Construct as copy resetting name
189 const DimensionedField<Type, GeoMesh>&
192 //- Construct as copy resetting name and re-use as specified.
196 DimensionedField<Type, GeoMesh>&,
200 //- Construct by transferring the DimensionedField with a new name
204 const Xfer<DimensionedField<Type, GeoMesh> >&
207 //- Construct as copy resetting name
208 # ifdef ConstructFromTmp
212 const tmp<DimensionedField<Type, GeoMesh> >&
217 tmp<DimensionedField<Type, GeoMesh> > clone() const;
221 virtual ~DimensionedField();
228 const dictionary& fieldDict,
229 const word& fieldDictEntry = "value"
233 inline const Mesh& mesh() const;
235 //- Return dimensions
236 inline const dimensionSet& dimensions() const;
238 //- Return non-const access to dimensions
239 inline dimensionSet& dimensions();
241 inline const Field<Type>& field() const;
243 inline Field<Type>& field();
245 //- Return a component field of the field
246 tmp<DimensionedField<cmptType, GeoMesh> > component
251 //- Replace a component field of the field
255 const DimensionedField<cmptType, GeoMesh>&
258 //- Replace a component field of the field
262 const tmp<DimensionedField<cmptType, GeoMesh> >&
265 //- Return the field transpose (only defined for second rank tensors)
266 tmp<DimensionedField<Type, GeoMesh> > T() const;
268 //- Calculate and return arithmetic average
269 dimensioned<Type> average() const;
271 //- Calculate and return weighted average
272 dimensioned<Type> weightedAverage
274 const DimensionedField<scalar, GeoMesh>&
277 //- Calculate and return weighted average
278 dimensioned<Type> weightedAverage
280 const tmp<DimensionedField<scalar, GeoMesh> >&
286 bool writeData(Ostream&, const word& fieldDictEntry) const;
288 bool writeData(Ostream&) const;
293 void operator=(const DimensionedField<Type, GeoMesh>&);
294 void operator=(const tmp<DimensionedField<Type, GeoMesh> >&);
295 void operator=(const dimensioned<Type>&);
297 void operator+=(const DimensionedField<Type, GeoMesh>&);
298 void operator+=(const tmp<DimensionedField<Type, GeoMesh> >&);
300 void operator-=(const DimensionedField<Type, GeoMesh>&);
301 void operator-=(const tmp<DimensionedField<Type, GeoMesh> >&);
303 void operator*=(const DimensionedField<scalar, GeoMesh>&);
304 void operator*=(const tmp<DimensionedField<scalar, GeoMesh> >&);
306 void operator/=(const DimensionedField<scalar, GeoMesh>&);
307 void operator/=(const tmp<DimensionedField<scalar, GeoMesh> >&);
309 void operator+=(const dimensioned<Type>&);
310 void operator-=(const dimensioned<Type>&);
312 void operator*=(const dimensioned<scalar>&);
313 void operator/=(const dimensioned<scalar>&);
318 friend Ostream& operator<< <Type, GeoMesh>
321 const DimensionedField<Type, GeoMesh>&
324 friend Ostream& operator<< <Type, GeoMesh>
327 const tmp<DimensionedField<Type, GeoMesh> >&
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 } // End namespace Foam
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
338 #include "DimensionedFieldI.H"
339 #include "DimensionedFieldFunctions.H"
342 # include "DimensionedField.C"
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //