1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::bufferedAccumulator
31 bufferedAccumulatorI.H
33 bufferedAccumulatorIO.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef bufferedAccumulator_H
38 #define bufferedAccumulator_H
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 class bufferedAccumulator;
54 const bufferedAccumulator<Type>&
57 /*---------------------------------------------------------------------------*\
58 Class bufferedAccumulator Declaration
59 \*---------------------------------------------------------------------------*/
62 class bufferedAccumulator
64 public List< Field<Type> >
70 List<label> bufferOffsets_;
73 // Private Member Functions
75 inline Field<Type>& accumulationBuffer();
77 inline const Field<Type>& accumulationBuffer() const;
79 void accumulateAndResetBuffer(const label b);
85 typedef typename pTraits<Type>::cmptType cmptType;
88 // Static data members
90 static const char* const typeName;
96 bufferedAccumulator();
98 //- Construct from components
101 const label nBuffers,
102 const label bufferLength,
103 const label bufferingInterval
106 //- Construct as copy
107 bufferedAccumulator(const bufferedAccumulator<Type>&);
112 ~bufferedAccumulator();
117 label addToBuffers(const List<Type>& valuesToAdd);
119 Field<Type> averaged() const;
121 void resetAveraging();
126 inline label averagesTaken() const;
128 inline label nBuffers() const;
130 inline label bufferLength() const;
132 inline const List<label>& bufferOffsets() const;
139 const label nBuffers,
140 const label bufferLength,
141 const label bufferingInterval
147 void operator=(const bufferedAccumulator<Type>&);
150 // IOstream Operators
152 friend Ostream& operator<< <Type>
155 const bufferedAccumulator<Type>&
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 } // End namespace Foam
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 #include "bufferedAccumulatorI.H"
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 # include "bufferedAccumulator.C"
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 // ************************************************************************* //