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::bufferedAccumulator
30 bufferedAccumulatorI.H
32 bufferedAccumulatorIO.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef bufferedAccumulator_H
37 #define bufferedAccumulator_H
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 class bufferedAccumulator;
53 const bufferedAccumulator<Type>&
56 /*---------------------------------------------------------------------------*\
57 Class bufferedAccumulator Declaration
58 \*---------------------------------------------------------------------------*/
61 class bufferedAccumulator
63 public List< Field<Type> >
69 List<label> bufferOffsets_;
72 // Private Member Functions
74 inline Field<Type>& accumulationBuffer();
76 inline const Field<Type>& accumulationBuffer() const;
78 void accumulateAndResetBuffer(const label b);
84 typedef typename pTraits<Type>::cmptType cmptType;
87 // Static data members
89 static const char* const typeName;
95 bufferedAccumulator();
97 //- Construct from components
100 const label nBuffers,
101 const label bufferLength,
102 const label bufferingInterval
105 //- Construct as copy
106 bufferedAccumulator(const bufferedAccumulator<Type>&);
110 ~bufferedAccumulator();
115 label addToBuffers(const List<Type>& valuesToAdd);
117 Field<Type> averaged() const;
119 void resetAveraging();
124 inline label averagesTaken() const;
126 inline label nBuffers() const;
128 inline label bufferLength() const;
130 inline const List<label>& bufferOffsets() const;
137 const label nBuffers,
138 const label bufferLength,
139 const label bufferingInterval
145 void operator=(const bufferedAccumulator<Type>&);
148 // IOstream Operators
150 friend Ostream& operator<< <Type>
153 const bufferedAccumulator<Type>&
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 } // End namespace Foam
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 #include "bufferedAccumulatorI.H"
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 # include "bufferedAccumulator.C"
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 // ************************************************************************* //