ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / molecularDynamics / molecularMeasurements / bufferedAccumulator / bufferedAccumulator.H
blob8d462902f48ce69cf294d90391b37e1407f4e720
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::bufferedAccumulator
27 Description
29 SourceFiles
30     bufferedAccumulatorI.H
31     bufferedAccumulator.C
32     bufferedAccumulatorIO.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef bufferedAccumulator_H
37 #define bufferedAccumulator_H
39 #include "Field.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 template<class Type>
47 class bufferedAccumulator;
49 template<class Type>
50 Ostream& operator<<
52     Ostream&,
53     const bufferedAccumulator<Type>&
56 /*---------------------------------------------------------------------------*\
57                       Class bufferedAccumulator Declaration
58 \*---------------------------------------------------------------------------*/
60 template<class Type>
61 class bufferedAccumulator
63     public List< Field<Type> >
65     // Private data
67         label averagesTaken_;
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);
81 public:
83     //- Component type
84     typedef typename pTraits<Type>::cmptType cmptType;
87     // Static data members
89         static const char* const typeName;
92     // Constructors
94         //- Construct null
95         bufferedAccumulator();
97         //- Construct from components
98         bufferedAccumulator
99         (
100             const label nBuffers,
101             const label bufferLength,
102             const label bufferingInterval
103         );
105         //- Construct as copy
106         bufferedAccumulator(const bufferedAccumulator<Type>&);
109     //- Destructor
110     ~bufferedAccumulator();
113     // Member Functions
115         label addToBuffers(const List<Type>& valuesToAdd);
117         Field<Type> averaged() const;
119         void resetAveraging();
122         // Access
124             inline label averagesTaken() const;
126             inline label nBuffers() const;
128             inline label bufferLength() const;
130             inline const List<label>& bufferOffsets() const;
133         // Edit
135             void setSizes
136             (
137                 const label nBuffers,
138                 const label bufferLength,
139                 const label bufferingInterval
140             );
143     // Member Operators
145         void operator=(const bufferedAccumulator<Type>&);
148     // IOstream Operators
150         friend Ostream& operator<< <Type>
151         (
152             Ostream&,
153             const bufferedAccumulator<Type>&
154         );
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 } // End namespace Foam
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 #include "bufferedAccumulatorI.H"
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 #ifdef NoRepository
169 #   include "bufferedAccumulator.C"
170 #endif
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 #endif
176 // ************************************************************************* //