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

Commit baa1a25

Browse files
vrugeOpenModelica-Hudson
authored andcommitted
improved inStream
define `0/0` for inStream-equation as first `stream_exp` refs ticket:4869 Belonging to [master]: - #2346 - OpenModelica/OpenModelica-testsuite#917
1 parent 7dd0320 commit baa1a25

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Compiler/BackEnd/BackendDAEOptimize.mo

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ algorithm
152152
local
153153
DAE.Type tp;
154154
DAE.ComponentRef cr;
155-
DAE.Exp e, expr;
155+
DAE.Exp e, expr, a, b;
156156
Option<DAE.Exp> eMin, eMax;
157157
Boolean isZero;
158158

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

180+
case DAE.CALL(path=Absyn.IDENT("$OMC$inStreamDiv"),expLst={e, expr})
181+
algorithm
182+
e := ExpressionSimplify.simplify(e);
183+
expr := match(e)
184+
case DAE.BINARY(a, DAE.DIV(), b)
185+
guard Expression.isZero(a) and Expression.isZero(b)
186+
then
187+
expr;
188+
else
189+
e;
190+
end match;
191+
then
192+
expr;
193+
180194
else inExp;
181195
end match;
182196
end simplifyInStreamWork2;

Compiler/FrontEnd/ConnectUtil.mo

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2487,7 +2487,7 @@ algorithm
24872487
local
24882488
DAE.ComponentRef c;
24892489
Face f1, f2;
2490-
DAE.Exp e;
2490+
DAE.Exp e, expr;
24912491
list<ConnectorElement> inside, outside;
24922492

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

0 commit comments

Comments
 (0)