diff --git a/applications/test/codeStream/codeStreamDict1 b/applications/test/codeStream/codeStreamDict1 index 54fb3d0efe..ec94ddb173 100644 --- a/applications/test/codeStream/codeStreamDict1 +++ b/applications/test/codeStream/codeStreamDict1 @@ -14,10 +14,15 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// #include "codeStreamDefaults" +// values from outer-scope +begIter 0; +endIter 200; writeInterval #codeStream { + // values from inner-scope + nDumps 5; + codeInclude #{ #include "fvCFD.H" @@ -30,14 +35,15 @@ writeInterval #codeStream code #{ - scalar start = 0; - scalar end = 100; - label nDumps = 5; - label interval = end - start; - Info<<"on-the-fly: " << ((interval)/nDumps) << endl; - os << ((interval)/nDumps); + label interval = ($endIter - $begIter); + label nDumps = $nDumps; + os << (interval / nDumps); #}; }; +// play with cleanup +#remove begIter + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 1accc97517..21ffba1f91 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -83,17 +83,21 @@ bool Foam::functionEntries::codeStream::execute << exit(FatalIOError); } + // get code dictionary + // must reference parent for stringOps::expandDict to work nicely + dictionary codeDict("#codeStream", parentDict, is); + // Read three sections of code. // Remove any leading whitespace - necessary for compilation options, // convenience for includes and body. - dictionary codeDict(is); // "codeInclude" is optional string codeInclude; if (codeDict.found("codeInclude")) { codeInclude = stringOps::trim(codeDict["codeInclude"]); + stringOps::inplaceExpandDict(codeInclude, codeDict); } // "codeOptions" is optional @@ -101,10 +105,13 @@ bool Foam::functionEntries::codeStream::execute if (codeDict.found("codeOptions")) { codeOptions = stringOps::trim(codeDict["codeOptions"]); + stringOps::inplaceExpandDict(codeOptions, codeDict); } // "code" is mandatory string code = stringOps::trim(codeDict["code"]); + stringOps::inplaceExpandDict(code, codeDict); + // Create SHA1 digest from the contents SHA1Digest sha; diff --git a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C index fc1c6f0ffb..aee9c859d8 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C +++ b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C @@ -159,12 +159,11 @@ void Foam::codeStreamTools::copyAndExpand { is.getLine(line); - // normal expansion according to mapping + // expand according to mapping + // expanding according to env variables might cause too many + // surprises stringOps::inplaceExpand(line, mapping); - // expand according to env variables - stringOps::inplaceExpandEnv(line, true, true); - os << line.c_str() << nl; } while (is.good()); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C index b87a560ac0..05c778ad5b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C @@ -96,6 +96,7 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary if (dict.found("codeInclude")) { codeInclude = stringOps::trim(dict["codeInclude"]); + stringOps::inplaceExpandDict(codeInclude, dict); } // "codeOptions" is optional @@ -103,10 +104,13 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary if (dict.found("codeOptions")) { codeOptions = stringOps::trim(dict["codeOptions"]); + stringOps::inplaceExpandDict(codeOptions, dict); } // "code" is mandatory string code = stringOps::trim(dict["code"]); + stringOps::inplaceExpandDict(code, dict); + // Create SHA1 digest from the contents SHA1Digest sha;