BUG: faceSource: #1364

This commit is contained in:
mattijs
2014-08-05 15:25:14 +01:00
committed by Andrew Heather
parent 993895b048
commit 5b215dce4c
2 changed files with 30 additions and 4 deletions

View File

@ -444,6 +444,20 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
if (dict.readIfPresent("weightField", weightFieldName_))
{
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"))
@ -664,8 +678,8 @@ void Foam::fieldValues::faceSource::write()
file() << obr_.time().value() << tab << totalArea;
}
// construct weight field
scalarField weightField(faceId_.size(), 1.0);
// construct weight field. Note: zero size means weight = 1
scalarField weightField;
if (weightFieldName_ != "none")
{
weightField =

View File

@ -194,8 +194,15 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
break;
}
case opWeightedAverage:
{
if (weightField.size())
{
result = sum(values)/sum(weightField);
}
else
{
result = sum(values)/values.size();
}
break;
}
case opAreaAverage:
@ -329,8 +336,13 @@ bool Foam::fieldValues::faceSource::writeValues
}
}
// apply scale factor and weight field
values *= scaleFactor_*weightField;
values *= scaleFactor_;
if (weightField.size())
{
values *= weightField;
}
if (Pstream::master())
{