Skip to content

Commit

Permalink
ticket:4237 fix partition index in jacobians
Browse files Browse the repository at this point in the history
- change default partition index of Jacobians => 0
- fixed a small cpp codegen issue
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Jan 31, 2017
1 parent 4ffbdb4 commit 0014f95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Compiler/SimCode/SimCode.mo
Expand Up @@ -90,7 +90,7 @@ uniontype JacobianMatrix
end JAC_MATRIX;
end JacobianMatrix;

constant JacobianMatrix emptyJacobian = JAC_MATRIX({}, {}, "", {}, {}, {}, 0, -1, -1);
constant JacobianMatrix emptyJacobian = JAC_MATRIX({}, {}, "", {}, {}, {}, 0, -1, 0);

constant PartitionData emptyPartitionData = PARTITIONDATA(-1,{},{},{});

Expand Down
16 changes: 8 additions & 8 deletions Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -1149,11 +1149,11 @@ protected
String name;
SimCode.SparsityPattern sparsity,sparsityT;
list<list<Integer>> colors;
Integer maxcolor, index;
Integer maxcolor, index, partIdx;
algorithm
SimCode.JAC_MATRIX(columns, vars, name, sparsity, sparsityT, colors, maxcolor, index) := inSymjac;
SimCode.JAC_MATRIX(columns, vars, name, sparsity, sparsityT, colors, maxcolor, index, partIdx) := inSymjac;
(columns, outLinearSysIndex, outNonLinSysIndex, outMixedSysIndex, outJacobianIndex, outSymJacs) := countandIndexAlgebraicLoopsSymJacColumn(columns, inLinearSysIndex, inNonLinSysIndex, inMixedSysIndex, inJacobianIndex, {});
outSymjac := SimCode.JAC_MATRIX(columns, vars, name, sparsity, sparsityT, colors, maxcolor, outJacobianIndex, -1);
outSymjac := SimCode.JAC_MATRIX(columns, vars, name, sparsity, sparsityT, colors, maxcolor, outJacobianIndex, partIdx);
outJacobianIndex := outJacobianIndex + 1;
end countandIndexAlgebraicLoopsSymJac;

Expand Down Expand Up @@ -4219,7 +4219,7 @@ algorithm
print("created sparse pattern for algebraic loop time: " + realString(clock()) + "\n");
end if;

then (SOME(SimCode.JAC_MATRIX({}, {}, "", sparseInts, sparseIntsT, coloring, maxColor, -1, -1)), iuniqueEqIndex, itempvars);
then (SOME(SimCode.JAC_MATRIX({}, {}, "", sparseInts, sparseIntsT, coloring, maxColor, -1, 0)), iuniqueEqIndex, itempvars);

case (BackendDAE.GENERIC_JACOBIAN(SOME((BackendDAE.DAE(eqs={syst as BackendDAE.EQSYSTEM(matching=BackendDAE.MATCHING(comps=comps))},
shared=shared), name,
Expand Down Expand Up @@ -4283,7 +4283,7 @@ algorithm
print("analytical Jacobians -> transformed to SimCode for Matrix " + name + " time: " + realString(clock()) + "\n");
end if;

then (SOME(SimCode.JAC_MATRIX({SimCode.JAC_COLUMN(columnEquations, columnVars, nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, -1)), uniqueEqIndex, tempvars);
then (SOME(SimCode.JAC_MATRIX({SimCode.JAC_COLUMN(columnEquations, columnVars, nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, 0)), uniqueEqIndex, tempvars);

else
equation
Expand Down Expand Up @@ -4469,7 +4469,7 @@ algorithm
// create seed vars
seedVars = replaceSeedVarsName(seedVars, name);

tmpJac = SimCode.JAC_MATRIX({SimCode.JAC_COLUMN({},{},nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, -1);
tmpJac = SimCode.JAC_MATRIX({SimCode.JAC_COLUMN({},{},nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, 0);
linearModelMatrices = tmpJac::inJacobianMatrixes;
(linearModelMatrices, uniqueEqIndex) = createSymbolicJacobianssSimCode(rest, inSimVarHT, iuniqueEqIndex, restnames, linearModelMatrices);

Expand Down Expand Up @@ -4558,7 +4558,7 @@ algorithm
// create seed vars
seedVars = replaceSeedVarsName(seedVars, name);

tmpJac = SimCode.JAC_MATRIX({SimCode.JAC_COLUMN(columnEquations, columnVars, nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, -1);
tmpJac = SimCode.JAC_MATRIX({SimCode.JAC_COLUMN(columnEquations, columnVars, nRows)}, seedVars, name, sparseInts, sparseIntsT, coloring, maxColor, -1, 0);
linearModelMatrices = tmpJac::inJacobianMatrixes;
(linearModelMatrices, uniqueEqIndex) = createSymbolicJacobianssSimCode(rest, inSimVarHT, uniqueEqIndex, restnames, linearModelMatrices);
then
Expand Down Expand Up @@ -5021,7 +5021,7 @@ algorithm
end if;

then
(SimCode.JAC_MATRIX({SimCode.JAC_COLUMN({}, {}, nResultVars)}, {}, inName, sparseInts, sparseIntsT, coloring, maxColor, -1, -1), iuniqueEqIndex);
(SimCode.JAC_MATRIX({SimCode.JAC_COLUMN({}, {}, nResultVars)}, {}, inName, sparseInts, sparseIntsT, coloring, maxColor, -1, 0), iuniqueEqIndex);

else
equation
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -12850,7 +12850,7 @@ template functionAnalyticJacobians(list<JacobianMatrix> JacobianMatrixes, SimCod
let &varDecls = buffer "" /*BUFD*/

let jacMats = (JacobianMatrixes |> JAC_MATRIX(columns=mat, seedVars=vars, matrixName=name, sparsity=sparsepattern, coloredCols=colorList, maxColorCols=maxColor, jacobianIndex=jacIndex, partitionIndex=partIdx) =>
generateMatrix(jacIndex, mat, vars, name, sparsepattern, colorList, partIdx, maxColor, simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
generateMatrix(jacIndex, mat, vars, name, sparsepattern, colorList, maxColor, partIdx, simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
;separator="\n\n";empty)
/*let initialStateSetJac = (stateSets |> set hasindex i1 fromindex 0 => (match set
case set as SES_STATESET(__) then
Expand Down

0 comments on commit 0014f95

Please sign in to comment.