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

Commit 61870e3

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Enhance logging of DgesvSolver
1 parent 4866f55 commit 61870e3

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

SimulationRuntime/cpp/Include/Solver/Dgesv/DgesvSolver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class DgesvSolver : public IAlgLoopSolver
4242

4343
long int *_ihelpArray; //pivot indices for lapackroutine
4444

45+
const char*
46+
*_yNames; ///< Names of variables
4547
double
48+
*_yNominal, ///< Nominal values of variables
4649
*_y, ///< Temp - Unknowns
4750
*_y0, ///< Temp - Auxillary variables
4851
*_y_old, //stores old solution

SimulationRuntime/cpp/Solver/Dgesv/DgesvSolver.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ DgesvSolver::DgesvSolver(ILinearAlgLoop* algLoop, ILinSolverSettings* settings)
1919
: _algLoop (algLoop)
2020
, _dimSys (0)
2121

22+
, _yNames (NULL)
23+
, _yNominal (NULL)
2224
, _y (NULL)
2325
, _y0 (NULL)
2426
, _y_old (NULL)
@@ -35,6 +37,8 @@ DgesvSolver::DgesvSolver(ILinearAlgLoop* algLoop, ILinSolverSettings* settings)
3537

3638
DgesvSolver::~DgesvSolver()
3739
{
40+
if (_yNames) delete [] _yNames;
41+
if (_yNominal) delete [] _yNominal;
3842
if (_y) delete [] _y;
3943
if (_y0) delete [] _y0;
4044
if (_y_old) delete [] _y_old;
@@ -60,6 +64,8 @@ void DgesvSolver::initialize()
6064

6165
if (_dimSys > 0) {
6266
// Initialization of vector of unknowns
67+
if (_yNames) delete [] _yNames;
68+
if (_yNominal) delete [] _yNominal;
6369
if (_y) delete [] _y;
6470
if (_y0) delete [] _y0;
6571
if (_y_old) delete [] _y_old;
@@ -70,6 +76,8 @@ void DgesvSolver::initialize()
7076
if (_zeroVec) delete [] _zeroVec;
7177
if (_fNominal) delete [] _fNominal;
7278

79+
_yNames = new const char* [_dimSys];
80+
_yNominal = new double[_dimSys];
7381
_y = new double[_dimSys];
7482
_y0 = new double[_dimSys];
7583
_y_old = new double[_dimSys];
@@ -80,6 +88,8 @@ void DgesvSolver::initialize()
8088
_zeroVec = new double[_dimSys];
8189
_fNominal = new double[_dimSys];
8290

91+
_algLoop->getNamesReal(_yNames);
92+
_algLoop->getNominalReal(_yNominal);
8393
_algLoop->getReal(_y);
8494
_algLoop->getReal(_y0);
8595
_algLoop->getReal(_y_new);
@@ -93,7 +103,12 @@ void DgesvSolver::initialize()
93103
_iterationStatus = SOLVERERROR;
94104
}
95105
}
96-
LOGGER_WRITE("DgesvSolver: initialized",LC_NLS,LL_DEBUG);
106+
107+
LOGGER_WRITE_BEGIN("DgesvSolver: eq" + to_string(_algLoop->getEquationIndex()) +
108+
" initialized", LC_LS, LL_DEBUG);
109+
LOGGER_WRITE_VECTOR("yNames", _yNames, _dimSys, LC_LS, LL_DEBUG);
110+
LOGGER_WRITE_VECTOR("yNominal", _yNominal, _dimSys, LC_LS, LL_DEBUG);
111+
LOGGER_WRITE_END(LC_LS, LL_DEBUG);
97112
}
98113

99114
void DgesvSolver::solve()
@@ -104,6 +119,10 @@ void DgesvSolver::solve()
104119

105120
_iterationStatus = CONTINUE;
106121

122+
LOGGER_WRITE_BEGIN("DgesvSolver: eq" + to_string(_algLoop->getEquationIndex()) +
123+
" at time " + to_string(_algLoop->getSimTime()) + ":",
124+
LC_LS, LL_DEBUG);
125+
107126
//use lapack
108127
long int dimRHS = 1; // Dimension of right hand side of linear system (=_b)
109128
long int irtrn = 0; // Return-flag of Fortran code
@@ -123,6 +142,8 @@ void DgesvSolver::solve()
123142
for (int i = 0; i < _dimSys; i++, idx++)
124143
_fNominal[i] = std::max(std::abs(Atemp[idx]), _fNominal[i]);
125144

145+
LOGGER_WRITE_VECTOR("fNominal", _fNominal, _dimSys, LC_LS, LL_DEBUG);
146+
126147
for (int j = 0, idx = 0; j < _dimSys; j++)
127148
for (int i = 0; i < _dimSys; i++, idx++)
128149
_A[idx] /= _fNominal[i];
@@ -154,6 +175,9 @@ void DgesvSolver::solve()
154175
_algLoop->setReal(_y);
155176
if (_algLoop->isLinearTearing())
156177
_algLoop->evaluate();//resets the right hand side to zero in the case of linear tearing. Otherwise, the b vector on the right hand side needs no update.
178+
179+
LOGGER_WRITE_VECTOR("y*", _y, _dimSys, LC_LS, LL_DEBUG);
180+
LOGGER_WRITE_END(LC_LS, LL_DEBUG);
157181
}
158182

159183
IAlgLoopSolver::ITERATIONSTATUS DgesvSolver::getIterationStatus()

0 commit comments

Comments
 (0)