diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 25177e5c6700bd6ce9c33f6d60fdfe6667ee7546..9342fb122c5103a8cdbabab08fab6c665cb1fbbd 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -314,9 +314,12 @@ public: static word member(const word& name); //- Create scope:name or scope_name string - // An empty scope or name is ignored. - template<class StringType> - static inline word scopedName(StringType scope, const word& name); + // An empty scope is ignored. + static inline word scopedName + ( + const std::string& scope, + const word& name + ); //- Return the IOobject, but also consider an alternative file name. // diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index c7ee333ea68195bb15ea0013c411268ef38f59a1..9447a4833dcff72e8b77cb9997b0c733d357e8bc 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -43,18 +43,13 @@ inline Foam::word Foam::IOobject::groupName } -template<class StringType> inline Foam::word Foam::IOobject::scopedName ( - StringType scope, + const std::string& scope, const word& name ) { - if (name.empty()) - { - return scope; - } - else if (scope.empty()) + if (scope.empty()) { return name; } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C index d402678d8e0d61d143c1b851bc54c7635863d491..e3e6875ae1fc9572e117e4ca9abfa7057c466e3e 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C @@ -31,22 +31,18 @@ License // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -namespace Foam +namespace { - // Return the current get position for std input stream - static inline std::streampos tellg(Istream* isptr) - { - ISstream* sptr = dynamic_cast<ISstream*>(isptr); - - if (sptr) - { - return sptr->stdStream().tellg(); - } - return 0; - } +// The current get position (std::istream only) +inline std::streampos stream_tellg(Foam::Istream* isptr) +{ + auto* sptr = dynamic_cast<Foam::ISstream*>(isptr); + return sptr ? sptr->stdStream().tellg() : std::streampos(0); } +} // End anonymous namespace + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -141,7 +137,7 @@ bool Foam::Istream::readEnd(const char* funcName) << "Expected a '" << token::END_LIST << "' while reading " << funcName << ", found " << delimiter.info() - << " at stream position " << tellg(this) << nl + << " at stream position " << stream_tellg(this) << nl << exit(FatalIOError); } @@ -182,7 +178,7 @@ char Foam::Istream::readEndList(const char* funcName) << "' or a '" << token::END_BLOCK << "' while reading " << funcName << ", found " << delimiter.info() - << " at stream position " << tellg(this) << nl + << " at stream position " << stream_tellg(this) << nl << exit(FatalIOError); return '\0'; diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C index 791dfbfb16c8f3c97c6bc47735fa4b4dfd40c48c..546d5db0c798ebb282210ff4d4dfc809dfa577a2 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -330,18 +330,13 @@ void Foam::lduMatrix::setResidualField return; } - word lookupName; - if (initial) - { - lookupName = word("initialResidual:" + fieldName); - } - else - { - lookupName = word("residual:" + fieldName); - } - scalarIOField* residualPtr = - mesh().thisDb().getObjectPtr<scalarIOField>(lookupName); + mesh().thisDb().getObjectPtr<scalarIOField> + ( + initial + ? IOobject::scopedName("initialResidual", fieldName) + : IOobject::scopedName("residual", fieldName) + ); if (residualPtr) { diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index 93cc67fadcfac0ee58922906e28dcf180cf15460..bda9620c394b5c78f24aaef911d0866e54a5cfa4 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -484,7 +484,11 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ), residualName_ ( - dict.getOrDefault<word>("residual", "initialResidual:p") + dict.getOrDefault<word> + ( + "residual", + IOobject::scopedName("initialResidual", "p") + ) ), UName_ ( diff --git a/src/functionObjects/utilities/solverInfo/solverInfo.C b/src/functionObjects/utilities/solverInfo/solverInfo.C index 296ae571af74708a3b1bc7acdebbc87a58f67938..8808cfa5606e49f17932f276a66aa96f955317ba 100644 --- a/src/functionObjects/utilities/solverInfo/solverInfo.C +++ b/src/functionObjects/utilities/solverInfo/solverInfo.C @@ -86,7 +86,10 @@ void Foam::functionObjects::solverInfo::createResidualField return; } - const word residualName("initialResidual:" + fieldName); + const word residualName + ( + IOobject::scopedName("initialResidual", fieldName) + ); if (!mesh_.foundObject<IOField<scalar>>(residualName)) {