From 3a6e4274097862cb8da26fe804ee7a500dd761d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 28 Sep 2022 09:24:46 +0200 Subject: [PATCH] ENH: simplify dictionary search for value/refValue in BCs - in expressions BCs in particular, there is various logic handling for if value/refValue/refGradient etc are found or not. Handle the lookups as findEntry and branch to use Field assign or other handling, depending on its existence. STYLE: use wordList instead of wordRes for copy/filter dictionary --- .../db/IOstreams/IOstreams/IOstreamOption.H | 4 +- .../dictionaryContent/dictionaryContent.H | 5 ++- .../expressions/exprResult/exprResult.C | 17 ++++---- .../expressions/exprResult/exprResult.H | 11 +++--- .../expressions/exprResult/exprResultI.H | 9 ++--- .../basic/value/valuePointPatchField.C | 6 +-- .../uniformInterpolationTable.H | 8 ++-- .../uniformInterpolationTableI.H | 8 ++-- src/OpenFOAM/primitives/bools/Switch/Switch.C | 4 +- src/OpenFOAM/primitives/bools/Switch/Switch.H | 14 +++---- .../faPatchFields/faPatchField/faPatchField.C | 6 +-- .../faePatchField/faePatchField.C | 6 +-- .../exprFixedValueFvPatchField.C | 15 ++++--- .../fvPatchFields/exprMixedFvPatchField.C | 39 +++++++++++-------- .../exprValuePointPatchField.C | 23 +++++------ .../exprValuePointPatchField.H | 4 +- .../fvPatchFields/fvPatchField/fvPatchField.C | 6 +-- .../fvsPatchField/fvsPatchField.C | 8 ++-- .../velocityFilmShellFvPatchVectorField.C | 4 +- .../thermalShellFvPatchScalarField.C | 4 +- .../vibrationShellFvPatchScalarField.C | 4 +- 21 files changed, 106 insertions(+), 99 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H b/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H index b1ae05ac4f..e952058dc4 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H @@ -42,8 +42,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef IOstreamOption_H -#define IOstreamOption_H +#ifndef Foam_IOstreamOption_H +#define Foam_IOstreamOption_H #include "word.H" diff --git a/src/OpenFOAM/db/dictionary/dictionaryContent/dictionaryContent.H b/src/OpenFOAM/db/dictionary/dictionaryContent/dictionaryContent.H index c1137f1eef..2d5ed67ea1 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryContent/dictionaryContent.H +++ b/src/OpenFOAM/db/dictionary/dictionaryContent/dictionaryContent.H @@ -32,10 +32,11 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef dictionaryContent_H -#define dictionaryContent_H +#ifndef Foam_dictionaryContent_H +#define Foam_dictionaryContent_H #include "dictionary.H" +#include "wordList.H" #include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/expressions/exprResult/exprResult.C b/src/OpenFOAM/expressions/exprResult/exprResult.C index 296cb3f7b9..5b013566ed 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResult.C +++ b/src/OpenFOAM/expressions/exprResult/exprResult.C @@ -254,8 +254,11 @@ Foam::expressions::exprResult::exprResult { DebugInFunction << nl; - if (dict.found("value")) + const auto* hasValue = dict.findEntry("value", keyType::LITERAL); + + if (hasValue) { + const auto& valueEntry = *hasValue; const bool uniform = isUniform_; const label len = @@ -268,12 +271,12 @@ Foam::expressions::exprResult::exprResult const bool ok = ( // Just use for