Skip to content

Commit

Permalink
- make +d=graphvizDump working with +d=dumpindxdae
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18418 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Dec 5, 2013
1 parent 4b6a5a2 commit bc31e4e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -7960,6 +7960,7 @@ algorithm

Debug.execStat("expandAlgorithmsbyInitStmts", GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
Debug.fcall2(Flags.DUMP_INDX_DAE, BackendDump.dumpBackendDAE, outSODE, "dumpindxdae");
Debug.bcall2(Flags.isSet(Flags.DUMP_INDX_DAE) and Flags.isSet(Flags.ADDITIONAL_GRAPHVIZ_DUMP), BackendDump.graphvizBackendDAE, outSODE, "dumpindxdae");
Debug.fcall(Flags.DUMP_BACKENDDAE_INFO, BackendDump.dumpCompShort, outSODE);
Debug.fcall2(Flags.DUMP_EQNINORDER, BackendDump.dumpEqnsSolved, outSODE, "indxdae: eqns in order");

Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Initialization.mo
Expand Up @@ -188,7 +188,7 @@ algorithm
// simplify system
(initdae, Util.SUCCESS()) = BackendDAEUtil.postOptimizeDAE(initdae, pastOptModules, matchingAlgorithm, daeHandler);
Debug.fcall2(Flags.DUMP_INITIAL_SYSTEM, BackendDump.dumpBackendDAE, initdae, "solved initial system");
Debug.bcall2(Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) and Flags.isSet(Flags.ADDITIONAL_GRAPHVIZ_DUMP), BackendDump.graphvizBackendDAE, initdae, "initialization");
Debug.bcall2(Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) and Flags.isSet(Flags.ADDITIONAL_GRAPHVIZ_DUMP), BackendDump.graphvizBackendDAE, initdae, "dumpinitialsystem");

// warn about selected default initial conditions
b = List.isNotEmpty(dumpVars);
Expand Down
24 changes: 17 additions & 7 deletions Compiler/Template/GraphvizDump.tpl
Expand Up @@ -23,7 +23,10 @@ template dumpDependence(BackendDAE.BackendDAE backendDAE, String suffix)
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 =>
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 =>
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]'
if isStateVar(var) then
'var<%clusterID%>_<%varID%> [label="der(<%crefStr(var.varName)%>)", shape="box"]'
else
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>", shape="box"]'
;separator="\n")
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 =>
'eq<%clusterID%>_<%eqID%> [label="<%BackendDump.equationString(eq)%>", shape="box"]'
Expand Down Expand Up @@ -58,7 +61,8 @@ template dumpDependence2(Integer clusterID, Option<BackendDAE.IncidenceMatrix> m
case SOME(incMatrix) then
let incNodes = (arrayList(incMatrix) |> varList hasindex eqID fromindex 1 =>
let foo = (varList |> varID =>
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
if intGt(varID, 0) then
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
;separator="\n")
'<%foo%>'
;separator="\n")
Expand All @@ -73,7 +77,10 @@ template dumpMatching(BackendDAE.BackendDAE backendDAE, String suffix)
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 =>
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 =>
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]'
if isStateVar(var) then
'var<%clusterID%>_<%varID%> [label="der(<%crefStr(var.varName)%>)", shape="box"]'
else
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>", shape="box"]'
;separator="\n")
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 =>
<<
Expand Down Expand Up @@ -115,15 +122,17 @@ template connections(Integer clusterID, BackendDAE.Matching matching, Option<Bac
if intEq(listGet(arrayList(ass2), eqID), varID) then
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="bold", arrowhead="none"];'
else
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
if intGt(varID, 0) then
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
;separator="\n")
'<%foo%>'
;separator="\n")
'<%incNodes%>'
else
let incNodes = (arrayList(incMatrix) |> varList hasindex eqID fromindex 1 =>
let foo = (varList |> varID =>
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
if intGt(varID, 0) then
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];'
;separator="\n")
'<%foo%>'
;separator="\n")
Expand All @@ -135,7 +144,8 @@ template connections(Integer clusterID, BackendDAE.Matching matching, Option<Bac
match matching
case matching as BackendDAE.MATCHING(ass2=ass2) then
let matchedNodes = (arrayList(ass2) |> varID hasindex eqID fromindex 1 =>
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="bold", arrowhead="none"];'
if intGt(varID, 0) then
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="bold", arrowhead="none"];'
;separator="\n")
<<
// no incidence matrix
Expand All @@ -154,7 +164,7 @@ template dumpSorting(BackendDAE.BackendDAE backendDAE, String suffix)
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 =>
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 =>
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]'
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>", shape="box"]'
;separator="\n")
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 =>
'eq<%clusterID%>_<%eqID%> [label="<%BackendDump.equationString(eq)%>", shape="box"]'
Expand Down
6 changes: 6 additions & 0 deletions Compiler/Template/GraphvizDumpTV.mo
@@ -1,6 +1,12 @@
interface package GraphvizDumpTV

package builtin
function intGt
input Integer a;
input Integer b;
output Boolean c;
end intGt;

function arrayList
replaceable type TypeVar subtypeof Any;
input array<TypeVar> arr;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util/Flags.mo
Expand Up @@ -368,7 +368,7 @@ constant DebugFlag PARTLINTORNSYSTEM = DEBUG_FLAG(100, "partlintornsystem", fals
constant DebugFlag DUMP_DISCRETEVARS_INFO = DEBUG_FLAG(101, "discreteinfo", false,
Util.gettext("Enables dumping of discrete variables. Works only in combination with backenddaeinfo."));
constant DebugFlag ADDITIONAL_GRAPHVIZ_DUMP = DEBUG_FLAG(102, "graphvizDump", false,
Util.gettext("activates additional graphviz dumps (as *.dot files). It can be used in addition to one of the following flags: {dumpinitialsystems}."));
Util.gettext("activates additional graphviz dumps (as *.dot files). It can be used in addition to one of the following flags: {dumpinitialsystems|dumpindxdae}."));
constant DebugFlag INFO_XML_OPERATIONS = DEBUG_FLAG(103, "infoXmlOperations", false,
Util.gettext("Enables output of the operations in the _info.xml file when translating models."));
constant DebugFlag HPCOM_DUMP = DEBUG_FLAG(104, "hpcomDump", false,
Expand Down

0 comments on commit bc31e4e

Please sign in to comment.