FreeFOAM The Cross-Platform CFD Toolkit
DimensionedField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::DimensionedField
26 
27 Description
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.
30 
31 SourceFiles
32  DimensionedFieldI.H
33  DimensionedField.C
34  DimensionedFieldIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef DimensionedField_H
39 #define DimensionedField_H
40 
41 #include <OpenFOAM/regIOobject.H>
42 #include <OpenFOAM/Field.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 
52 template<class Type, class GeoMesh> class DimensionedField;
53 
54 template<class Type, class GeoMesh> Ostream& operator<<
55 (
56  Ostream&,
57  const DimensionedField<Type, GeoMesh>&
58 );
59 
60 template<class Type, class GeoMesh> Ostream& operator<<
61 (
62  Ostream&,
63  const tmp<DimensionedField<Type, GeoMesh> >&
64 );
65 
66 
67 /*---------------------------------------------------------------------------*\
68  Class DimensionedField Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class Type, class GeoMesh>
73 :
74  public regIOobject,
75  public Field<Type>
76 {
77 
78 public:
79 
80  // Public typedefs
81 
82  typedef typename GeoMesh::Mesh Mesh;
83  typedef typename Field<Type>::cmptType cmptType;
84 
85 
86 private:
87 
88  // Private data
89 
90  //- Reference to mesh
91  const Mesh& mesh_;
92 
93  //- Dimension set for this field
94  dimensionSet dimensions_;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("DimensionedField");
101 
102  // Static Member Functions
103 
104  //- Return a null DimensionedField
105  inline static const DimensionedField<Type, GeoMesh>& null();
106 
107 
108  // Constructors
109 
110  //- Construct from components
112  (
113  const IOobject&,
114  const Mesh& mesh,
115  const dimensionSet&,
116  const Field<Type>&
117  );
118 
119  //- Construct from components
120  // Used for temporary fields which are initialised after construction
122  (
123  const IOobject&,
124  const Mesh& mesh,
125  const dimensionSet&
126  );
127 
128  //- Construct from components
130  (
131  const IOobject&,
132  const Mesh& mesh,
133  const dimensioned<Type>&
134  );
135 
136  //- Construct from Istream
138  (
139  const IOobject&,
140  const Mesh& mesh,
141  const word& fieldDictEntry="value"
142  );
143 
144  void readField
145  (
146  const dictionary& fieldDict,
147  const word& fieldDictEntry="value"
148  );
149 
150  //- Construct as copy
152  (
154  );
155 
156  //- Construct as copy or re-use as specified.
158  (
160  bool reUse
161  );
162 
163  //- Construct by transferring the DimensionedField
165  (
167  );
168 
169  //- Construct as copy of tmp<DimensionedField> deleting argument
170 # ifdef ConstructFromTmp
172  (
174  );
175 # endif
176 
177  //- Construct as copy resetting IO parameters
179  (
180  const IOobject&,
182  );
183 
184  //- Construct as copy resetting name
186  (
187  const word& newName,
189  );
190 
191  //- Construct as copy resetting name and re-use as specified.
193  (
194  const word& newName,
196  bool reUse
197  );
198 
199  //- Construct by transferring the DimensionedField with a new name
201  (
202  const word& newName,
204  );
205 
206  //- Construct as copy resetting name
207 # ifdef ConstructFromTmp
209  (
210  const word& newName,
212  );
213 # endif
214 
215  //- Clone
217 
218 
219  //- Destructor
220  virtual ~DimensionedField();
221 
222 
223  // Member Functions
224 
225  //- Return mesh
226  inline const Mesh& mesh() const;
227 
228  //- Return dimensions
229  inline const dimensionSet& dimensions() const;
230 
231  //- Return non-const access to dimensions
232  inline dimensionSet& dimensions();
233 
234  inline const Field<Type>& field() const;
235 
236  inline Field<Type>& field();
237 
238  //- Return a component field of the field
240  (
241  const direction
242  ) const;
243 
244  //- Replace a component field of the field
245  void replace
246  (
247  const direction,
249  );
250 
251  //- Replace a component field of the field
252  void replace
253  (
254  const direction,
256  );
257 
258  //- Return the field transpose (only defined for second rank tensors)
260 
261  //- Calculate and return arithmetic average
262  dimensioned<Type> average() const;
263 
264  //- Calculate and return weighted average
266  (
268  ) const;
269 
270  //- Calculate and return weighted average
272  (
274  ) const;
275 
276 
277  // Write
278 
279  bool writeData(Ostream&, const word& fieldDictEntry) const;
280 
281  bool writeData(Ostream&) const;
282 
283 
284  // Member Operators
285 
288  void operator=(const dimensioned<Type>&);
289 
292 
295 
298 
301 
302  void operator+=(const dimensioned<Type>&);
303  void operator-=(const dimensioned<Type>&);
304 
305  void operator*=(const dimensioned<scalar>&);
306  void operator/=(const dimensioned<scalar>&);
307 
308 
309  // Ostream Operators
310 
311  friend Ostream& operator<< <Type, GeoMesh>
312  (
313  Ostream&,
315  );
316 
317  friend Ostream& operator<< <Type, GeoMesh>
318  (
319  Ostream&,
321  );
322 };
323 
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 } // End namespace Foam
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
333 
334 #ifdef NoRepository
335 # include <OpenFOAM/DimensionedField.C>
336 #endif
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 #endif
341 
342 // ************************ vim: set sw=4 sts=4 et: ************************ //