ENH: Updated weight field initialisation for fieldValues function object

This commit is contained in:
andy
2011-08-16 18:05:06 +01:00
parent c2dd153a14
commit 53f332bc60
6 changed files with 55 additions and 39 deletions

View File

@ -52,7 +52,8 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
(
const word& fieldName
const word& fieldName,
const bool mustGet
) const
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
@ -74,6 +75,20 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
}
}
if (mustGet)
{
FatalErrorIn
(
"Foam::tmp<Foam::Field<Type> > "
"Foam::fieldValues::faceSource::getFieldValues"
"("
"const word&, "
"const bool"
") const"
) << "Field " << fieldName << " not found in database"
<< abort(FatalError);
}
return tmp<Field<Type> >(new Field<Type>(0));
}
@ -139,7 +154,13 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
if (ok)
{
Field<Type> values(getFieldValues<Type>(fieldName));
scalarField weightField(getFieldValues<scalar>(weightFieldName_));
scalarField weightField;
if (operation_ == opWeightedAverage)
{
weightField = getFieldValues<scalar>(weightFieldName_, true);
}
scalarField magSf;
if (surfacePtr_.valid())