diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index 38133bd05..bc8996a55 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.C @@ -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 + ( + pTraits(fieldValueStream) + ) + ); + IOobject fieldHeader ( fieldName, @@ -63,27 +73,19 @@ void setFieldType GeoField field(fieldHeader, mesh); - typename GeoField::value_type value - ( - static_cast - ( - pTraits(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 regions(setFieldsDict.lookup("regions")); - forAll(regions, regionI) + forAll (regions, regionI) { const entry& region = regions[regionI];