Skip to content

Commit 0488acd

Browse files
authored
[janitor] Fix whitespace and comments (#14036)
1 parent ea22787 commit 0488acd

File tree

11 files changed

+60
-83
lines changed

11 files changed

+60
-83
lines changed

OMCompiler/Compiler/SimCode/SimCodeUtil.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15398,7 +15398,7 @@ algorithm
1539815398
end match;
1539915399
else
1540015400
//print("cref2simvar: " + ComponentReference.printComponentRefStr(inCref) + " not found!\n");
15401-
badcref := ComponentReference.makeCrefIdent("ERROR_cref2simvar_failed " + ComponentReference.printComponentRefStr(inCref), DAE.T_REAL_DEFAULT, {});
15401+
badcref := ComponentReference.makeCrefIdent("ERROR_simVarFromHT_failed " + ComponentReference.printComponentRefStr(inCref), DAE.T_REAL_DEFAULT, {});
1540215402
sv := SimCodeVar.SIMVAR(badcref, BackendDAE.VARIABLE(), "", "", "", -2, NONE(), NONE(), NONE(), NONE(), false, DAE.T_REAL_DEFAULT, false, NONE(), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SOME(SimCodeVar.LOCAL()), NONE(), NONE(), {}, false, true, NONE(), false, NONE(), false, NONE(), NONE(), NONE(), SOME(badcref), false);
1540315403
end try;
1540415404
outSimVar := sv;

OMCompiler/Compiler/Template/CodegenC.tpl

Lines changed: 33 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ template simulationFile_exo(SimCode simCode)
633633
<%functionCallExternalObjectDestructors(extObjInfo, modelNamePrefix(simCode))%>
634634
#if defined(__cplusplus)
635635
}
636-
#endif
637-
<%\n%>
636+
#endif<%\n%>
638637
>>
639638
/* adrpo: leave a newline at the end of file to get rid of the warning */
640639
end match
@@ -660,8 +659,7 @@ template simulationFile_nls(SimCode simCode)
660659
661660
#if defined(__cplusplus)
662661
}
663-
#endif
664-
<%\n%>
662+
#endif<%\n%>
665663
>>
666664
/* adrpo: leave a newline at the end of file to get rid of the warning */
667665
end match
@@ -687,8 +685,7 @@ template simulationFile_lsy(SimCode simCode)
687685
688686
#if defined(__cplusplus)
689687
}
690-
#endif
691-
<%\n%>
688+
#endif<%\n%>
692689
>>
693690
/* adrpo: leave a newline at the end of file to get rid of the warning */
694691
end match
@@ -711,8 +708,7 @@ template simulationFile_set(SimCode simCode)
711708
712709
#if defined(__cplusplus)
713710
}
714-
#endif
715-
<%\n%>
711+
#endif<%\n%>
716712
>>
717713
/* adrpo: leave a newline at the end of file to get rid of the warning */
718714
end match
@@ -738,8 +734,7 @@ template simulationFile_evt(SimCode simCode)
738734
739735
#if defined(__cplusplus)
740736
}
741-
#endif
742-
<%\n%>
737+
#endif<%\n%>
743738
>>
744739
/* adrpo: leave a newline at the end of file to get rid of the warning */
745740
end match
@@ -768,8 +763,7 @@ template simulationFile_inz(SimCode simCode)
768763
769764
#if defined(__cplusplus)
770765
}
771-
#endif
772-
<%\n%>
766+
#endif<%\n%>
773767
>>
774768
/* adrpo: leave a newline at the end of file to get rid of the warning */
775769
end match
@@ -791,8 +785,7 @@ template simulationFile_dly(SimCode simCode)
791785
792786
#if defined(__cplusplus)
793787
}
794-
#endif
795-
<%\n%>
788+
#endif<%\n%>
796789
>>
797790
/* adrpo: leave a newline at the end of file to get rid of the warning */
798791
end match
@@ -816,8 +809,7 @@ template simulationFile_spd(SimCode simCode)
816809
817810
#if defined(__cplusplus)
818811
}
819-
#endif
820-
<%\n%>
812+
#endif<%\n%>
821813
>>
822814
/* adrpo: leave a newline at the end of file to get rid of the warning */
823815
end match
@@ -841,8 +833,7 @@ template simulationFile_bnd(SimCode simCode)
841833
842834
#if defined(__cplusplus)
843835
}
844-
#endif
845-
<%\n%>
836+
#endif<%\n%>
846837
>>
847838
/* adrpo: leave a newline at the end of file to get rid of the warning */
848839
end match
@@ -887,8 +878,7 @@ template simulationFile_asr(SimCode simCode)
887878
888879
#if defined(__cplusplus)
889880
}
890-
#endif
891-
<%\n%>
881+
#endif<%\n%>
892882
>>
893883
/* adrpo: leave a newline at the end of file to get rid of the warning */
894884
end match
@@ -904,9 +894,7 @@ template simulationFile_mix(SimCode simCode, Text &header)
904894
/* Mixed Systems */
905895
<%simulationFileHeader(simCode.fileNamePrefix)%>
906896
#include "<%simCode.fileNamePrefix%>_11mix.h"
907-
<%functionSetupMixedSystems(initialEquations, initialEquations_lambda0, parameterEquations, allEquations, jacobianMatrices, &header, modelNamePrefixStr)%>
908-
909-
<%\n%>
897+
<%functionSetupMixedSystems(initialEquations, initialEquations_lambda0, parameterEquations, allEquations, jacobianMatrices, &header, modelNamePrefixStr)%><%\n%>
910898
>>
911899
/* adrpo: leave a newline at the end of file to get rid of the warning */
912900
end match
@@ -923,9 +911,7 @@ template simulationFile_jac(SimCode simCode)
923911
#include "<%fileNamePrefix%>_12jac.h"
924912
#include "simulation/jacobian_util.h"
925913
#include "util/omc_file.h"
926-
<%functionAnalyticJacobians(jacobianMatrices, modelNamePrefix(simCode), simCode.fileNamePrefix)%>
927-
928-
<%\n%>
914+
<%functionAnalyticJacobians(jacobianMatrices, modelNamePrefix(simCode), simCode.fileNamePrefix)%><%\n%>
929915
>>
930916
/* adrpo: leave a newline at the end of file to get rid of the warning */
931917
end match
@@ -940,8 +926,7 @@ template simulationFile_jac_header(SimCode simCode)
940926
/* Jacobians */
941927
static const REAL_ATTRIBUTE dummyREAL_ATTRIBUTE = omc_dummyRealAttribute;
942928

943-
<%symJacDefinition(jacobianMatrices, modelNamePrefix(simCode))%>
944-
<%\n%>
929+
<%symJacDefinition(jacobianMatrices, modelNamePrefix(simCode))%><%\n%>
945930
>>
946931
/* adrpo: leave a newline at the end of file to get rid of the warning */
947932
end match
@@ -963,7 +948,7 @@ template simulationFile_opt(SimCode simCode)
963948
<%optimizationComponents(classAttributes, simCode, modelNamePrefixStr)%>
964949
#if defined(__cplusplus)
965950
}
966-
#endif
951+
#endif<%\n%>
967952
>>
968953
/* adrpo: leave a newline at the end of file to get rid of the warning */
969954
end match
@@ -987,7 +972,7 @@ template simulationFile_opt_header(SimCode simCode)
987972
int <%symbolName(modelNamePrefixStr,"getTimeGrid")%>(DATA *data, modelica_integer * nsi, modelica_real**t);
988973
#if defined(__cplusplus)
989974
}
990-
#endif
975+
#endif<%\n%>
991976
>>
992977
/* adrpo: leave a newline at the end of file to get rid of the warning */
993978
end match
@@ -1032,8 +1017,7 @@ template simulationFile_lnz(SimCode simCode)
10321017
%>
10331018
#if defined(__cplusplus)
10341019
}
1035-
#endif
1036-
<%\n%>
1020+
#endif<%\n%>
10371021
>>
10381022
/* adrpo: leave a newline at the end of file to get rid of the warning */
10391023
end match
@@ -1077,15 +1061,14 @@ template simulationFile_dae_header(SimCode simCode)
10771061
/* auxiliary variable define for daeMode */
10781062
<%auxiliaryVars |> var =>
10791063
defineSimVarArray(var, "auxiliaryVars")
1080-
;separator="\n"%>
1064+
;separator="\n"%><%\n%>
10811065
>>
10821066
/* adrpo: leave a newline at the end of file to get rid of the warning */
10831067
case simCode as SIMCODE(__) then
10841068
<<
10851069
#ifndef <%fileNamePrefix%>_16DAE_H
10861070
#define <%fileNamePrefix%>_16DAE_H
1087-
#endif
1088-
<%\n%>
1071+
#endif<%\n%>
10891072
>>
10901073
end match
10911074
end simulationFile_dae_header;
@@ -5654,15 +5637,15 @@ template genVector(String name, String num, Integer numI, Integer flag) "templat
56545637
end match
56555638
end genVector;
56565639

5657-
template functionAnalyticJacobians(list<JacobianMatrix> JacobianMatrices,String modelNamePrefix, String fileNamePrefix) "template functionAnalyticJacobians
5640+
template functionAnalyticJacobians(list<JacobianMatrix> JacobianMatrices, String modelNamePrefix, String fileNamePrefix) "template functionAnalyticJacobians
56585641
This template generates source code for all given jacobians."
56595642
::=
5660-
let initialjacMats = (JacobianMatrices |> JAC_MATRIX(columns=mat, seedVars=vars, matrixName=name, sparsity=sparsepattern, coloredCols=colorList, maxColorCols=maxColor) =>
5661-
initialAnalyticJacobians(mat, vars, name, sparsepattern, colorList, maxColor, modelNamePrefix, fileNamePrefix); separator="\n")
5662-
let jacMats = (JacobianMatrices |> JAC_MATRIX(columns=mat, seedVars=vars, matrixName=name, partitionIndex=partIdx, crefsHT=crefsHT) =>
5663-
generateMatrix(mat, vars, name, partIdx, crefsHT, modelNamePrefix) ;separator="\n")
5664-
let jacGenericCalls = (JacobianMatrices |> jac as JAC_MATRIX() => genericCallBodies(jac.generic_loop_calls, createJacContext(jac.crefsHT)) ;separator="\n")
5665-
5643+
let initialjacMats = (JacobianMatrices |> JAC_MATRIX() =>
5644+
initialAnalyticJacobians(columns, seedVars, matrixName, sparsity, coloredCols, maxColorCols, modelNamePrefix, fileNamePrefix); separator="\n")
5645+
let jacMats = (JacobianMatrices |> JAC_MATRIX() =>
5646+
generateMatrix(columns, seedVars, matrixName, partitionIndex, crefsHT, modelNamePrefix) ;separator="\n")
5647+
let jacGenericCalls = (JacobianMatrices |> JAC_MATRIX() =>
5648+
genericCallBodies(generic_loop_calls, createJacContext(crefsHT)) ;separator="\n")
56665649
<<
56675650
<%jacMats%>
56685651

@@ -5683,21 +5666,18 @@ match sparsepattern
56835666
int <%symbolName(modelNamePrefix,"initialAnalyticJacobian")%><%matrixname%>(DATA* data, threadData_t *threadData, JACOBIAN *jacobian)
56845667
{
56855668
TRACE_PUSH
5686-
TRACE_POP
56875669
jacobian->availability = JACOBIAN_NOT_AVAILABLE;
5670+
TRACE_POP
56885671
return 1;
56895672
}
56905673
>>
56915674
case _ then
5692-
let &eachCrefParts = buffer ""
5693-
let sp_size_index = lengthListElements(unzipSecond(sparsepattern))
5675+
let sp_size_index = lengthListElements(unzipSecond(sparsepattern))
56945676
let sizeleadindex = listLength(sparsepattern)
5695-
let fileName = '<%fileNamePrefix%>_Jac<%matrixname%>.bin'
5696-
let colorString = readSPColors(colorList, "jacobian->sparsePattern->colorCols", sizeleadindex)
56975677
let availability = if SimCodeUtil.jacobianColumnsAreEmpty(jacobianColumn) then 'JACOBIAN_ONLY_SPARSITY' else 'JACOBIAN_AVAILABLE'
5698-
let sizeRows = (jacobianColumn |> JAC_COLUMN(numberOfResultVars=nRows) => '<%nRows%>';separator="\n")
5699-
let tmpvarsSize = (jacobianColumn |> JAC_COLUMN(columnVars=vars) => listLength(vars);separator="\n")
5700-
let constantEqns = (jacobianColumn |> JAC_COLUMN(constantEqns=constantEqns) =>
5678+
let sizeRows = (jacobianColumn |> JAC_COLUMN() => numberOfResultVars; separator="\n")
5679+
let tmpvarsSize = (jacobianColumn |> JAC_COLUMN() => listLength(columnVars); separator="\n")
5680+
let constantEqns = (jacobianColumn |> JAC_COLUMN() =>
57015681
match constantEqns case {} then 'NULL' case _ then '<%symbolName(modelNamePrefix,"functionJac")%><%matrixname%>_constantEqns'
57025682
;separator="")
57035683
let evalColumn = '<%symbolName(modelNamePrefix,"functionJac")%><%matrixname%>_column'
@@ -5709,7 +5689,7 @@ match sparsepattern
57095689
TRACE_PUSH
57105690
size_t count;
57115691
5712-
FILE* pFile = openSparsePatternFile(data, threadData, "<%fileName%>");
5692+
FILE* pFile = openSparsePatternFile(data, threadData, "<%fileNamePrefix%>_Jac<%matrixname%>.bin");
57135693
57145694
initJacobian(jacobian, <%sizeCols%>, <%sizeRows%>, <%tmpvarsSize%>, <%evalColumn%>, <%constantEqns%>, NULL);
57155695
jacobian->sparsePattern = allocSparsePattern(<%sizeleadindex%>, <%sp_size_index%>, <%maxColor%>);
@@ -5728,7 +5708,7 @@ match sparsepattern
57285708
}
57295709

57305710
/* write color array */
5731-
<%colorString%>
5711+
<%readSPColors(colorList, "jacobian->sparsePattern->colorCols", sizeleadindex)%>
57325712

57335713
omc_fclose(pFile);
57345714

@@ -5801,7 +5781,6 @@ template functionJac(list<SimEqSystem> jacEquations, list<SimEqSystem> constantE
58015781
"This template generates functions for each column of a single jacobian.
58025782
This is a helper of generateMatrix."
58035783
::=
5804-
let constantEqns2 = generateConstantEqns(constantEqns, matrixName, modelNamePrefix)
58055784
<<
58065785
/* constant equations */
58075786
<%(constantEqns |> eq hasindex sub_idx =>
@@ -5810,7 +5789,7 @@ template functionJac(list<SimEqSystem> jacEquations, list<SimEqSystem> constantE
58105789
<%(jacEquations |> eq hasindex sub_idx =>
58115790
equation_impl(base_idx, sub_idx, eq, createJacContext(jacHT), modelNamePrefix, false); separator="\n")%>
58125791

5813-
<%constantEqns2%>
5792+
<%generateConstantEqns(constantEqns, matrixName, modelNamePrefix)%>
58145793

58155794
int <%symbolName(modelNamePrefix,"functionJac")%><%matrixName%>_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian)
58165795
{
@@ -6999,7 +6978,6 @@ end simulationParModelicaKernelsFile;
69996978
}
70006979
#endif
70016980
#endif<%\n%>
7002-
<%\n%>
70036981
>>
70046982
/* adrpo: leave a newline at the end of file to get rid of the warning */
70056983
end simulationFunctionsHeaderFile;

OMCompiler/SimulationRuntime/c/simulation/jacobian_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void freeJacobian(JACOBIAN *jac)
106106

107107
/*! \fn evalJacobian
108108
*
109-
* compute entries of Jacobian in sparse CSC or dense format
109+
* compute entries of Jacobian in sparse CSC or dense format
110110
* uses coloring (sparsePattern non NULL)
111111
*
112112
* \param [ref] [data]

OMCompiler/SimulationRuntime/c/simulation/solver/dassl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ int dassl_initial(DATA* data, threadData_t *threadData,
351351
data->callback->initialAnalyticJacobianA(data, threadData, jacobian);
352352
if(jacobian->availability == JACOBIAN_AVAILABLE || jacobian->availability == JACOBIAN_ONLY_SPARSITY) {
353353
infoStreamPrint(OMC_LOG_SIMULATION, 1, "Initialized Jacobian:");
354-
infoStreamPrint(OMC_LOG_SIMULATION, 0, "columns: %d rows: %d", jacobian->sizeCols, jacobian->sizeRows);
354+
infoStreamPrint(OMC_LOG_SIMULATION, 0, "columns: %zu rows: %zu", jacobian->sizeCols, jacobian->sizeRows);
355355
infoStreamPrint(OMC_LOG_SIMULATION, 0, "NNZ: %d colors: %d", jacobian->sparsePattern->numberOfNonZeros, jacobian->sparsePattern->maxColors);
356356
messageClose(OMC_LOG_SIMULATION);
357357
}

OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ int gbodef_main(DATA *data, threadData_t *threadData, SOLVER_INFO *solverInfo, d
748748
modelica_boolean foundEvent;
749749

750750
// This is the target time of the main integrator
751-
double innerTargetTime = fmin(targetTime, gbData->timeRight);
751+
const double innerTargetTime = fmin(targetTime, gbData->timeRight);
752752

753753
/* The inner integrator needs to be initialzed, at start time, when an event occured,
754754
* and if outer integrations have been done with all states involved
@@ -758,7 +758,6 @@ int gbodef_main(DATA *data, threadData_t *threadData, SOLVER_INFO *solverInfo, d
758758
gbodef_init(data, threadData, solverInfo);
759759
}
760760

761-
762761
fastStatesChange = checkFastStatesChange(gbData);
763762

764763
if (fastStatesChange && !gbfData->isExplicit) {

OMCompiler/SimulationRuntime/c/simulation/solver/gbode_nls.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
#include "../jacobian_util.h"
4747
#include "../../util/rtclock.h"
4848

49+
/* forward declarations */
50+
int jacobian_SR_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
51+
int jacobian_MR_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
52+
int jacobian_IRK_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
53+
4954
/**
5055
* @brief Specific error handling of kinsol for gbode
5156
*
@@ -660,7 +665,9 @@ void residual_DIRK(RESIDUAL_USERDATA* userData, const double *xloc, double *res,
660665
*
661666
* For the fast states:
662667
* Based on the Butcher tableau the following nonlinear residuals will be calculated:
663-
* res = f(tOld + c[i]*h, yOld + h*sum(A[i,j]*k[j], j=1..act_stage))
668+
* y[j] = yOld + h*sum(A[i,j]*k[j], j=1..act_stage)
669+
* res_const[j] = yOld + h*sum(A[i,j]*k[j], j=1..act_stage-1)
670+
* res = res_const[j] - y[j] + f(tOld + c[i]*h, y[j])
664671
* When calling, the following is already calculated:
665672
* sData->timeValue = tOld + c[i]*h
666673
* res_const = yOld + h*sum(A[i,j]*k[j], j=1..act_stage-1)

OMCompiler/SimulationRuntime/c/simulation/solver/gbode_nls.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ void residual_MS(RESIDUAL_USERDATA* userData, const double *xloc, double *res, c
5555
void residual_DIRK(RESIDUAL_USERDATA* userData, const double *xloc, double *res, const int *iflag);
5656
void residual_IRK(RESIDUAL_USERDATA* userData, const double *xloc, double *res, const int *iflag);
5757

58-
int jacobian_SR_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
59-
int jacobian_IRK_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
60-
6158
void residual_MS_MR(RESIDUAL_USERDATA* userData, const double *xloc, double *res, const int *iflag);
6259
void residual_DIRK_MR(RESIDUAL_USERDATA* userData, const double *xloc, double *res, const int *iflag);
63-
int jacobian_MR_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian);
6460

6561
#ifdef __cplusplus
6662
};

0 commit comments

Comments
 (0)