diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index c60eb8e463aebc61e5d5a9b1e6ea3e48441723a2..d60ada722bca3daabc290f3b3ecc0d9f09e0b280 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -406,6 +406,7 @@ public: //- Construct top-level dictionary from Istream, //- reading entries until EOF. Discards the header. + // \note this constructor should be explicit dictionary(Istream& is); //- Construct top-level dictionary from Istream, @@ -420,7 +421,7 @@ public: //- Construct top-level dictionary as copy from pointer to dictionary. // A null pointer is treated like an empty dictionary. - dictionary(const dictionary* dict); + explicit dictionary(const dictionary* dict); //- Move construct for given parent dictionary dictionary(const dictionary& parentDict, dictionary&& dict); @@ -928,7 +929,7 @@ public: // Emits FatalIOError void checkITstream(const ITstream& is, const word& keyword) const; - //- Read dictionary from Istream + //- Read dictionary from Istream. Discards the header. bool read(Istream& is); //- Read dictionary from Istream, optionally keeping the header @@ -944,7 +945,7 @@ public: void writeEntry(const keyType& keyword, Ostream& os) const; //- Write dictionary entries. - // \param extraNewLine adds additional newline\n between entries + // \param extraNewLine adds additional newline between entries // for "top-level" dictionaries void writeEntries(Ostream& os, const bool extraNewLine=false) const; diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C index 633e9c216a350414e65ab01d5b9f7f9cd1879df1..383d0603df00f6ab6a8f7d44fea61f7080345d1d 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,7 +38,7 @@ Foam::dictionaryEntry::dictionaryEntry ) : entry(keyType(is)), - dictionary(parentDict, is) + dictionary(parentDict, dictionary(is)) { is.fatalCheck(FUNCTION_NAME); } diff --git a/src/OpenFOAM/expressions/exprResult/exprResult.C b/src/OpenFOAM/expressions/exprResult/exprResult.C index 06654035227eb66a99af21f1190955481463c906..b1f93df85594bd1adc283792585f66af59e55f12 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResult.C +++ b/src/OpenFOAM/expressions/exprResult/exprResult.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> + Copyright (C) 2012-2018 Bernhard Gschaider Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License @@ -354,6 +354,17 @@ Foam::expressions::exprResult::New } +Foam::autoPtr<Foam::expressions::exprResult> +Foam::expressions::exprResult::New +( + Istream& is +) +{ + dictionary dict(is); + return New(dict); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::expressions::exprResult::~exprResult() diff --git a/src/OpenFOAM/expressions/exprResult/exprResult.H b/src/OpenFOAM/expressions/exprResult/exprResult.H index 495573c39486977abc1f807c4c81d06d1ba6acf3..3c6f9299dbf263dcf1777f1103deba5b4725bd22 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResult.H +++ b/src/OpenFOAM/expressions/exprResult/exprResult.H @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2012-2018 Bernhard Gschaider + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -323,6 +323,9 @@ public: const bool needsValue = false ); + //- Construct from Istream as dictionary content + explicit exprResult(Istream& is); + //- Construct by copying a field template<class Type> explicit exprResult(const Field<Type>& fld); @@ -362,6 +365,9 @@ public: //- Return a reference to the selected value driver static autoPtr<exprResult> New(const dictionary& dict); + //- Construct from Istream as dictionary content + static autoPtr<exprResult> New(Istream& is); + //- Clone virtual autoPtr<exprResult> clone() const { diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index d2fc33510fb3b95e92c875968b215ef86322af77..ef9866c4340ccec5dc0244ddb8e03068ef18cb50 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -234,7 +234,7 @@ directionalPressureGradientExplicitSource if (propsFile.good()) { Info<< " Reading pressure gradient from file" << endl; - dictionary propsDict(dictionary::null, propsFile); + dictionary propsDict(propsFile); propsDict.readEntry("gradient", gradP0_); } diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 803602ffb77fcf798326787d26fb23472bb04a50..00c9a8f1e12ac45b658edd96057574ba13442526 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,7 +109,7 @@ Foam::fv::meanVelocityForce::meanVelocityForce if (propsFile.good()) { Info<< " Reading pressure gradient from file" << endl; - dictionary propsDict(dictionary::null, propsFile); + dictionary propsDict(propsFile); propsDict.readEntry("gradient", gradP0_); }