bufferedAccumulator.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) 2011-2016 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::bufferedAccumulator
26 
27 Description
28 
29 SourceFiles
30  bufferedAccumulatorI.H
31  bufferedAccumulator.C
32  bufferedAccumulatorIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef bufferedAccumulator_H
37 #define bufferedAccumulator_H
38 
39 #include "Field.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 template<class Type>
48 
49 template<class Type>
50 Ostream& operator<<
51 (
52  Ostream&,
54 );
55 
56 /*---------------------------------------------------------------------------*\
57  Class bufferedAccumulator Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
62 :
63  public List<Field<Type>>
64 {
65  // Private data
66 
67  label averagesTaken_;
68 
69  List<label> bufferOffsets_;
70 
71 
72  // Private Member Functions
73 
74  inline Field<Type>& accumulationBuffer();
75 
76  inline const Field<Type>& accumulationBuffer() const;
77 
78  void accumulateAndResetBuffer(const label b);
79 
80 
81 public:
82 
83  //- Component type
84  typedef typename pTraits<Type>::cmptType cmptType;
85 
86 
87  // Static data members
88 
89  static const char* const typeName;
90 
91 
92  // Constructors
93 
94  //- Construct null
96 
97  //- Construct from components
99  (
100  const label nBuffers,
101  const label bufferLength,
102  const label bufferingInterval
103  );
104 
105  //- Construct as copy
107 
108 
109  //- Destructor
111 
112 
113  // Member Functions
114 
115  label addToBuffers(const List<Type>& valuesToAdd);
116 
117  Field<Type> averaged() const;
118 
119  void resetAveraging();
120 
121 
122  // Access
123 
124  inline label averagesTaken() const;
125 
126  inline label nBuffers() const;
127 
128  inline label bufferLength() const;
129 
130  inline const List<label>& bufferOffsets() const;
131 
132 
133  // Edit
134 
135  void setSizes
136  (
137  const label nBuffers,
138  const label bufferLength,
139  const label bufferingInterval
140  );
141 
142 
143  // Member Operators
144 
146 
147 
148  // IOstream Operators
149 
150  friend Ostream& operator<< <Type>
151  (
152  Ostream&,
154  );
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace Foam
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #include "bufferedAccumulatorI.H"
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #ifdef NoRepository
169  #include "bufferedAccumulator.C"
170 #endif
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
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 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
Traits class for primitives.
Definition: pTraits.H:50
void setSizes(const label nBuffers, const label bufferLength, const label bufferingInterval)
Field< Type > averaged() const
Pre-declare SubField and related Field type.
Definition: Field.H:57
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
static const char *const typeName
const List< label > & bufferOffsets() const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bufferedAccumulator()
Construct null.
pTraits< Type >::cmptType cmptType
Component type.
label addToBuffers(const List< Type > &valuesToAdd)
void operator=(const bufferedAccumulator< Type > &)
Namespace for OpenFOAM.