mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: faceSource: #1364
This commit is contained in:
@ -444,6 +444,20 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
|||||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
{
|
{
|
||||||
Info<< " weight field = " << weightFieldName_ << nl;
|
Info<< " weight field = " << weightFieldName_ << nl;
|
||||||
|
|
||||||
|
if (source_ == stSampledSurface)
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"void Foam::fieldValues::faceSource::initialise"
|
||||||
|
"("
|
||||||
|
"const dictionary&"
|
||||||
|
")",
|
||||||
|
dict
|
||||||
|
)
|
||||||
|
<< "Cannot use weightField for a sampledSurface"
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict.found("orientedWeightField"))
|
if (dict.found("orientedWeightField"))
|
||||||
@ -664,8 +678,8 @@ void Foam::fieldValues::faceSource::write()
|
|||||||
file() << obr_.time().value() << tab << totalArea;
|
file() << obr_.time().value() << tab << totalArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct weight field
|
// construct weight field. Note: zero size means weight = 1
|
||||||
scalarField weightField(faceId_.size(), 1.0);
|
scalarField weightField;
|
||||||
if (weightFieldName_ != "none")
|
if (weightFieldName_ != "none")
|
||||||
{
|
{
|
||||||
weightField =
|
weightField =
|
||||||
|
|||||||
@ -195,7 +195,14 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
|||||||
}
|
}
|
||||||
case opWeightedAverage:
|
case opWeightedAverage:
|
||||||
{
|
{
|
||||||
result = sum(values)/sum(weightField);
|
if (weightField.size())
|
||||||
|
{
|
||||||
|
result = sum(values)/sum(weightField);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = sum(values)/values.size();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opAreaAverage:
|
case opAreaAverage:
|
||||||
@ -329,8 +336,13 @@ bool Foam::fieldValues::faceSource::writeValues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// apply scale factor and weight field
|
// apply scale factor and weight field
|
||||||
values *= scaleFactor_*weightField;
|
values *= scaleFactor_;
|
||||||
|
if (weightField.size())
|
||||||
|
{
|
||||||
|
values *= weightField;
|
||||||
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user