41void Foam::bufferedAccumulator<Type>::accumulateAndResetBuffer(
const label
b)
43 accumulationBuffer() += (*this)[
b];
47 (*this)[
b] = Field<Type>(bufferLength(), Zero);
49 bufferOffsets_[
b] = 0;
68 const label bufferLength,
69 const label bufferingInterval
92 averagesTaken_(bA.averagesTaken()),
109 const label nBuffers,
110 const label bufferLength,
111 const label bufferingInterval
125 forAll(bufferOffsets_, bO)
127 bufferOffsets_[bO] = -bufferingInterval * bO - 1;
135 const List<Type>& valuesToAdd
138 label bufferToRefill = -1;
140 for (label
b = 0;
b < nBuffers();
b++)
144 label& bO = bufferOffsets_[
b];
148 buf[bO] = valuesToAdd[
b];
155 accumulateAndResetBuffer(
b);
160 if (bufferToRefill != -1)
163 <<
"More than one bufferedAccumulator accumulation "
164 <<
"buffer filled at once, this is considered an error."
172 return bufferToRefill;
181 Field<Type> bA = accumulationBuffer()/averagesTaken_;
188 <<
"Averaged correlation function requested but averagesTaken = "
190 <<
". Returning empty field."
201 accumulationBuffer() = Field<Type>(bufferLength(),
Zero);
220 List<Field<Type>>::operator=(
rhs);
222 averagesTaken_ =
rhs.averagesTaken();
224 bufferOffsets_ =
rhs.bufferOffsets();
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
Field< Type > averaged() const
bufferedAccumulator()
Construct null.
label addToBuffers(const List< Type > &valuesToAdd)
~bufferedAccumulator()
Destructor.
label bufferLength() const
const List< label > & bufferOffsets() const
void setSizes(const label nBuffers, const label bufferLength, const label bufferingInterval)
label averagesTaken() const
static const char *const typeName
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define forAll(list, i)
Loop across all elements in list.