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

Commit 22f0d9b

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Support linear systems in clocked partitions
1 parent 15bcdab commit 22f0d9b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,9 +3825,9 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
38253825

38263826
<%algloopRHSCode(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq)%>
38273827
<%if Flags.isSet(Flags.WRITE_TO_BUFFER) then algloopResiduals(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq)%>
3828-
<%initAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, stateDerVectorName, useFlatArrayNotation)%>
3828+
<%initAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38293829
<%queryDensity(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq,context, useFlatArrayNotation)%>
3830-
<%updateAlgloop(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq,context, stateDerVectorName, useFlatArrayNotation)%>
3830+
<%updateAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38313831
<%updateAlgloopNonLinear(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38323832

38333833
<%LinearalgloopDefaultImplementationCode(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, stateDerVectorName, useFlatArrayNotation)%>
@@ -3872,10 +3872,10 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
38723872
}
38733873
<%algloopRHSCode(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq)%>
38743874
<%if Flags.isSet(Flags.WRITE_TO_BUFFER) then algloopResiduals(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq)%>
3875-
<%initAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, stateDerVectorName, useFlatArrayNotation)%>
3875+
<%initAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38763876

38773877
<%queryDensity(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq,context, useFlatArrayNotation)%>
3878-
<%updateAlgloop(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,eq,context, stateDerVectorName, useFlatArrayNotation)%>
3878+
<%updateAlgloop(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38793879
<%updateAlgloopNonLinear(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, eq, context, clockIndex, stateDerVectorName, useFlatArrayNotation)%>
38803880

38813881
<%NonLinearalgloopDefaultImplementationCode(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, eq, context, stateDerVectorName, useFlatArrayNotation)%>
@@ -3918,7 +3918,7 @@ match simCode
39183918
end queryDensity;
39193919

39203920

3921-
template updateAlgloop(SimCode simCode ,Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace,SimEqSystem eqn,Context context, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
3921+
template updateAlgloop(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, SimEqSystem eqn, Context context, Integer clockIndex, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
39223922
::=
39233923
match simCode
39243924
case SIMCODE(modelInfo = MODELINFO(__)) then
@@ -3954,6 +3954,7 @@ match simCode
39543954

39553955
void <%modelname%>Algloop<%ls.index%>::evaluate()
39563956
{
3957+
<%if intGt(clockIndex, 0) then 'const int clockIndex = <%clockIndex%>;'%>
39573958
<%varDecls%>
39583959
//prebody
39593960
<%prebody%>
@@ -5938,7 +5939,7 @@ template functionInitialEquations(list<SimEqSystem> initalEquations, Text method
59385939
>>
59395940
end functionInitialEquations;
59405941

5941-
template initAlgloop(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, SimEqSystem eq, Context context, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
5942+
template initAlgloop(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, SimEqSystem eq, Context context, Integer clockIndex, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
59425943
::=
59435944
match simCode
59445945
case SIMCODE(modelInfo = MODELINFO(__)) then
@@ -5951,6 +5952,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
59515952
<<
59525953
void <%modelname%>Algloop<%nls.index%>::initialize()
59535954
{
5955+
<%if intGt(clockIndex, 0) then 'const int clockIndex = <%clockIndex%>;'%>
59545956
<%initAlgloopEquation(eq,simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, stateDerVectorName, useFlatArrayNotation)%>
59555957
// Don't update the equations once before start of simulation
59565958
// evaluate();
@@ -5963,6 +5965,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
59635965
<<
59645966
void <%modelname%>Algloop<%ls.index%>::initialize()
59655967
{
5968+
<%if intGt(clockIndex, 0) then 'const int clockIndex = <%clockIndex%>;'%>
59665969
<%initAlgloopEquation(eq,simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, stateDerVectorName, useFlatArrayNotation)%>
59675970
}
59685971
>>
@@ -5990,7 +5993,8 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
59905993

59915994
void <%modelname%>Algloop<%ls.index%>::initialize()
59925995
{
5993-
<%initAlgloopEquation(eq, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, stateDerVectorName, useFlatArrayNotation)%>
5996+
<%if intGt(clockIndex, 0) then 'const int clockIndex = <%clockIndex%>;'%>
5997+
<%initAlgloopEquation(eq, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, stateDerVectorName, useFlatArrayNotation)%>
59945998
}
59955999
>>
59966000
end initAlgloop;

0 commit comments

Comments
 (0)