13#ifndef FACTORIZATION_HH
14#define FACTORIZATION_HH
21#include <dune/grid/config.h>
24#include "dune/istl/bcrsmatrix.hh"
41template <
class Scalar>
77 virtual void solve(std::vector<field_type>& b)
const
79 assert(b.size() >=
size());
95 virtual void solve(std::vector<Scalar>
const& b, std::vector<Scalar>& x,
bool transposed=
false)
const
97 assert(b.size() >=
size());
98 if (x.size() <
size())
123 virtual size_t size()
const = 0;
139template <
class Scalar,
class Index>
142 std::vector<Index>
const& ridx,
143 std::vector<Index>
const& cidx,
144 std::vector<Scalar>
const& values,
145 std::vector<Index>& Ap, std::vector<Index>& Ai,
146 std::vector<Scalar>& Az);
156template <
class Scalar>
161 using Matrices = std::variant<MatrixAsTriplet<Scalar,int>
const*,
170 using Argument = std::tuple<Matrices, FactorizationOptions>;
183 std::ostringstream hint;
184 hint <<
"Solver key " << direct <<
" not registered.\n"
185 <<
"Has the corresponding object file been linked in?\n"
186 <<
"Did you specify the right index type (int/long/unsigned long) in your matrix?\n";
198template <
class Scalar,
class Index>
210 Argument args{Matrices(&A),options};
222template <
class Scalar>
223std::unique_ptr<Factorization<Scalar>>
236template <
class Scalar,
int n,
int m,
class Index>
237std::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 .
FactorizationOptions Options
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
The argument type passed to factorization creators.
std::variant< MatrixAsTriplet< Scalar, int > const *, MatrixAsTriplet< Scalar, long > const *, MatrixAsTriplet< Scalar, unsigned long > const * > Matrices
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.
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.