1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
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>&);
111 ~bufferedAccumulator();
116 label addToBuffers(const List<Type>& valuesToAdd);
118 Field<Type> averaged() const;
120 void resetAveraging();
125 inline label averagesTaken() const;
127 inline label nBuffers() const;
129 inline label bufferLength() const;
131 inline const List<label>& bufferOffsets() const;
138 const label nBuffers,
139 const label bufferLength,
140 const label bufferingInterval
146 void operator=(const bufferedAccumulator<Type>&);
149 // IOstream Operators
151 friend Ostream& operator<< <Type>
154 const bufferedAccumulator<Type>&
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 #include "bufferedAccumulatorI.H"
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 # include "bufferedAccumulator.C"
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 // ************************************************************************* //