AverageField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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::AverageField
26 
27 Description
28  A primitive field with a separate average value.
29 
30 SourceFiles
31  AverageField.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef AverageField_H
36 #define AverageField_H
37 
38 #include "Field.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class AverageField Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Type>
50 class AverageField
51 :
52  public Field<Type>
53 {
54  // Private Data
55 
56  //- The average of the field
57  Type average_;
58 
59 
60 public:
61 
62  // Constructors
63 
64  //- Construct from size (does not set values)
65  AverageField(const label size);
66 
67  //- Construct from components
68  AverageField(const Field<Type>&, const Type& average);
69 
70  //- Construct from Istream
72 
73 
74  // Member Functions
75 
76  const Type& average() const;
77 
78  Type& average();
79 
80  bool writeData(Ostream& os) const;
81 };
82 
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 } // End namespace Foam
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 #ifdef NoRepository
91  #include "AverageField.C"
92 #endif
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A primitive field with a separate average value.
Definition: AverageField.H:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Pre-declare SubField and related Field type.
Definition: Field.H:56
AverageField(const label size)
Construct from size (does not set values)
Definition: AverageField.C:31
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool writeData(Ostream &os) const
Definition: AverageField.C:75
const Type & average() const
Definition: AverageField.C:61
label size() const
Return the number of elements in the UList.
Definition: ListI.H:170
Namespace for OpenFOAM.