Graceful exit when a field is not found

This commit is contained in:
Hrvoje Jasak 2011-08-03 12:00:26 +01:00
parent 9e7526282e
commit af228db90a

View file

@ -45,8 +45,18 @@ void setFieldType
Istream& fieldValueStream Istream& fieldValueStream
) )
{ {
// Read field and value together; otherwise there will be an input error
// when a field is not found. HJ, 3/Aug/2011
word fieldName(fieldValueStream); word fieldName(fieldValueStream);
typename GeoField::value_type value
(
static_cast<const typename GeoField::value_type&>
(
pTraits<typename GeoField::value_type>(fieldValueStream)
)
);
IOobject fieldHeader IOobject fieldHeader
( (
fieldName, fieldName,
@ -63,14 +73,6 @@ void setFieldType
GeoField field(fieldHeader, mesh); GeoField field(fieldHeader, mesh);
typename GeoField::value_type value
(
static_cast<const typename GeoField::value_type&>
(
pTraits<typename GeoField::value_type>(fieldValueStream)
)
);
if (selectedCells.size() == field.size()) if (selectedCells.size() == field.size())
{ {
field.internalField() = value; field.internalField() = value;