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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::bufferedAccumulator
28 
29 Description
30 
31 SourceFiles
32  bufferedAccumulatorI.H
33  bufferedAccumulator.C
34  bufferedAccumulatorIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef bufferedAccumulator_H
39 #define bufferedAccumulator_H
40 
41 #include "Field.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 template<class Type>
50 
51 template<class Type>
52 Ostream& operator<<
53 (
54  Ostream&,
56 );
57 
58 /*---------------------------------------------------------------------------*\
59  Class bufferedAccumulator Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class Type>
64 :
65  public List<Field<Type>>
66 {
67  // Private data
68 
69  label averagesTaken_;
70 
71  List<label> bufferOffsets_;
72 
73 
74  // Private Member Functions
75 
76  inline Field<Type>& accumulationBuffer();
77 
78  inline const Field<Type>& accumulationBuffer() const;
79 
80  void accumulateAndResetBuffer(const label b);
81 
82 
83 public:
84 
85  //- Component type
86  typedef typename pTraits<Type>::cmptType cmptType;
87 
88 
89  // Static data members
90 
91  static const char* const typeName;
92 
93 
94  // Constructors
95 
96  //- Construct null
98 
99  //- Construct from components
101  (
102  const label nBuffers,
103  const label bufferLength,
104  const label bufferingInterval
105  );
106 
107  //- Construct as copy
109 
110 
111  //- Destructor
113 
114 
115  // Member Functions
116 
117  label addToBuffers(const List<Type>& valuesToAdd);
118 
119  Field<Type> averaged() const;
120 
121  void resetAveraging();
122 
123 
124  // Access
125 
126  inline label averagesTaken() const;
127 
128  inline label nBuffers() const;
129 
130  inline label bufferLength() const;
131 
132  inline const List<label>& bufferOffsets() const;
133 
134 
135  // Edit
136 
137  void setSizes
138  (
139  const label nBuffers,
140  const label bufferLength,
141  const label bufferingInterval
142  );
143 
144 
145  // Member Operators
146 
148 
149 
150  // IOstream Operators
151 
152  friend Ostream& operator<< <Type>
153  (
154  Ostream&,
156  );
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #include "bufferedAccumulatorI.H"
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #ifdef NoRepository
171  #include "bufferedAccumulator.C"
172 #endif
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
Foam::bufferedAccumulator::nBuffers
label nBuffers() const
Definition: bufferedAccumulatorI.H:57
Foam::bufferedAccumulator::operator=
void operator=(const bufferedAccumulator< Type > &)
Definition: bufferedAccumulator.C:211
Foam::bufferedAccumulator::averaged
Field< Type > averaged() const
Definition: bufferedAccumulator.C:177
Foam::bufferedAccumulator::cmptType
pTraits< Type >::cmptType cmptType
Component type.
Definition: bufferedAccumulator.H:85
bufferedAccumulator.C
Foam::bufferedAccumulator::resetAveraging
void resetAveraging()
Definition: bufferedAccumulator.C:199
Foam::bufferedAccumulator::bufferLength
label bufferLength() const
Definition: bufferedAccumulatorI.H:64
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::bufferedAccumulator
Definition: bufferedAccumulator.H:48
Foam::bufferedAccumulator::setSizes
void setSizes(const label nBuffers, const label bufferLength, const label bufferingInterval)
Definition: bufferedAccumulator.C:108
Field.H
bufferedAccumulatorI.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::bufferedAccumulator::averagesTaken
label averagesTaken() const
Definition: bufferedAccumulatorI.H:50
Foam::bufferedAccumulator::addToBuffers
label addToBuffers(const List< Type > &valuesToAdd)
Definition: bufferedAccumulator.C:134
Foam::bufferedAccumulator::~bufferedAccumulator
~bufferedAccumulator()
Destructor.
Definition: bufferedAccumulator.C:100
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::bufferedAccumulator::typeName
static const char *const typeName
Definition: bufferedAccumulator.H:90
Foam::bufferedAccumulator::bufferOffsets
const List< label > & bufferOffsets() const
Definition: bufferedAccumulatorI.H:71
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::bufferedAccumulator::bufferedAccumulator
bufferedAccumulator()
Construct null.
Definition: bufferedAccumulator.C:56