Skip to content
Snippets Groups Projects
Commit b97a21dd authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Dmitri Naumov
Browse files

Try to fix accelerated linear PDE assembly

parent 726ce877
No related branches found
No related tags found
No related merge requests found
......@@ -63,8 +63,30 @@ public:
}
bool compute(Matrix& A, EigenOption& opt,
MathLib::LinearSolverBehaviour const linear_solver_behaviour)
MathLib::LinearSolverBehaviour linear_solver_behaviour)
{
if (linear_solver_behaviour == MathLib::LinearSolverBehaviour::REUSE)
{
// Checking if this is the first compute() call should work both for
// direct solvers (that factorize the matrix A) and for iterative
// solvers (that store a reference to A in the preconditioner).
if (is_first_compute_call_)
{
// There is nothing there, yet, to be reused. Hence, we compute
// and store the result.
linear_solver_behaviour =
MathLib::LinearSolverBehaviour::RECOMPUTE_AND_STORE;
}
else
{
return true;
}
}
// TODO (CL) That might not work under all circumstances, e.g., if the
// linear solver fails subsequently. Time will tell.
is_first_compute_call_ = false;
#ifdef USE_EIGEN_UNSUPPORTED
if (opt.scaling)
{
......@@ -89,6 +111,8 @@ private:
#ifdef USE_EIGEN_UNSUPPORTED
std::unique_ptr<Eigen::IterScaling<EigenMatrix::RawMatrixType>> scaling_;
#endif
bool is_first_compute_call_ = true;
};
namespace details
......
......@@ -34,18 +34,12 @@ bool solvePicard(GlobalLinearSolver& linear_solver, GlobalMatrix& A,
BaseLib::RunTime time_linear_solver;
time_linear_solver.start();
if (linear_solver_behaviour == MathLib::LinearSolverBehaviour::RECOMPUTE ||
linear_solver_behaviour ==
MathLib::LinearSolverBehaviour::RECOMPUTE_AND_STORE)
if (!linear_solver.compute(A, linear_solver_behaviour))
{
if (!linear_solver.compute(A, linear_solver_behaviour))
{
ERR("Picard: The linear solver failed in the compute() step.");
return false;
}
ERR("Picard: The linear solver failed in the compute() step.");
return false;
}
// REUSE the previously computed preconditioner or LU decomposition
bool const iteration_succeeded = linear_solver.solve(rhs, x);
INFO("[time] Linear solver took {:g} s.", time_linear_solver.elapsed());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment