40void Foam::correlationFunction<Type>::setTimesAndSizes
42 const label tZeroBufferSize
45 sampleSteps_ = ceil(sampleInterval_/mesh_.time().deltaTValue());
47 sampleInterval_ = sampleSteps_*mesh_.time().deltaTValue();
49 label bufferLength(ceil(duration_/sampleInterval_));
51 duration_ = bufferLength*sampleInterval_;
53 label bufferingInterval(ceil(averagingInterval_/sampleInterval_));
55 averagingInterval_ = bufferingInterval*sampleInterval_;
57 label nBuffers(ceil(duration_/averagingInterval_));
82Foam::correlationFunction<Type>::correlationFunction
86 const label tZeroBufferSize
91 duration_(
dict.get<scalar>(
"duration")),
92 sampleInterval_(
dict.get<scalar>(
"sampleInterval")),
93 averagingInterval_(
dict.
get<scalar>(
"averagingInterval"))
95 setTimesAndSizes(tZeroBufferSize);
100Foam::correlationFunction<Type>::correlationFunction
103 const label tZeroBufferSize,
104 const scalar duration,
105 const scalar sampleInterval,
106 const scalar averagingInterval
112 sampleInterval_(sampleInterval),
113 averagingInterval_(averagingInterval)
115 setTimesAndSizes(tZeroBufferSize);
134 if (measurandFieldSize() != currentValues.
size())
137 <<
"Trying to supply a Field of length"
138 << currentValues.
size()
139 <<
" to calculate the correlation function. "
140 <<
"Expecting a Field of length "
141 << measurandFieldSize() <<
nl
145 List<scalar> cFSums(nBuffers(),
Zero);
147 forAll(tZeroBuffers_, tZB)
149 scalar& cFSum = cFSums[tZB];
151 const Field<Type>& tZeroBuffer = tZeroBuffers_[tZB];
155 const Type& tZeroBufferValue = tZeroBuffer[cV];
157 const Type& currentValue = currentValues[cV];
168 cFSum /= (measurandFieldSize()*currentValues[0].
size());
171 label bufferToRefill = addToBuffers(cFSums);
173 if (bufferToRefill != -1)
175 tZeroBuffers_[bufferToRefill] = currentValues;
183 const Type& currentValue
186 if (measurandFieldSize() != 1)
189 <<
"Trying to supply a single value to calculate the correlation "
190 <<
"function. Expecting a Field of length "
191 << measurandFieldSize()
195 calculateCorrelationFunction(
Field<Type>(1, currentValue));
202 Field<scalar> averageCF(averaged());
204 scalar cFIntegral = 0.0;
206 for (label v = 0; v < averageCF.size() - 1; v++)
211 *(averageCF[v+1] + averageCF[v]);
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...
bool get(const label i) const
Return bool value at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
Field< scalar > averaged() const
label addToBuffers(const List< scalar > &valuesToAdd)
label measurandFieldSize() const
~correlationFunction()
Destructor.
void calculateCorrelationFunction(const Field< Type > &)
scalar averagingInterval() const
scalar sampleInterval() const
static const char *const typeName
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Mesh consisting of general polyhedral cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
errorManip< error > abort(error &err)
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...
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.