Parser: better #codeStream
We have an issue with such OpenFOAM input code:
FoamFile
{
version 2.0;
}
internalField #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};
codeLibs
#{
-lfiniteVolume \
-lmeshTools
#};
code
#{
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField alpha_a(mesh.nCells(), 0);
forAll(mesh.C(), i)
{
scalar y = mesh.C()[i].y();
alpha_a[i] = 0.305*(1.0+tanh((12.5*0.006-y)/0.005));
/*if (y < 12.5*0.006)
{
alpha_a[i] = 0.61;
}
else
{
alpha_a[i] = 0;
}*/
}
alpha_a.writeEntry("", os);
#};
};
We should be able to get/set the code with:
print(tree.children["internalField"]["code"])
tree.children["internalField"]["code"] = "..."
Or even maybe (because we would have a CodeStream
node, which would just be a special Dict
):
print(tree.children["internalField"].code)
tree.children["internalField"].code = "..."
Note that I guess it should be very easy to add few lines to tests/test_parser.py::test_code_stream
to make it fail by testing this behavior.