From 15ce7dcf0ae228f0d8ed7e7f21ce53d3b0a4fdfe Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 16 Apr 2012 15:51:20 +0100 Subject: [PATCH] dimensionedType: Add support for optional read and re-read of name and dimensions Supports rho 1; rho [1 -3 0 0 0] 1; rho rho [1 -3 0 0 0] 1; --- .../dimensionedType/dimensionedType.C | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index cf841919b8..4e96c3012a 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -131,6 +131,16 @@ dimensioned::dimensioned token nextToken(is); is.putBack(nextToken); + // Check if the original format is used in which the name is provided + // and reset the name to that read + if (nextToken.isWord()) + { + is >> name_; + is >> nextToken; + is.putBack(nextToken); + } + + // If the dimensions are provided compare with the argument if (nextToken == token::BEGIN_SQR) { dimensionSet dims(is); @@ -391,8 +401,26 @@ dimensioned min template Istream& operator>>(Istream& is, dimensioned& dt) { - // do a stream read op for a Type and a dimensions()et - is >> dt.name_ >> dt.dimensions_ >> dt.value_; + token nextToken(is); + is.putBack(nextToken); + + // Check if the original format is used in which the name is provided + // and reset the name to that read + if (nextToken.isWord()) + { + is >> dt.name_; + is >> nextToken; + is.putBack(nextToken); + } + + // If the dimensions are provided reset the dimensions to those read + if (nextToken == token::BEGIN_SQR) + { + is >> dt.dimensions_; + } + + // Read the value + is >> dt.value_; // Check state of Istream is.check("Istream& operator>>(Istream&, dimensioned&)");