Skip to content

Commit

Permalink
Fixed bug with arrays in flow variables in connectors.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2352 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed May 4, 2006
1 parent f6bc546 commit 18266c6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
35 changes: 35 additions & 0 deletions Compiler/Connect.mo
Expand Up @@ -149,6 +149,41 @@ algorithm
ss_1 := merge(ss, s1, s2);
end addFlow;

public function addArrayFlow "function: addArrayFlow
For connecting two arrays, a flow equation for each index should be generated, see addFlow.
"
input Sets ss;
input Exp.ComponentRef r1;
input Face d1;
input Exp.ComponentRef r2;
input Face d2;
input Integer dsize;
output Sets ss_1;
Set s1,s2;
Sets ss_1;
algorithm
outSets:=
matchcontinue (ss,r1,d1,r2,d2,dsize)
local
Sets s,ss_1,ss_2,ss;
Exp.ComponentRef r1_1,r2_1,r1,r2;
Integer i_1,i;
Set s1,s2;
case (s,_,_,_,_,0) then s;
case (ss,r1,d1,r2,d2,i)
equation
r1_1 = Exp.subscriptCref(r1, {Exp.INDEX(Exp.ICONST(i))});
r2_1 = Exp.subscriptCref(r2, {Exp.INDEX(Exp.ICONST(i))});
i_1 = i - 1;
s1 = findFlowSet(ss, r1_1,d1);
s2 = findFlowSet(ss, r2_1,d2);
ss_1 = merge(ss, s1, s2);
ss_2 = addArrayFlow(ss_1, r1,d1, r2,d2, i_1);
then
ss_2;
end matchcontinue;
end addArrayFlow;

public function addArrayEqu "function: addArrayEqu
For connecting two arrays, an equal equation for each index should
Expand Down
10 changes: 7 additions & 3 deletions Compiler/Inst.mo
Expand Up @@ -7161,20 +7161,24 @@ algorithm
list<Types.Var> l1,l2;
Boolean flow_;
String c1_str,t1_str;
case (sets,env,pre,c1,f1,(Types.T_REAL(varLstReal = _),_),c2,f2,(Types.T_REAL(varLstReal = _),_),true) /* flow Flow type, must be a subtype of Real */

/* flow - with a subtype of Real */
case (sets,env,pre,c1,f1,(Types.T_REAL(varLstReal = _),_),c2,f2,(Types.T_REAL(varLstReal = _),_),true)
equation
c1_1 = Prefix.prefixCref(pre, c1);
c2_1 = Prefix.prefixCref(pre, c2);
sets_1 = Connect.addFlow(sets, c1_1, f1, c2_1, f2);
then
(sets_1,{});
case (sets,env,pre,c1,f1,(Types.T_ARRAY(arrayType = t1),_),c2,f2,(Types.T_ARRAY(arrayType = t2),_),true)

/* flow - with arrays */
case (sets,env,pre,c1,f1,(Types.T_ARRAY(arrayDim = Types.DIM(integerOption = SOME(dim1)),arrayType = t1),_),c2,f2,(Types.T_ARRAY(arrayType = t2),_),true)
equation
((Types.T_REAL(_),_)) = Types.arrayElementType(t1);
((Types.T_REAL(_),_)) = Types.arrayElementType(t2);
c1_1 = Prefix.prefixCref(pre, c1);
c2_1 = Prefix.prefixCref(pre, c2);
sets_1 = Connect.addEqu(sets, c1_1, c2_1);
sets_1 = Connect.addArrayFlow(sets, c1_1,f1, c2_1,f2,dim1);
then
(sets_1,{});
case (sets,env,pre,c1,f1,(_,_),c2,f2,(_,_),false) /* Non-flow type Parameters and constants generate assert statements */
Expand Down

0 comments on commit 18266c6

Please sign in to comment.