Fix output in case of LAPACK error.

Make copy of matrix before calling dgesv, since it will overwrite it.
This commit is contained in:
Atgeirr Flø Rasmussen 2012-10-17 12:40:43 +02:00
parent 49af5dcd7b
commit 88af4a4ce3
2 changed files with 4 additions and 1 deletions

View File

@ -465,6 +465,7 @@ namespace Opm
tof_coeff_ = &tof_coeff[0];
rhs_.resize(num_basis);
jac_.resize(num_basis*num_basis);
orig_jac_.resize(num_basis*num_basis);
basis_.resize(num_basis);
basis_nb_.resize(num_basis);
grad_basis_.resize(num_basis*grid_.dimensions);
@ -617,6 +618,7 @@ namespace Opm
std::vector<MAT_SIZE_T> piv(num_basis);
MAT_SIZE_T ldb = num_basis;
MAT_SIZE_T info = 0;
orig_jac_ = jac_;
dgesv_(&n, &nrhs, &jac_[0], &lda, &piv[0], &rhs_[0], &ldb, &info);
if (info != 0) {
// Print the local matrix and rhs.
@ -624,7 +626,7 @@ namespace Opm
<< " with A = \n";
for (int row = 0; row < n; ++row) {
for (int col = 0; col < n; ++col) {
std::cerr << " " << jac_[row + n*col];
std::cerr << " " << orig_jac_[row + n*col];
}
std::cerr << '\n';
}

View File

@ -91,6 +91,7 @@ namespace Opm
double* tof_coeff_;
std::vector<double> rhs_; // single-cell right-hand-side
std::vector<double> jac_; // single-cell jacobian
std::vector<double> orig_jac_; // single-cell jacobian (copy)
// Below: storage for quantities needed by solveSingleCell().
std::vector<double> coord_;
std::vector<double> basis_;