Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[DAEMode] create aux variable for cse variables
Browse files Browse the repository at this point in the history
 - this attempts to fix initialization issue in DAEmode

Belonging to [master]:
  - #2460
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed May 23, 2018
1 parent 729fcc0 commit 2716d05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -48,6 +48,7 @@ import BackendDump;
import BaseHashSet;
import BaseHashTable;
import ComponentReference;
import CommonSubExpression;
import DAEUtil;
import Debug;
import ElementSource;
Expand Down Expand Up @@ -1247,6 +1248,17 @@ algorithm
end match;
end isAlgebraicOldState;

public function isCSEVar
"Return true if variable is introduced by wrapFunctionCall and prefixed with '$cse'"
input BackendDAE.Var inVar;
output Boolean outBoolean;
algorithm
outBoolean := match (inVar)
case (BackendDAE.VAR()) guard CommonSubExpression.isCSECref(inVar.varName) then true;
else false;
end match;
end isCSEVar;

public function hasMayerTermAnno
"author: Vitalij Ruge
Return true if variable has isMayer=true annotation"
Expand Down
4 changes: 3 additions & 1 deletion Compiler/BackEnd/DAEMode.mo
Expand Up @@ -298,7 +298,7 @@ algorithm
constant Boolean debug = false;

case ({eq}, false, false)
guard(Util.boolAndList(list(CommonSubExpression.isCSECref(v.varName) for v in vars)))
guard(Util.boolAndList(list(BackendVariable.isCSEVar(v) for v in vars)))
equation
newResVars = list(BackendVariable.setVarKind(v, BackendDAE.DAE_AUX_VAR()) for v in vars);
new_eq = BackendEquation.setEquationAttributes(eq, BackendDAE.EQ_ATTR_DEFAULT_AUX);
Expand Down Expand Up @@ -492,6 +492,8 @@ algorithm
algorithm

(discVars, contVars) := List.splitOnTrue(inVars, BackendVariable.isVarDiscrete);
(newAuxVars, contVars) := List.splitOnTrue(contVars, BackendVariable.BackendVariable.isCSEVar);
discVars := listAppend(newAuxVars,discVars);
(discEqns, contEqns) := getDiscAndContEqns(inVars, inEqns, discVars, contVars, traverserArgs.shared.functionTree);

// create discrete
Expand Down

0 comments on commit 2716d05

Please sign in to comment.