surfaceFieldValue weightedAverage missing division for mag(Sf)
Summary
Within the surfaceFieldValue FO we can compute weighted operations, among which the weightedAverage
.
When the weightField is a vector field, then it is not clear if the weighting factor is computed correctly.
The computation of the weightedAverage is done in surfaceFieldValueTemplates.C, line 195. But here the weighting factor is computed only for scalar values. As it is using the function weightingFactor(weightField)
defined in surfaceFieldValue.C, line 833. To my understanding here we are missing the case where the weightField is a vector, but we do not want an area weighting as well.
On the other hand, for area-averaged operations, such as weightedAreaAverage, we have both cases of weightFactor=scalar and weightFactor=vector.
What is the expected correct behavior?
For weightedAverage operation, the weighting factor with vector weightField should be computed using a unity vector, i.e. weightField & (Sf/mag(Sf))
.
Environment information
- OpenFOAM version : v2106, develop
Possible fixes
To my understanding for the weighted averages with vector weightField we need to compute the factor as below:
weightField & (Sf/mag(Sf))
together with the change in surfaceFieldValueTemplates.C, line 193 as follows:
const scalarField factor(weightingFactor(weightField, Sf));