From ddeaa566efd2d7dcdb4c9a53826c498c89b32b3c Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 10 Jan 2024 15:26:01 +0000 Subject: [PATCH] coded: Permit both untyped and typed substitutions Coded functionality now supports basic un-typed substitutions from the surrounding dictionary. For example: value 1.2345; #codeExecute { scalar s = $value; ... }; It also now supports the more functional typed substitutions, such as: direction (1 0 0); #codeExecute { vector v = $direction; ... }; These substitutions are now possible in all code blocks. Blocks with access to the dictionary (e.g., #codeRead) will do a lookup which will not require re-compilation if the value is changed. Blocks without access to the dictionary will have the value directly substituted, and will require recompilation when the value is changed. --- .../codedFixedValueFvPatchFieldTemplate.C | 2 ++ .../codedFixedValuePointPatchFieldTemplate.C | 2 ++ .../dynamicCode/codedFunction1Template.C | 1 + .../dynamicCode/codedFunction2Template.C | 1 + .../dynamicCode/codedFunctionObjectTemplate.C | 1 + .../dynamicCode/codedFvModelTemplate.C | 1 + .../codedMixedFvPatchFieldTemplate.C | 2 ++ .../functionEntries/codeStream/codeStream.C | 5 +++-- .../db/dynamicLibrary/codedBase/codedBase.C | 4 ++-- .../db/dynamicLibrary/codedBase/codedBase.H | 5 ++++- .../compileTemplate/compileTemplate.H | 8 +++++++- .../dynamicCode/dynamicCodeContext.C | 11 ++++++----- .../dynamicCode/dynamicCodeContext.H | 5 +++-- .../codedFixedValuePointPatchField.C | 16 +++++++++------- .../codedFixedValuePointPatchField.H | 5 ++++- .../functions/Function1/Coded/CodedFunction1.C | 15 +++++++++------ .../functions/Function1/Coded/CodedFunction1.H | 5 ++++- .../functions/Function2/Coded/CodedFunction2.C | 15 +++++++++------ .../functions/Function2/Coded/CodedFunction2.H | 5 ++++- .../primitives/strings/stringOps/stringOps.C | 4 ++-- .../codedFixedValueFvPatchField.C | 16 +++++++++------- .../codedFixedValueFvPatchField.H | 5 ++++- .../codedMixed/codedMixedFvPatchField.C | 16 +++++++++------- .../codedMixed/codedMixedFvPatchField.H | 5 ++++- .../codedFunctionObject/codedFunctionObject.C | 18 +++++++++++++++++- .../codedFunctionObject/codedFunctionObject.H | 5 ++++- .../general/codedFvModel/codedFvModel.C | 15 ++++++++++++++- .../general/codedFvModel/codedFvModel.H | 5 ++++- 28 files changed, 141 insertions(+), 57 deletions(-) diff --git a/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.C index aa4ff17946..ace1ac9270 100644 --- a/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.C @@ -28,7 +28,9 @@ License #include "fieldMapper.H" #include "volFields.H" #include "surfaceFields.H" +#include "read.H" #include "unitConversion.H" + //{{{ begin codeInclude ${codeInclude} //}}} end codeInclude diff --git a/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.C index c2b87df682..141304d347 100644 --- a/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.C @@ -27,7 +27,9 @@ License #include "addToRunTimeSelectionTable.H" #include "fieldMapper.H" #include "pointFields.H" +#include "read.H" #include "unitConversion.H" + //{{{ begin codeInclude ${codeInclude} //}}} end codeInclude diff --git a/etc/codeTemplates/dynamicCode/codedFunction1Template.C b/etc/codeTemplates/dynamicCode/codedFunction1Template.C index 18453aa734..ce22667e5c 100644 --- a/etc/codeTemplates/dynamicCode/codedFunction1Template.C +++ b/etc/codeTemplates/dynamicCode/codedFunction1Template.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "codedFunction1Template.H" +#include "read.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/dynamicCode/codedFunction2Template.C b/etc/codeTemplates/dynamicCode/codedFunction2Template.C index 49388693b1..93a5a5e6f0 100644 --- a/etc/codeTemplates/dynamicCode/codedFunction2Template.C +++ b/etc/codeTemplates/dynamicCode/codedFunction2Template.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "codedFunction2Template.H" +#include "read.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/dynamicCode/codedFunctionObjectTemplate.C b/etc/codeTemplates/dynamicCode/codedFunctionObjectTemplate.C index 333013208d..890883da2d 100644 --- a/etc/codeTemplates/dynamicCode/codedFunctionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFunctionObjectTemplate.C @@ -25,6 +25,7 @@ License #include "codedFunctionObjectTemplate.H" #include "volFields.H" +#include "read.H" #include "unitConversion.H" #include "addToRunTimeSelectionTable.H" diff --git a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C index ef3d08038f..b3fe40636a 100644 --- a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C @@ -27,6 +27,7 @@ License #include "addToRunTimeSelectionTable.H" #include "volFields.H" #include "surfaceFields.H" +#include "read.H" #include "unitConversion.H" #include "fvMatrix.H" diff --git a/etc/codeTemplates/dynamicCode/codedMixedFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/codedMixedFvPatchFieldTemplate.C index c15ee39e58..cc36ed34ab 100644 --- a/etc/codeTemplates/dynamicCode/codedMixedFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedMixedFvPatchFieldTemplate.C @@ -28,7 +28,9 @@ License #include "fieldMapper.H" #include "volFields.H" #include "surfaceFields.H" +#include "read.H" #include "unitConversion.H" + //{{{ begin codeInclude ${codeInclude} //}}} end codeInclude diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 982712f1ba..c44fc7322b 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,7 +92,8 @@ Foam::functionEntries::codeStream::getFunction const dynamicCodeContext context ( codeDict, - {"code", "codeInclude", "localCode"} + {"code", "codeInclude", "localCode"}, + {"dict", word::null, word::null} ); // codeName: codeStream + _ diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C index 1e8638c47a..c1d455da09 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -322,7 +322,7 @@ void Foam::codedBase::updateLibrary() const dict ); - dynamicCodeContext context(dict, codeKeys()); + dynamicCodeContext context(dict, codeKeys(), codeDictVars()); // codeName: name + _ // codeDir : name diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H index fd75c14c2b..668a073d8c 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -112,6 +112,9 @@ protected: //- Get the keywords associated with source code virtual wordList codeKeys() const = 0; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const = 0; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const = 0; diff --git a/src/OpenFOAM/db/dynamicLibrary/compileTemplate/compileTemplate.H b/src/OpenFOAM/db/dynamicLibrary/compileTemplate/compileTemplate.H index e27f22e2e5..3ca29069dc 100644 --- a/src/OpenFOAM/db/dynamicLibrary/compileTemplate/compileTemplate.H +++ b/src/OpenFOAM/db/dynamicLibrary/compileTemplate/compileTemplate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,6 +73,12 @@ class compileTemplate return wordList::null(); } + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const + { + return wordList::null(); + } + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C index f5ed95b388..7202c062ec 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,8 @@ void Foam::dynamicCodeContext::addLineDirective Foam::dynamicCodeContext::dynamicCodeContext ( const dictionary& dict, - const wordList& codeKeys + const wordList& codeKeys, + const wordList& codeDictVars ) : dict_(dict), @@ -64,7 +65,7 @@ Foam::dynamicCodeContext::dynamicCodeContext if (codePtrs[i]) { string s(stringOps::trim(verbatimString(codePtrs[i]->stream()))); - stringOps::inplaceExpandCodeString(s, dict); + stringOps::inplaceExpandCodeString(s, dict, codeDictVars[i]); code_.insert(key, s); } else @@ -78,7 +79,7 @@ Foam::dynamicCodeContext::dynamicCodeContext if (optionsPtr) { options_ = stringOps::trim(verbatimString(optionsPtr->stream())); - stringOps::inplaceExpandCodeString(options_, dict); + stringOps::inplaceExpandCodeString(options_, dict, word::null); } // Libs @@ -86,7 +87,7 @@ Foam::dynamicCodeContext::dynamicCodeContext if (libsPtr) { libs_ = stringOps::trim(verbatimString(libsPtr->stream())); - stringOps::inplaceExpandCodeString(libs_, dict); + stringOps::inplaceExpandCodeString(libs_, dict, word::null); } // Calculate SHA1 digest from all entries diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H index a642b8b413..d2b4e501ee 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -89,7 +89,8 @@ public: dynamicCodeContext ( const dictionary& dict, - const wordList& codeKeys + const wordList& codeKeys, + const wordList& codeDictVars ); diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C index 2921400a57..384798491d 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,12 +35,14 @@ License template Foam::wordList Foam::codedFixedValuePointPatchField::codeKeys() const { - return - { - "code", - "codeInclude", - "localCode" - }; + return {"code", "codeInclude", "localCode"}; +} + + +template +Foam::wordList Foam::codedFixedValuePointPatchField::codeDictVars() const +{ + return {word::null, word::null, word::null}; } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H index d93251b49d..73bdf4132b 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -110,6 +110,9 @@ class codedFixedValuePointPatchField //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.C b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.C index 5f7e67e5b3..67b0fe5834 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.C +++ b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,11 +32,14 @@ License template Foam::wordList Foam::Function1s::Coded::codeKeys() const { - return - { - "code", - "codeInclude" - }; + return {"code", "codeInclude"}; +} + + +template +Foam::wordList Foam::Function1s::Coded::codeDictVars() const +{ + return {word::null, word::null}; } diff --git a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H index 4823ef9142..afc0a8c421 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -98,6 +98,9 @@ class Coded //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.C b/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.C index bb89aae046..de63ee86d2 100644 --- a/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.C +++ b/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,11 +32,14 @@ License template Foam::wordList Foam::Function2s::Coded::codeKeys() const { - return - { - "code", - "codeInclude" - }; + return {"code", "codeInclude"}; +} + + +template +Foam::wordList Foam::Function2s::Coded::codeDictVars() const +{ + return {word::null, word::null}; } diff --git a/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.H b/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.H index a36e9ada6c..868b1d9474 100644 --- a/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.H +++ b/src/OpenFOAM/primitives/functions/Function2/Coded/CodedFunction2.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -83,6 +83,9 @@ class Coded //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index cc9292215a..c2eeedc2d8 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -587,7 +587,7 @@ Foam::string& Foam::stringOps::inplaceExpandCodeString // If the dictionary is not accessible but the // type is known, then read the substituted value // from a string - buf << "read<" << varType << ">(\""; + buf << "Foam::read<" << varType << ">(\""; } // If the dictionary is not accessible and/or the type diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index d7519dd423..aa184512bb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,12 +35,14 @@ License template Foam::wordList Foam::codedFixedValueFvPatchField::codeKeys() const { - return - { - "code", - "codeInclude", - "localCode" - }; + return {"code", "codeInclude", "localCode"}; +} + + +template +Foam::wordList Foam::codedFixedValueFvPatchField::codeDictVars() const +{ + return {word::null, word::null, word::null}; } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H index 0142b5ed37..bef1db863b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -108,6 +108,9 @@ class codedFixedValueFvPatchField //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C index 5b9b972e49..2bb712bfe5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,12 +35,14 @@ License template Foam::wordList Foam::codedMixedFvPatchField::codeKeys() const { - return - { - "code", - "codeInclude", - "localCode" - }; + return {"code", "codeInclude", "localCode"}; +} + + +template +Foam::wordList Foam::codedMixedFvPatchField::codeDictVars() const +{ + return {word::null, word::null, word::null}; } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H index a308f0d00e..8d26670bbb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -118,6 +118,9 @@ class codedMixedFvPatchField //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index a0f8f5d22b..f9f0500cac 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,22 @@ Foam::wordList Foam::codedFunctionObject::codeKeys() const } +Foam::wordList Foam::codedFunctionObject::codeDictVars() const +{ + return + { + word::null, + word::null, + word::null, + word::null, + "dict", + word::null, + word::null, + word::null, + }; +} + + void Foam::codedFunctionObject::prepare ( dynamicCode& dynCode, diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index 298a486fb3..096082df9a 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,6 +99,9 @@ class codedFunctionObject //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Adapt the context for the current object virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; diff --git a/src/fvModels/general/codedFvModel/codedFvModel.C b/src/fvModels/general/codedFvModel/codedFvModel.C index e2998a2bfd..b8e639fff9 100644 --- a/src/fvModels/general/codedFvModel/codedFvModel.C +++ b/src/fvModels/general/codedFvModel/codedFvModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -144,6 +144,19 @@ Foam::wordList Foam::fv::codedFvModel::codeKeys() const } +Foam::wordList Foam::fv::codedFvModel::codeDictVars() const +{ + return + { + word::null, + word::null, + word::null, + word::null, + word::null + }; +} + + Foam::fvModel& Foam::fv::codedFvModel::redirectFvModel() const { if (!redirectFvModelPtr_.valid()) diff --git a/src/fvModels/general/codedFvModel/codedFvModel.H b/src/fvModels/general/codedFvModel/codedFvModel.H index 5938a1f754..c7d8bb8d5c 100644 --- a/src/fvModels/general/codedFvModel/codedFvModel.H +++ b/src/fvModels/general/codedFvModel/codedFvModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -126,6 +126,9 @@ class codedFvModel //- Get the keywords associated with source code virtual wordList codeKeys() const; + //- Get the name of the dictionary variables in the source code + virtual wordList codeDictVars() const; + //- Dynamically compiled fvModel fvModel& redirectFvModel() const;