diff --git a/src/OpenFOAM/dimensionSet/dimensionSetIO.C b/src/OpenFOAM/dimensionSet/dimensionSetIO.C index 3977383160..9fcfd9ee20 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSetIO.C +++ b/src/OpenFOAM/dimensionSet/dimensionSetIO.C @@ -143,7 +143,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w) const word subWord = w.substr(start, i-start); if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT) { - push(token(readScalar(IStringStream(subWord)()))); + push(token(readScalar(subWord))); } else { @@ -154,7 +154,9 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w) { if (isdigit(w[i])) { - push(token(readScalar(IStringStream(w[i])()))); + // Single digit: as scalar value + const scalar val = (w[i] - '0'); + push(token(val)); } else { @@ -169,7 +171,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w) const word subWord = w.substr(start); if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT) { - push(token(readScalar(IStringStream(subWord)()))); + push(token(readScalar(subWord))); } else { @@ -539,7 +541,7 @@ Foam::Istream& Foam::dimensionSet::read { const word symbol = symbolPow.substr(0, index); const word exp = symbolPow.substr(index+1); - scalar exponent = readScalar(IStringStream(exp)()); + scalar exponent = readScalar(exp); dimensionedScalar s; s.read(readSet[symbol], readSet); diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C index ae2c0cb5e0..51adcb3381 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C @@ -71,7 +71,7 @@ namespace Foam << exit(FatalError); } - return readScalar(IStringStream(splitted[componentColumns_[0]])()); + return readScalar(splitted[componentColumns_[0]]); } @@ -80,7 +80,7 @@ namespace Foam { Type result; - for(label i = 0;i < pTraits::nComponents; i++) + for (label i = 0; i < pTraits::nComponents; ++i) { if (componentColumns_[i] >= splitted.size()) { @@ -90,10 +90,7 @@ namespace Foam << exit(FatalError); } - result[i] = readScalar - ( - IStringStream(splitted[componentColumns_[i]])() - ); + result[i] = readScalar(splitted[componentColumns_[i]]); } return result; @@ -150,7 +147,7 @@ void Foam::csvTableReader::operator() break; } - scalar time = readScalar(IStringStream(splitted[timeColumn_])()); + scalar time = readScalar(splitted[timeColumn_]); Type value = readValue(splitted); values.append(Tuple2(time, value)); diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C index 1ddf2cc1ca..4ddc9123dc 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C @@ -43,7 +43,7 @@ Foam::label Foam::Function1Types::CSV::readValue << exit(FatalError); } - return readLabel(IStringStream(splitted[componentColumns_[0]])()); + return readLabel(splitted[componentColumns_[0]]); } @@ -61,7 +61,7 @@ Foam::scalar Foam::Function1Types::CSV::readValue << exit(FatalError); } - return readScalar(IStringStream(splitted[componentColumns_[0]])()); + return readScalar(splitted[componentColumns_[0]]); } @@ -70,18 +70,17 @@ Type Foam::Function1Types::CSV::readValue(const List& splitted) { Type result; - for (label i = 0; i < pTraits::nComponents; i++) + for (label i = 0; i < pTraits::nComponents; ++i) { if (componentColumns_[i] >= splitted.size()) { FatalErrorInFunction - << "No column " << componentColumns_[i] << " in " + << "No column " << componentColumns_[i] << " in " << splitted << endl << exit(FatalError); } - result[i] = - readScalar(IStringStream(splitted[componentColumns_[i]])()); + result[i] = readScalar(splitted[componentColumns_[i]]); } return result; @@ -189,7 +188,7 @@ void Foam::Function1Types::CSV::read() break; } - scalar x = readScalar(IStringStream(splitted[refColumn_])()); + scalar x = readScalar(splitted[refColumn_]); Type value = readValue(splitted); values.append(Tuple2(x, value)); diff --git a/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C b/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C index 7bcc2d3243..761ec70b31 100644 --- a/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C +++ b/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -103,9 +103,9 @@ bool Foam::fileFormats::NASedgeFormat::read { edge e; - // label groupId = readLabel(IStringStream(line.substr(16,8))()); - e[0] = readLabel(IStringStream(line.substr(24,8))()); - e[1] = readLabel(IStringStream(line.substr(32,8))()); + // label groupId = readLabel(line.substr(16,8)); + e[0] = readLabel(line.substr(24,8)); + e[1] = readLabel(line.substr(32,8)); // discard groupID dynEdges.append(e); @@ -114,19 +114,19 @@ bool Foam::fileFormats::NASedgeFormat::read { edge e; - // label groupId = readLabel(IStringStream(line.substr(16,8))()); - e[0] = readLabel(IStringStream(line.substr(16,8))()); - e[1] = readLabel(IStringStream(line.substr(24,8))()); + // label groupId = readLabel(line.substr(16,8)); + e[0] = readLabel(line.substr(16,8)); + e[1] = readLabel(line.substr(24,8)); // discard groupID dynEdges.append(e); } else if (cmd == "GRID") { - label index = readLabel(IStringStream(line.substr(8,8))()); - scalar x = parseNASCoord(line.substr(24, 8)); - scalar y = parseNASCoord(line.substr(32, 8)); - scalar z = parseNASCoord(line.substr(40, 8)); + label index = readLabel(line.substr(8,8)); + scalar x = readNasScalar(line.substr(24, 8)); + scalar y = readNasScalar(line.substr(32, 8)); + scalar z = readNasScalar(line.substr(40, 8)); pointId.append(index); dynPoints.append(point(x, y, z)); @@ -139,9 +139,9 @@ bool Foam::fileFormats::NASedgeFormat::read // GRID* 126 0 -5.55999875E+02 -5.68730474E+02 // * 2.14897901E+02 - label index = readLabel(IStringStream(line.substr(8,16))()); - scalar x = parseNASCoord(line.substr(40, 16)); - scalar y = parseNASCoord(line.substr(56, 16)); + label index = readLabel(line.substr(8,16)); + scalar x = readNasScalar(line.substr(40, 16)); + scalar y = readNasScalar(line.substr(56, 16)); is.getLine(line); if (line[0] != '*') @@ -153,7 +153,7 @@ bool Foam::fileFormats::NASedgeFormat::read << "File:" << is.name() << " line:" << is.lineNumber() << exit(FatalError); } - scalar z = parseNASCoord(line.substr(8, 16)); + scalar z = readNasScalar(line.substr(8, 16)); pointId.append(index); dynPoints.append(point(x, y, z)); diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C index ab37ac9a90..a7ec90fc4d 100644 --- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C @@ -92,9 +92,9 @@ bool Foam::fileFormats::NASsurfaceFormat::read // ANSA extension if (line.startsWith("$ANSA_NAME")) { - string::size_type sem0 = line.find(';', 0); - string::size_type sem1 = line.find(';', sem0+1); - string::size_type sem2 = line.find(';', sem1+1); + const auto sem0 = line.find(';', 0); + const auto sem1 = line.find(';', sem0+1); + const auto sem2 = line.find(';', sem1+1); if ( @@ -103,10 +103,7 @@ bool Foam::fileFormats::NASsurfaceFormat::read && sem2 != string::npos ) { - ansaId = readLabel - ( - IStringStream(line.substr(sem0+1, sem1-sem0-1))() - ); + ansaId = readLabel(line.substr(sem0+1, sem1-sem0-1)); ansaType = line.substr(sem1+1, sem2-sem1-1); string rawName; @@ -125,11 +122,7 @@ bool Foam::fileFormats::NASsurfaceFormat::read // $HMNAME COMP 1"partName" if (line.startsWith("$HMNAME COMP") && line.find('"') != string::npos) { - label groupId = readLabel - ( - IStringStream(line.substr(16, 16))() - ); - + label groupId = readLabel(line.substr(16, 16)); IStringStream lineStream(line.substr(32)); string rawName; @@ -177,10 +170,10 @@ bool Foam::fileFormats::NASsurfaceFormat::read if (cmd == "CTRIA3") { - label groupId = readLabel(IStringStream(line.substr(16,8))()); - label a = readLabel(IStringStream(line.substr(24,8))()); - label b = readLabel(IStringStream(line.substr(32,8))()); - label c = readLabel(IStringStream(line.substr(40,8))()); + label groupId = readLabel(line.substr(16,8)); + label a = readLabel(line.substr(24,8)); + label b = readLabel(line.substr(32,8)); + label c = readLabel(line.substr(40,8)); // Convert groupID into zoneId Map