Skip to content
Snippets Groups Projects
Commit e0f39930 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: scalar - added readOrDefault(is, defaultValue) function

parent 12ba22be
Branches
1 merge request!560Integration of grey area turbulence models from Upstream CFD
......@@ -40,6 +40,24 @@ Foam::scalar Foam::readScalar(Istream& is)
}
Foam::scalar Foam::readScalarOrDefault(Istream& is, const scalar defaultValue)
{
if (is.good())
{
token tok(is);
if (tok.isNumber())
{
return tok.scalarToken();
}
is.putBack(tok);
}
return defaultValue;
}
Foam::scalar Foam::readRawScalar(Istream& is)
{
scalar val(0);
......
......@@ -103,6 +103,9 @@ namespace Foam
//- Read scalar from stream.
scalar readScalar(Istream& is);
//- Read scalar from stream if present or return default value
scalar readScalarOrDefault(Istream& is, const scalar defaultValue);
//- Read raw scalar from binary stream.
// \note No internal check for binary vs ascii,
// the caller knows what they are doing
......@@ -172,6 +175,9 @@ namespace Foam
//- Read scalar from stream.
scalar readScalar(Istream& is);
//- Read scalar from stream if present or return default value
scalar readScalarOrDefault(Istream& is, const scalar defaultValue);
//- Read raw scalar from binary stream.
// \note No internal check for binary vs ascii,
// the caller knows what they are doing
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment