From 9e296d3040928530738206922ff4e8b27952df18 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 10 Aug 2023 10:16:17 +0100 Subject: [PATCH] dimensionedType: Make read flexible as to the presence of a name --- .../dimensionedType/dimensionedType.C | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index 43f4008609..0e3cd19ffe 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -54,13 +54,10 @@ void Foam::dimensioned::initialise(Istream& is) if (dims != dimensions_) { - FatalIOErrorInFunction - ( - is - ) << "The dimensions " << dims - << " provided do not match the required dimensions " - << dimensions_ - << abort(FatalIOError); + FatalIOErrorInFunction(is) + << "The dimensions " << dims + << " provided do not match the required dimensions " + << dimensions_ << abort(FatalIOError); } } @@ -337,16 +334,27 @@ bool Foam::dimensioned::readIfPresent(const dictionary& dict) template Foam::Istream& Foam::dimensioned::read(Istream& is) { - // Read name - is >> name_; + // If the name is present, read it + token nextToken(is); + is.putBack(nextToken); + if (nextToken.isWord()) + { + is >> name_; + } - // Read dimensionSet + multiplier - scalar mult; - dimensions_.read(is, mult); + // Read the dimensions and multiplier + scalar multiplier; + dimensions_.read(is, multiplier); - // Read value + // Read and scale the value is >> value_; - value_ *= mult; + value_ *= multiplier; + + // If the name is not present, set it + if (!nextToken.isWord()) + { + name_ = Foam::name(value_); + } // Check state of Istream is.check