Skip to content

Commit

Permalink
Fix clock partitioning in encapsulateWhenConditions
Browse files Browse the repository at this point in the history
Re-partition only continuous systems if necessary.
  • Loading branch information
gossen authored and OpenModelica-Hudson committed Aug 31, 2015
1 parent 60202fe commit 43e12c9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -72,17 +72,15 @@ public function encapsulateWhenConditions "author: lochel"
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
protected
BackendDAE.EqSystems systs, systs2;
BackendDAE.Shared shared, shared2;
BackendDAE.EventInfo eventInfo;
BackendDAE.EqSystems systs;
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
Integer index;
HashTableExpToIndex.HashTable ht "is used to avoid redundant condition-variables";
list<BackendDAE.Var> vars;
list<BackendDAE.Equation> eqns;
BackendDAE.Variables vars_;
BackendDAE.EquationArray eqns_, removedEqs;
BackendDAE.BackendDAE bdae;

algorithm
BackendDAE.DAE(systs, shared) := inDAE;

Expand All @@ -93,17 +91,15 @@ algorithm
((removedEqs, vars, eqns, index, ht)) :=
BackendEquation.traverseEquationArray(shared.removedEqs, encapsulateWhenConditions_Equation,
(BackendEquation.emptyEqns(), {}, {}, index, ht) );

shared.removedEqs := BackendEquation.emptyEqns();
shared.removedEqs := removedEqs;
eqns_ := BackendEquation.listEquation(eqns);
vars_ := BackendVariable.listVar(vars);
systs := listAppend(systs, {BackendDAEUtil.createEqSystem(vars_, eqns_, {}, BackendDAE.UNKNOWN_PARTITION(), removedEqs)});
syst := BackendDAEUtil.createEqSystem(vars_, eqns_, {}, BackendDAE.UNSPECIFIED_PARTITION(), BackendEquation.emptyEqns());
systs := listAppend(systs, {syst});

if intGt(index, 1) then
outDAE := BackendDAE.DAE(systs, shared);
outDAE := SynchronousFeatures.clockPartitioning(outDAE);
else
outDAE := inDAE;
outDAE := BackendDAE.DAE(systs, shared);
if index > 1 then
outDAE := SynchronousFeatures.contPartitioning(outDAE);
end if;

if Flags.isSet(Flags.DUMP_ENCAPSULATECONDITIONS) then
Expand Down
22 changes: 22 additions & 0 deletions Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -85,6 +85,28 @@ algorithm
end match;
end clockPartitioning;

public function contPartitioning
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
protected
BackendDAE.EqSystems systs, clockedSysts, clockedSysts1;
BackendDAE.Shared shared;
BackendDAE.EqSystem syst;
list<BackendDAE.Equation> unpartRemEqs;
algorithm
(clockedSysts, systs) := List.splitOnTrue(inDAE.eqs, BackendDAEUtil.isClockedSyst);
shared := inDAE.shared;

if listLength(systs) > 0 then
BackendDAE.DAE({syst}, shared) := BackendDAEOptimize.collapseIndependentBlocks(BackendDAE.DAE(systs, shared));
(systs, clockedSysts1, unpartRemEqs) := baseClockPartitioning(syst, shared);
assert(listLength(clockedSysts1) == 0, "Get clocked system in SynchronousFeatures.addContVarsEqs");
shared.removedEqs := BackendEquation.addEquations(unpartRemEqs, shared.removedEqs);
end if;

outDAE := BackendDAE.DAE(listAppend(systs, clockedSysts), shared);
end contPartitioning;

protected function clockPartitioning1
input BackendDAE.EqSystem inSyst;
input BackendDAE.Shared inShared;
Expand Down

0 comments on commit 43e12c9

Please sign in to comment.