DiFfRG
Loading...
Searching...
No Matches
UMFPack.hh
Go to the documentation of this file.
1#pragma once
2
3// external libraries
4#include <deal.II/lac/sparse_direct.h>
5
6// DiFfRG
8
9namespace DiFfRG
10{
11 template <typename SparseMatrixType, typename VectorType>
12 class UMFPack : public AbstractLinearSolver<SparseMatrixType, VectorType>
13 {
14 public:
15 UMFPack() : matrix(nullptr) {}
16
17 void init(const SparseMatrixType &matrix) { this->matrix = &matrix; }
18
19 bool invert()
20 {
21 if (!matrix) throw std::runtime_error("UMFPack::invert: matrix not initialized");
22 solver.initialize(*matrix);
23 return true;
24 }
25
26 int solve(const VectorType &src, VectorType &dst, const double)
27 {
28 if (!matrix) throw std::runtime_error("UMFPack::solve: matrix not initialized");
29 solver.vmult(dst, src);
30 return -1;
31 }
32
33 private:
34 const SparseMatrixType *matrix;
35 dealii::SparseDirectUMFPACK solver;
36 };
37} // namespace DiFfRG
Definition abstract_linear_solver.hh:9
Definition UMFPack.hh:13
dealii::SparseDirectUMFPACK solver
Definition UMFPack.hh:35
void init(const SparseMatrixType &matrix)
Definition UMFPack.hh:17
int solve(const VectorType &src, VectorType &dst, const double)
Definition UMFPack.hh:26
bool invert()
Definition UMFPack.hh:19
UMFPack()
Definition UMFPack.hh:15
const SparseMatrixType * matrix
Definition UMFPack.hh:34
Definition complex_math.hh:14