ENH: patchCloud: return pTraits<Type>::max for unfound points
[OpenFOAM-1.7.x.git] / src / lagrangian / molecularDynamics / molecularMeasurements / bufferedAccumulator / bufferedAccumulator.H
blobddfd438a2a382525bf8173c88bcb5a9e94ddb6b2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
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
111         ~bufferedAccumulator();
114     // Member Functions
116         label addToBuffers(const List<Type>& valuesToAdd);
118         Field<Type> averaged() const;
120         void resetAveraging();
123         // Access
125             inline label averagesTaken() const;
127             inline label nBuffers() const;
129             inline label bufferLength() const;
131             inline const List<label>& bufferOffsets() const;
134         // Edit
136             void setSizes
137             (
138                 const label nBuffers,
139                 const label bufferLength,
140                 const label bufferingInterval
141             );
144     // Member Operators
146         void operator=(const bufferedAccumulator<Type>&);
149     // IOstream Operators
151         friend Ostream& operator<< <Type>
152         (
153             Ostream&,
154             const bufferedAccumulator<Type>&
155         );
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 #include "bufferedAccumulatorI.H"
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 #ifdef NoRepository
170 #   include "bufferedAccumulator.C"
171 #endif
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 #endif
177 // ************************************************************************* //