Block decomposition: bugfix with temporary terms when mfs=3

In an “evaluate” block, the LHS of a renormalized equation (such as “log(x)=…”)
could be associated to a temporary term that would then be incorrectly
computed: that temporary term would be evaluated *before* (and not after) the
evaluation of the associated variable (“x” in the example).
master
Sébastien Villemot 2022-10-26 17:33:26 +02:00
parent e153353365
commit 627dd92c64
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 10 additions and 1 deletions

View File

@ -988,7 +988,16 @@ ModelTree::computeBlockTemporaryTerms()
blocks_temporary_terms[blk].resize(blocks[blk].size + 1);
for (int eq = 0; eq < blocks[blk].size; eq++)
{
if (eq < blocks[blk].getRecursiveSize() && isBlockEquationRenormalized(blk, eq))
/* It is important to compute temporary terms of the renormalized
equation if the latter is going to be used in the output files.
Otherwise, for an equation of the form log(x) = RHS, a temporary
term could be associated to log(x), and since it would be
associated to this equation, it would be printed and thus computed
*before* x is actually evaluated, and thus would be incorrect. */
if ((blocks[blk].simulation_type == BlockSimulationType::evaluateBackward
|| blocks[blk].simulation_type == BlockSimulationType::evaluateForward
|| eq < blocks[blk].getRecursiveSize())
&& isBlockEquationRenormalized(blk, eq))
getBlockEquationRenormalizedExpr(blk, eq)->computeBlockTemporaryTerms(blk, eq, blocks_temporary_terms, reference_count);
else
getBlockEquationExpr(blk, eq)->computeBlockTemporaryTerms(blk, eq, blocks_temporary_terms, reference_count);