FreeFOAM The Cross-Platform CFD Toolkit
bufferedAccumulator.H
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::bufferedAccumulator
26 
27 Description
28 
29 SourceFiles
30  bufferedAccumulatorI.H
31  bufferedAccumulator.C
32  bufferedAccumulatorIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef bufferedAccumulator_H
37 #define bufferedAccumulator_H
38 
39 #include <OpenFOAM/Field.H>
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 template<class Type>
47 class bufferedAccumulator;
48 
49 template<class Type>
50 Ostream& operator<<
51 (
52  Ostream&,
53  const bufferedAccumulator<Type>&
54 );
55 
56 /*---------------------------------------------------------------------------*\
57  Class bufferedAccumulator Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
62 :
63  public List< Field<Type> >
64 {
65  // Private data
66 
67  label averagesTaken_;
68 
69  List<label> bufferOffsets_;
70 
71 
72  // Private Member Functions
73 
74  inline Field<Type>& accumulationBuffer();
75 
76  inline const Field<Type>& accumulationBuffer() const;
77 
78  void accumulateAndResetBuffer(const label b);
79 
80 
81 public:
82 
83  //- Component type
85 
86 
87  // Static data members
88 
89  static const char* const typeName;
90 
91 
92  // Constructors
93 
94  //- Construct null
96 
97  //- Construct from components
99  (
100  const label nBuffers,
101  const label bufferLength,
102  const label bufferingInterval
103  );
104 
105  //- Construct as copy
107 
108 
109  // Destructor
110 
112 
113 
114  // Member Functions
115 
116  label addToBuffers(const List<Type>& valuesToAdd);
117 
118  Field<Type> averaged() const;
119 
120  void resetAveraging();
121 
122 
123  // Access
124 
125  inline label averagesTaken() const;
126 
127  inline label nBuffers() const;
128 
129  inline label bufferLength() const;
130 
131  inline const List<label>& bufferOffsets() const;
132 
133 
134  // Edit
135 
136  void setSizes
137  (
138  const label nBuffers,
139  const label bufferLength,
140  const label bufferingInterval
141  );
142 
143 
144  // Member Operators
145 
147 
148 
149  // IOstream Operators
150 
151  friend Ostream& operator<< <Type>
152  (
153  Ostream&,
155  );
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #include "bufferedAccumulatorI.H"
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #ifdef NoRepository
170 # include "bufferedAccumulator.C"
171 #endif
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************ vim: set sw=4 sts=4 et: ************************ //