Graceful exit when a field is not found
This commit is contained in:
parent
9e7526282e
commit
af228db90a
1 changed files with 13 additions and 11 deletions
|
@ -45,8 +45,18 @@ void setFieldType
|
|||
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);
|
||||
|
||||
typename GeoField::value_type value
|
||||
(
|
||||
static_cast<const typename GeoField::value_type&>
|
||||
(
|
||||
pTraits<typename GeoField::value_type>(fieldValueStream)
|
||||
)
|
||||
);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
|
@ -63,27 +73,19 @@ void setFieldType
|
|||
|
||||
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())
|
||||
{
|
||||
field.internalField() = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(selectedCells, celli)
|
||||
forAll (selectedCells, celli)
|
||||
{
|
||||
field[selectedCells[celli]] = value;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(field.boundaryField(), patchi)
|
||||
forAll (field.boundaryField(), patchi)
|
||||
{
|
||||
// Forced patch assignment. HJ, 1/Aug/2010
|
||||
field.boundaryField()[patchi] ==
|
||||
|
@ -216,7 +218,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
PtrList<entry> regions(setFieldsDict.lookup("regions"));
|
||||
|
||||
forAll(regions, regionI)
|
||||
forAll (regions, regionI)
|
||||
{
|
||||
const entry& region = regions[regionI];
|
||||
|
||||
|
|
Reference in a new issue