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

Commit c51b595

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
[Backend] improve residual creation for complex equations
Belonging to [master]: - #2152
1 parent ddd8677 commit c51b595

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Compiler/BackEnd/BackendEquation.mo

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,11 +1330,12 @@ algorithm
13301330
BackendDAE.Equation backendEq;
13311331
list<Integer> ds;
13321332
Integer size;
1333-
list<DAE.Exp> explst;
1333+
list<DAE.Exp> explst, explst2;
13341334
list<BackendDAE.Equation> eqns;
13351335
list<list<DAE.Subscript>> subslst;
13361336
Real r;
13371337
BackendDAE.EquationAttributes attr;
1338+
list<DAE.ComponentRef> crlst;
13381339

13391340
case (BackendDAE.EQUATION(exp=DAE.TUPLE(explst), scalar=e2, source=source, attr=attr)) equation
13401341
((_, eqns)) = List.fold3(explst,equationTupleToScalarResidualForm, e2, source, attr, (1, {}));
@@ -1370,6 +1371,28 @@ algorithm
13701371
eqns = List.map2(explst, generateRESIDUAL_EQUATION, source, attr);
13711372
then eqns;
13721373

1374+
case (BackendDAE.COMPLEX_EQUATION(left=DAE.CALL(expLst=explst,
1375+
attr=DAE.CALL_ATTR(DAE.T_COMPLEX(complexClassType=ClassInf.RECORD()))),
1376+
right=e2, source=source, attr=attr))
1377+
guard(Expression.isCref(e2))
1378+
equation
1379+
crlst = ComponentReference.expandCref(Expression.expCref(e2),true);
1380+
explst2 = list(Expression.crefExp(c) for c in crlst);
1381+
explst = List.threadMap(explst, explst2, Expression.createResidualExp);
1382+
eqns = List.map2(explst, generateRESIDUAL_EQUATION, source, attr);
1383+
then eqns;
1384+
1385+
case (BackendDAE.COMPLEX_EQUATION(right=DAE.CALL(expLst=explst,
1386+
attr=DAE.CALL_ATTR(DAE.T_COMPLEX(complexClassType=ClassInf.RECORD()))),
1387+
left=e2, source=source, attr=attr))
1388+
guard(Expression.isCref(e2))
1389+
equation
1390+
crlst = ComponentReference.expandCref(Expression.expCref(e2),true);
1391+
explst2 = list(Expression.crefExp(c) for c in crlst);
1392+
explst = List.threadMap(explst, explst2, Expression.createResidualExp);
1393+
eqns = List.map2(explst, generateRESIDUAL_EQUATION, source, attr);
1394+
then eqns;
1395+
13731396
case (BackendDAE.COMPLEX_EQUATION(left=e1, right=e2, source=source, attr=attr)) equation
13741397
exp = Expression.createResidualExp(e1, e2);
13751398
(e, _) = ExpressionSimplify.simplify(exp);

0 commit comments

Comments
 (0)