mixedExpr boundary condition not working
Summary
Using the exprMixed boundary condition in OpenFOAM-v2212 causes the solver to throw up the following error:
--> FOAM FATAL IO ERROR: (openfoam-2212)
Entries 'valueExpr' and 'gradientExpr' (mixed-conditon) not found in dictionary "D:/SmallProjects/999_Temp/001_OpenFOAM_Tests /002_exprMixed_Bug_001/0/U.boundaryField.(plateOut_01)"
file: 0/U.boundaryField.(plateOut_01) at line 48 to 58.
From void Foam::expressions::patchExprFieldBase::readExpressions(const Foam::dictionary&, Foam::expressions::patchExprFieldBase::expectedTypes, bool)
in file expressions/fields/base/patchExprFieldBase.C at line 91.
FOAM exiting
The same case works as expected without any errors when run using OpenFOAM-v2206.
Steps to reproduce
This issue can be reproduced every time, when using the exprMixed boundary condition in any of the boundary field files, for example:
"(plateOut_01)"
{
type exprMixed;
value $internalField;
variables
(
"qOut{plateIn_01} = -sum(phi)"
"qIn = sum(phi)"
);
valueExpr "(qIn + 0.1*(qOut - qIn))/sum(area())*face()/area()";
fractionExpr "(phi > 0) ? 0 : 1";
}
Example case
An example case hat been attached along with this bug report which reproduces the problem when run using OpenFOAM-v2212, but runs fine when using OpenFOAM-v2206
What is the current bug behaviour?
The OpenFOAM solver exits with as error while setting up the boundary fields right in the beginning of the solve, before the first iteration has been run.
What is the expected correct behavior?
If the bug is fixed, the expectation is that the solver goes through the initial boundary field setup and starts the solve iterations, as seen when the case is run using OpenFOAM-v2206.
Relevant logs and/or images
See inserted text in the summary section and example case uploaded along with this issue report.
Environment information
- OpenFOAM version : v2212
- Operating system : Windows 11 (OpenFOAM native cross-compile)
- Hardware info : -na-
- Compiler : minGW Cross-compile (OpenSUSE)
Possible fixes
There has been a change in the file:
At the line pointed to by the link, between OpenFOAM-v2206 and OpenFOAM-v2212, which makes both the valueExpr and gradientExpr mandatory for the exprMixed boundary condition. In OpenFOAM-v2206, this error was only thrown when both, valueExpr and gradientExpr were missing from the definition, but worked if either one of the keywords were present (and when relevant, along with fractionExpr).
The problem can be solved by using an empty string for the gradientExpr in the patch boundary definition.
Is this an intended change? Using an empty string for an entry which is not required, is not an elegant solution.