STYLE: simpler construct for empty tmp field in volFieldValue

- originally (incorrectly) was a Field(0.0), which was generalized
  to Field(Zero), but Field() is the correct form

STYLE: rename 'mustGet' to more standard 'mandatory' variable
This commit is contained in:
Mark Olesen
2020-09-02 14:47:12 +02:00
parent b2feb6a8d8
commit 0e6df58c70
2 changed files with 7 additions and 12 deletions

View File

@ -233,7 +233,7 @@ protected:
// Checks for availability on any processor.
inline bool canWeight(const scalarField& weightField) const;
//- Return true if the field name is valid
//- True if the field name is valid (exists, and a supported type)
template<class Type>
bool validField(const word& fieldName) const;
@ -242,7 +242,7 @@ protected:
tmp<Field<Type>> getFieldValues
(
const word& fieldName,
const bool mustGet = false
const bool mandatory = false
) const;
//- Apply the 'operation' to the values

View File

@ -40,16 +40,11 @@ bool Foam::functionObjects::fieldValues::volFieldValue::validField
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
typedef typename VolFieldType::Internal IntVolFieldType;
if
return
(
obr_.foundObject<VolFieldType>(fieldName)
|| obr_.foundObject<IntVolFieldType>(fieldName)
)
{
return true;
}
return false;
);
}
@ -58,7 +53,7 @@ Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::volFieldValue::getFieldValues
(
const word& fieldName,
const bool mustGet
const bool mandatory
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
@ -73,14 +68,14 @@ Foam::functionObjects::fieldValues::volFieldValue::getFieldValues
return filterField(obr_.lookupObject<IntVolFieldType>(fieldName));
}
if (mustGet)
if (mandatory)
{
FatalErrorInFunction
<< "Field " << fieldName << " not found in database"
<< abort(FatalError);
}
return tmp<Field<Type>>::New(Zero);
return tmp<Field<Type>>::New();
}