Provide error message after failure to create large Sundials matrix
If Sundials tries to create an excessively large matrix, it returns a null pointer. To avoid a subsequent segfault, throw an exception which makes the cause of the error clear. WIP: Better error message for too-large Sundials matrix TEMP: fixup for cvodes error messages
This commit is contained in:
parent
90d2ec41ca
commit
0fdbe24aaf
2 changed files with 18 additions and 0 deletions
|
|
@ -369,6 +369,10 @@ void CVodesIntegrator::applyOptions()
|
|||
SUNLinSolFree((SUNLinearSolver) m_linsol);
|
||||
SUNMatDestroy((SUNMatrix) m_linsol_matrix);
|
||||
m_linsol_matrix = SUNDenseMatrix(N, N);
|
||||
if (m_linsol_matrix == nullptr) {
|
||||
throw CanteraError("CVodesIntegrator::applyOptions",
|
||||
"Unable to create SUNDenseMatrix of size {0} x {0}", N);
|
||||
}
|
||||
#if CT_SUNDIALS_USE_LAPACK
|
||||
m_linsol = SUNLapackDense(m_y, (SUNMatrix) m_linsol_matrix);
|
||||
#else
|
||||
|
|
@ -400,6 +404,11 @@ void CVodesIntegrator::applyOptions()
|
|||
SUNLinSolFree((SUNLinearSolver) m_linsol);
|
||||
SUNMatDestroy((SUNMatrix) m_linsol_matrix);
|
||||
m_linsol_matrix = SUNBandMatrix(N, nu, nl, nu+nl);
|
||||
if (m_linsol_matrix == nullptr) {
|
||||
throw CanteraError("CVodesIntegrator::applyOptions",
|
||||
"Unable to create SUNBandMatrix of size {} with bandwidths "
|
||||
"{} and {}", N, nu, nl);
|
||||
}
|
||||
#if CT_SUNDIALS_USE_LAPACK
|
||||
m_linsol = SUNLapackBand(m_y, (SUNMatrix) m_linsol_matrix);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -422,6 +422,10 @@ void IDA_Solver::init(doublereal t0)
|
|||
SUNLinSolFree((SUNLinearSolver) m_linsol);
|
||||
SUNMatDestroy((SUNMatrix) m_linsol_matrix);
|
||||
m_linsol_matrix = SUNDenseMatrix(N, N);
|
||||
if (m_linsol_matrix == nullptr) {
|
||||
throw CanteraError("IDA_Solver::init",
|
||||
"Unable to create SUNDenseMatrix of size {0} x {0}", N);
|
||||
}
|
||||
#if CT_SUNDIALS_USE_LAPACK
|
||||
m_linsol = SUNLapackDense(m_y, (SUNMatrix) m_linsol_matrix);
|
||||
#else
|
||||
|
|
@ -443,6 +447,11 @@ void IDA_Solver::init(doublereal t0)
|
|||
SUNLinSolFree((SUNLinearSolver) m_linsol);
|
||||
SUNMatDestroy((SUNMatrix) m_linsol_matrix);
|
||||
m_linsol_matrix = SUNBandMatrix(N, nu, nl, nu+nl);
|
||||
if (m_linsol_matrix == nullptr) {
|
||||
throw CanteraError("IDA_Solver::init",
|
||||
"Unable to create SUNBandMatrix of size {} with bandwidths "
|
||||
"{} and {}", N, nu, nl);
|
||||
}
|
||||
#if CT_SUNDIALS_USE_LAPACK
|
||||
m_linsol = SUNLapackBand(m_y, (SUNMatrix) m_linsol_matrix);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue