Commit 41e18489 authored by Sander, Oliver's avatar Sander, Oliver
Browse files

More cholmod debugging code

parent f931b4d2
Pipeline #8947 failed with stage
in 6 minutes and 29 seconds
......@@ -89,10 +89,12 @@ public:
*/
Cholmod()
{
std::cout << "CHOLMOD constructor begin" << std::endl;
if (std::is_same_v<Index,int>)
cholmod_start(&c_);
else
cholmod_l_start(&c_);
std::cout << "CHOLMOD constructor end" << std::endl;
}
/** @brief Destructor
......@@ -135,6 +137,8 @@ public:
*/
void apply(Vector& x, Vector& b, InverseOperatorResult& res)
{
std::cout << "CHOLMOD apply begin" << std::endl;
// do nothing if N=0
if ( nIsZero_ )
{
......@@ -160,10 +164,13 @@ public:
});
// create a cholmod dense object
std::cout << "CHOLMOD apply A" << std::endl;
auto b3 = make_cholmod_dense( (std::is_same_v<Index,int>)
? cholmod_allocate_dense(L_->n, 1, L_->n, CHOLMOD_REAL, &c_)
: cholmod_l_allocate_dense(L_->n, 1, L_->n, CHOLMOD_REAL, &c_), &c_);
std::cout << "CHOLMOD apply B" << std::endl;
// cast because void-ptr
auto b4 = static_cast<double*>(b3->x);
std::copy(b2.get(), b2.get() + L_->n, b4);
......@@ -175,6 +182,9 @@ public:
// cast because void-ptr
auto xp = static_cast<double*>(x3->x);
std::cout << "CHOLMOD apply C" << std::endl;
// copy into x
flatVectorForEach(x, [&](auto&& entry, auto&& flatIndex){
if ( subIndices_.empty() )
......@@ -187,6 +197,8 @@ public:
// statistics for a direct solver
res.iterations = 1;
res.converged = true;
std::cout << "CHOLMOD apply end" << std::endl;
}
......@@ -219,6 +231,8 @@ public:
template<class Matrix, class Ignore>
void setMatrix(const Matrix& matrix, const Ignore* ignore)
{
std::cout << "CHOLMOD setMatrix begin" << std::endl;
// count the number of entries and diagonal entries
int nonZeros = 0;
int numberOfIgnoredDofs = 0;
......@@ -258,6 +272,8 @@ public:
else
cholmod_l_free_sparse(&p, c);
};
std::cout << "CHOLMOD setMatrix A" << std::endl;
cholmod_sparse* rawM;
if (std::is_same_v<Index,int>)
......@@ -284,9 +300,12 @@ public:
&c_ // cholmod_common ptr
);
}
std::cout << "CHOLMOD setMatrix B" << std::endl;
auto M = std::unique_ptr<cholmod_sparse, decltype(deleter)>(rawM, deleter);
std::cout << "CHOLMOD setMatrix C" << std::endl;
// copy the data of BCRS matrix to Cholmod Sparse matrix
Index* Ap = static_cast<Index*>(M->p);
Index* Ai = static_cast<Index*>(M->i);
......@@ -359,17 +378,24 @@ public:
});
std::cout << "CHOLMOD setMatrix D" << std::endl;
// Now analyse the pattern and optimal row order
if (std::is_same_v<Index,int>)
L_ = cholmod_analyze(M.get(), &c_);
else
L_ = cholmod_l_analyze(M.get(), &c_);
std::cout << "CHOLMOD setMatrix E" << std::endl;
// Do the factorization (this may take some time)
if (std::is_same_v<Index,int>)
cholmod_factorize(M.get(), L_, &c_);
else
cholmod_l_factorize(M.get(), L_, &c_);
std::cout << "CHOLMOD setMatrix end" << std::endl;
}
virtual SolverCategory::Category category() const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment