13#ifndef FACTORIZATION_HH
14#define FACTORIZATION_HH
21#include <dune/grid/config.h>
24#include "dune/istl/bcrsmatrix.hh"
41template <
class Scalar>
76 virtual void solve(std::vector<field_type>& b)
const
78 assert(b.size() >=
size());
94 virtual void solve(std::vector<Scalar>
const& b, std::vector<Scalar>& x,
bool transposed=
false)
const
96 assert(b.size() >=
size());
97 if (x.size() <
size())
107 virtual void solve(Scalar
const* b, Scalar* x,
bool transposed=
false)
const = 0;
122 virtual size_t size()
const = 0;
138template <
class Scalar,
class Index>
141 std::vector<Index>
const& ridx,
142 std::vector<Index>
const& cidx,
143 std::vector<Scalar>
const& values,
144 std::vector<Index>& Ap, std::vector<Index>& Ai,
145 std::vector<Scalar>& Az);
155template <
class Scalar>
160 using Matrices = std::variant<MatrixAsTriplet<Scalar,int>
const*,
163 using Argument = std::tuple<Matrices, FactorizationOptions>;
176 std::ostringstream hint;
177 hint <<
"Solver key " << direct <<
" not registered.\n"
178 <<
"Has the corresponding object file been linked in?\n"
179 <<
"Did you specify the right index type (int/long/unsigned long) in your matrix?\n";
191template <
class Scalar,
class Index>
203 Argument args{Matrices(&A),options};
215template <
class Scalar>
216std::unique_ptr<Factorization<Scalar>>
221 using Index =
typename Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,1,1>>::size_type;
229template <
class Scalar,
int n,
int m,
class Index>
230std::unique_ptr<Factorization<Scalar>>
Abstract base class for matrix factorizations.
Factorization(Options options_)
virtual void solve(std::vector< Scalar > const &b, std::vector< Scalar > &x, bool transposed=false) const
Solves the system for the given right hand side .
Scalar field_type
The type of matrix elements (a field type).
virtual void solve(std::vector< field_type > &b) const
Solves the system for the given right hand side .
virtual void solve(Scalar const *b, Scalar *x, bool transposed=false) const =0
Solves the system for the given right hand side .
void setVerbose(int verbose_)
Info const & info() const
virtual void solve(field_type *b) const =0
Solves the system for the given right hand side .
virtual size_t size() const =0
reports the dimension of the system
SparseIndexInt nrows() const
Returns number of rows (computes them, if not known)
SparseIndexInt ncols() const
Returns number of cols (computes them, if not known)
A NUMA-aware compressed row storage matrix adhering mostly to the Dune ISTL interface (to complete....
To be raised if the matrix is singular.
std::unique_ptr< Factorization< Scalar > > getFactorization(DirectType directType, MatrixAsTriplet< Scalar, Index > const &A, FactorizationOptions options)
Creates a factorization of the given triplet matrix.
DirectType
Available direct solvers for linear equation systems.
void tripletToCompressedColumn(Index nRows, Index nCols, size_t nNonZeros, std::vector< Index > const &ridx, std::vector< Index > const &cidx, std::vector< Scalar > const &values, std::vector< Index > &Ap, std::vector< Index > &Ai, std::vector< Scalar > &Az)
Converts a matrix in triplet format to a compressed column format.
std::tuple< Matrices, FactorizationOptions > Argument
virtual std::unique_ptr< Factorization< Scalar > > create(Argument a) const =0
Creates a factorization for the given pair (A,opt) of matrix A and options opt.
std::variant< MatrixAsTriplet< Scalar, int > const *, MatrixAsTriplet< Scalar, long > const *, MatrixAsTriplet< Scalar, unsigned long > const * > Matrices
static std::string lookupFailureHint(DirectType direct)
Abstract base class of creators that can be registered at the pluggable factory.
The Mumps struct provides output information specific to MUMPS.
int zeroPivots
number of zero eigenvalues (if inertia detection for symmetric matrix was enabled)
int negativePivots
number of negative eigenvalues (if inertia detection for symmetric matrix was enabled)
The Info struct provides output information of direct solvers.
struct Kaskade::Factorization::Info::Mumps mumps
The Options struct allows to specify several options of factorization.
int verbosity
How detailed information should be reported.