@@ -2561,7 +2561,7 @@ protected function createTDSduplicateTasks2"sets the information about the new t
25612561protected
25622562 String crefAppend;
25632563 Integer threadIdx,compIdx,simVarIdx,simVarIdx2,simEqSysIdx,simEqSysIdx2,simEqSysIdx3,numVars,numEqs,numInitEqs,taskIdx,lsIdx,nlsIdx,mIdx;
2564- list< Integer > comps,simVarSysIdcs,simVarSysIdcs2,simEqSysIdcs,simEqSysIdcs2,simEqSysIdcsInit,thread,clTasks,origPredTasks,clPredTasks,duplPredTasks,pos;
2564+ list< Integer > comps,simVarSysIdcs,simVarSysIdcs2,simEqSysIdcs,simEqSysIdcs2,systSimEqSysIdcs2, simEqSysIdcsInit,thread,clTasks,origPredTasks,clPredTasks,duplPredTasks,pos;
25652565 list< list< Integer >> simEqIdxLst,simVarIdxLst;
25662566 array< list< Integer >> inComps;
25672567 BackendVarTransform . VariableReplacements repl;
@@ -2576,7 +2576,7 @@ protected
25762576 list< list< DAE . ComponentRef >> crefLst;
25772577 list< DAE . Exp > crefsDuplExp;
25782578 list< SimCode . SimVar > simVarLst,simVarDupl,algVars;
2579- list< SimCode . SimEqSystem > simEqSysts,simEqSystsDupl,initEqs;
2579+ list< SimCode . SimEqSystem > simEqSysts,simEqSystsDupl,systemSimEqSys,systemSimEqSysDupl, initEqs;
25802580 list< list< SimCode . SimEqSystem >> odes;
25812581algorithm
25822582 HpcOmTaskGraph . TASKGRAPHMETA (inComps= inComps) := iTaskGraphMeta;
@@ -2587,26 +2587,23 @@ algorithm
25872587 // print("node to duplicate "+&intString(node)+&"\n");
25882588 comps := arrayGet(inComps,node);
25892589 comps := listReverse(comps);
2590- // print("comps :"+&intListString(comps)+&"\n");
2591- // print("task :"+&intString(taskIdx)+&"\n");
2590+ print("comps :" +& intListString(comps)+& " \n " );
2591+ print("task :" +& intString(taskIdx)+& " \n " );
25922592 simEqIdxLst := List . map1(comps,Util . arrayGetIndexFirst,sccSimEqMappingIn);
25932593 simEqSysIdcs := List . flatten(simEqIdxLst);
2594- // print("simEqSysIdcs :"+&intListString(simEqSysIdcs)+&"\n");
2595-
2594+ print("simEqSysIdcs :" +& intListString(simEqSysIdcs)+& " \n " );
2595+
25962596 crefLst := List . map1(simEqSysIdcs,SimCodeUtil . getAssignedCrefsOfSimEq,simCodeIn);
25972597 crefs := List . flatten(crefLst);
2598- // print("crefs :\n"+&stringDelimitList(List.map(crefs,ComponentReference.debugPrintComponentRefTypeStr),"\n")+&"\n");
2599-
2598+ print("crefs : \n " +& stringDelimitList(List . map(crefs,ComponentReference . debugPrintComponentRefTypeStr)," \n " )+& " \n " );
26002599 simVarLst := List . map1(crefs,SimCodeUtil . get,ht);
2601- simEqSysts := List . map1(simEqSysIdcs,SimCodeUtil . getSimEqSysForIndex,List . flatten(odes));
26022600
26032601 // build the new crefs, new simVars
26042602 numVars := listLength(simVarLst);
26052603 simVarSysIdcs2 := List . intRange2(simVarIdx,simVarIdx+ numVars- 1 );
26062604 crefAppend := "_thr" +& intString(threadIdx);
2607- // crefsDupl := List.map1(crefs,ComponentReference.joinArrayCrefs,DAE.CREF_IDENT(crefAppend,DAE.T_UNKNOWN_DEFAULT,{}));
26082605 crefsDupl := List . map1r(crefs,ComponentReference . appendStringLastIdent,crefAppend);
2609- // print("crefs new :\n"+&stringDelimitList(List.map(crefsDupl,ComponentReference.debugPrintComponentRefTypeStr),"\n")+&"\n");
2606+ print("crefs new : \n " +& stringDelimitList(List . map(crefsDupl,ComponentReference . debugPrintComponentRefTypeStr)," \n " )+& " \n " );
26102607 crefsDuplExp := List . map(crefsDupl,Expression . crefExp);
26112608 simVarDupl := List . threadMap(crefsDupl,simVarLst,SimCodeUtil . replaceSimVarName);
26122609 simVarDupl := List . threadMap(simVarSysIdcs2,simVarDupl,SimCodeUtil . replaceSimVarIndex);
@@ -2617,14 +2614,20 @@ algorithm
26172614 ht := List . fold(simVarDupl,SimCodeUtil . addSimVarToHashTable,ht);
26182615 repl := BackendVarTransform . addReplacements(replIn,crefs,crefsDuplExp,NONE ());
26192616 // BackendVarTransform.dumpReplacements(repl);
2617+ simEqSysts := List . map1(simEqSysIdcs,SimCodeUtil . getSimEqSysForIndex,List . flatten(odes));
26202618 numEqs := listLength(simEqSysts);
26212619 simEqSysIdcs2 := List . intRange2(simEqSysIdx,simEqSysIdx+ numEqs- 1 );
2622- // print("simEqSysIdcs2 :"+&intListString(simEqSysIdcs2)+&"\n");
2620+ print("simEqSysIdcs2 :" +& intListString(simEqSysIdcs2)+& " \n " );
26232621 (simEqSystsDupl,_) := List . map1_2(simEqSysts,replaceExpsInSimEqSystem,repl);// replace the exps and crefs
26242622 (simEqSystsDupl,(lsIdx,nlsIdx,mIdx)) := List . mapFold(simEqSystsDupl,replaceSystemIndex,(lsIdx,nlsIdx,mIdx));// udpate the indeces of th systems
26252623 simEqSystsDupl := List . threadMap(simEqSystsDupl,simEqSysIdcs2,SimCodeUtil . replaceSimEqSysIndex);
2626- // print("the simEqSystsDupl "+&SimCodeUtil.dumpSimEqSystemLst(simEqSystsDupl)+&"\n");
2624+ print("the simEqSystsDupl " +& SimCodeUtil . dumpSimEqSystemLst(simEqSystsDupl)+& " \n " );
26272625 simEqSysIdx2 := simEqSysIdx + numEqs;
2626+
2627+ // duplicate the equations inside a system of equations
2628+ (simEqSystsDupl,simEqSysIdx2) := TDS_duplicateSystemOfEquations (simEqSystsDupl,simEqSysIdx2,repl,{});
2629+ print("the simEqSystsDupl after EqSys " +& SimCodeUtil . dumpSimEqSystemLst(simEqSystsDupl)+& " \n " );
2630+
26282631 // update sccSimEqmapping for the duplicated
26292632 duplSccSimEqMapOut := listAppend(List . map(simEqSysIdcs2,List . create),duplSccSimEqMapIn);
26302633 simCode := List . fold1(simEqSystsDupl,SimCodeUtil . addSimEqSysToODEquations,1 ,simCode);
@@ -2677,6 +2680,50 @@ algorithm
26772680 replOut := repl;
26782681end createTDSduplicateTasks2;
26792682
2683+ protected function TDS_duplicateSystemOfEquations
2684+ input list< SimCode . SimEqSystem > simEqsIn;
2685+ input Integer simEqSysIdxIn;
2686+ input BackendVarTransform . VariableReplacements repl;
2687+ input list< SimCode . SimEqSystem > simEqsFold;
2688+ output list< SimCode . SimEqSystem > simEqsOut;
2689+ output Integer simEqSysIdxOut;
2690+ algorithm
2691+ (simEqsOut,simEqSysIdxOut) := matchcontinue(simEqsIn,simEqSysIdxIn,repl,simEqsFold)
2692+ local
2693+ Integer simEqSysIdx, index, numEqs;
2694+ Boolean partOfMixed;
2695+ list< Integer > systSimEqSysIdcs2;
2696+ SimCode . SimEqSystem simEqSys;
2697+ list< SimCode . SimEqSystem > rest,duplicated,residual;
2698+ list< SimCode . SimVar > vars;
2699+ list< DAE . Exp > beqs;
2700+ list< tuple< Integer , Integer , SimCode . SimEqSystem >> simJac;
2701+ Option < SimCode . JacobianMatrix > jacobianMatrix;
2702+ list< DAE . ElementSource > sources;
2703+ Integer indexLinearSystem;
2704+ case ({},_,_,_)
2705+ then (listReverse(simEqsFold),simEqSysIdxIn);
2706+ case ((simEqSys as SimCode . SES_LINEAR (index= index,partOfMixed= partOfMixed,vars= vars,beqs= beqs,simJac= simJac,jacobianMatrix= jacobianMatrix, residual= residual,sources= sources,indexLinearSystem= indexLinearSystem))::rest,_,_,_)
2707+ equation
2708+ // print("the systemSimEqSys "+&SimCodeUtil.dumpSimEqSystemLst(residual)+&"\n");
2709+ numEqs = listLength(residual);
2710+ systSimEqSysIdcs2 = Util . if_(intEq(numEqs,0 ),{},List . intRange2(simEqSysIdxIn,simEqSysIdxIn+ numEqs- 1 ));
2711+ // print("systSimEqSysIdcs2 :"+&intListString(systSimEqSysIdcs2)+&"\n");
2712+ (duplicated,_) = List . map1_2(residual,replaceExpsInSimEqSystem,repl);// replace the exps and crefs
2713+ duplicated = List . threadMap(duplicated,systSimEqSysIdcs2,SimCodeUtil . replaceSimEqSysIndex);
2714+ // print("the systemSimEqSysDupl "+&SimCodeUtil.dumpSimEqSystemLst(duplicated)+&"\n");
2715+ simEqSys = SimCode . SES_LINEAR (index,partOfMixed,vars,beqs,simJac,duplicated,jacobianMatrix,sources,indexLinearSystem);
2716+ simEqSysIdx = simEqSysIdxIn + numEqs;
2717+ (duplicated,simEqSysIdx) = TDS_duplicateSystemOfEquations (rest,simEqSysIdx,repl,simEqSys::simEqsFold);
2718+ then (duplicated,simEqSysIdx);
2719+ else
2720+ equation
2721+ simEqSys::rest = simEqsIn;
2722+ (duplicated,simEqSysIdx) = TDS_duplicateSystemOfEquations (rest,simEqSysIdxIn,repl,simEqSys::simEqsFold);
2723+ then (duplicated,simEqSysIdx);
2724+ end matchcontinue;
2725+ end TDS_duplicateSystemOfEquations ;
2726+
26802727protected function makeSEScrefAssignment
26812728 input DAE . ComponentRef lhs;
26822729 input DAE . ComponentRef rhs;
0 commit comments