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

@ -45,7 +45,8 @@ bool Foam::fieldValues::cellSource::validField(const word& fieldName) const
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::setFieldValues
(
const word& fieldName
const word& fieldName,
const bool mustGet
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> vf;
@ -55,6 +56,20 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::setFieldValues
return filterField(obr_.lookupObject<vf>(fieldName));
}
if (mustGet)
{
FatalErrorIn
(
"Foam::tmp<Foam::Field<Type> > "
"Foam::fieldValues::cellSource::setFieldValues"
"("
"const word&, "
"const bool"
") const"
) << "Field " << fieldName << " not found in database"
<< abort(FatalError);
}
return tmp<Field<Type> >(new Field<Type>(0.0));
}
@ -125,7 +140,13 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
scalarField V(filterField(mesh().V()));
combineFields(V);
scalarField weightField(setFieldValues<scalar>(weightFieldName_));
scalarField weightField;
if (operation_ == opWeightedAverage)
{
weightField = setFieldValues<scalar>(weightFieldName_, true);
}
combineFields(weightField);
if (Pstream::master())