Skip to content

Commit

Permalink
improved inStream
Browse files Browse the repository at this point in the history
define `0/0` for inStream-equation as first `stream_exp`

refs ticket:4869

Belonging to [master]:
  - OpenModelica/OMCompiler#2346
  - OpenModelica/OpenModelica-testsuite#917
  • Loading branch information
vruge authored and OpenModelica-Hudson committed Apr 6, 2018
1 parent 7dd0320 commit baa1a25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -152,7 +152,7 @@ algorithm
local
DAE.Type tp;
DAE.ComponentRef cr;
DAE.Exp e, expr;
DAE.Exp e, expr, a, b;
Option<DAE.Exp> eMin, eMax;
Boolean isZero;

Expand All @@ -177,6 +177,20 @@ algorithm
//print(ExpressionDump.printExpStr(e));
then Expression.makePureBuiltinCall("max", {e, expr}, Expression.typeof(e));

case DAE.CALL(path=Absyn.IDENT("$OMC$inStreamDiv"),expLst={e, expr})
algorithm
e := ExpressionSimplify.simplify(e);
expr := match(e)
case DAE.BINARY(a, DAE.DIV(), b)
guard Expression.isZero(a) and Expression.isZero(b)
then
expr;
else
e;
end match;
then
expr;

else inExp;
end match;
end simplifyInStreamWork2;
Expand Down
6 changes: 5 additions & 1 deletion Compiler/FrontEnd/ConnectUtil.mo
Expand Up @@ -2487,7 +2487,7 @@ algorithm
local
DAE.ComponentRef c;
Face f1, f2;
DAE.Exp e;
DAE.Exp e, expr;
list<ConnectorElement> inside, outside;

// Unconnected stream connector:
Expand Down Expand Up @@ -2524,6 +2524,10 @@ algorithm
(outside, inside) := List.splitOnTrue(reducedStreams, isOutsideElement);
inside := removeStreamSetElement(streamCref, inside);
e := streamSumEquationExp(outside, inside, flowThreshold);
if not listEmpty(inside) then
expr := streamFlowExp(List.first(inside));
e := Expression.makePureBuiltinCall("$OMC$inStreamDiv", {e, expr}, Expression.typeof(e));
end if;
// Evaluate any inStream calls that were generated.
e := evaluateConnectionOperators2(e, sets, setArray, false, flowThreshold);
then
Expand Down

0 comments on commit baa1a25

Please sign in to comment.