10#include <kernel/solver/base.hpp>
11#include <kernel/lafem/saddle_point_matrix.hpp>
12#include <kernel/lafem/sparse_matrix_bcsr.hpp>
13#include <kernel/lafem/sparse_matrix_csr.hpp>
14#include <kernel/lafem/mean_filter.hpp>
15#include <kernel/lafem/tuple_vector.hpp>
16#include <kernel/lafem/dense_vector.hpp>
17#include <kernel/lafem/dense_vector_blocked.hpp>
23#if defined(FEAT_HAVE_UMFPACK) || defined(DOXYGEN)
41 public SolverBase<LAFEM::DenseVector<double, Index>>
118 return std::make_shared<Umfpack>(matrix);
141 public SolverBase<LAFEM::DenseVector<double, Index>>
188 UmfpackMean(system_matrix, mean_filter.get_vec_dual())
195 return "UmfpackMean";
232 return std::make_shared<UmfpackMean>(matrix, weight_vector);
251 return std::make_shared<UmfpackMean>(matrix, filter);
275 template<
typename DT_,
typename IT_,
int dim_>
277 public SolverBase<LAFEM::TupleVector<LAFEM::DenseVectorBlocked<DT_, IT_, dim_>, LAFEM::DenseVector<DT_, IT_>>>
346 return "SaddleUmfpackMean";
390 orow_ptr[0] =
Index(0);
392 for(
Index i(0); i < n_v; ++i)
398 Index op = orow_ptr[id];
400 for(
Index ip(irow_ptr_a[i]); ip < irow_ptr_a[i+1]; ++ip)
404 ocol_idx[op] =
Index(icol_idx_a[ip])*
Index(dim_) + k;
407 for(
Index ip(irow_ptr_b[i]); ip < irow_ptr_b[i+1]; ++ip, ++op)
408 ocol_idx[op] = n_v*
Index(dim_) +
Index(icol_idx_b[ip]);
414 for(
Index i(0); i < n_p; ++i)
418 for(
Index ip(irow_ptr_d[i]); ip < irow_ptr_d[i+1]; ++ip)
422 ocol_idx[op] =
Index(icol_idx_d[ip])*
Index(dim_) + k;
425 ocol_idx[op] =
Index(dim_)*n_v + n_p;
427 orow_ptr[
Index(dim_)*n_v+i+1] = ++op;
432 for(
Index j(0); j < n_p; ++j, ++op)
434 ocol_idx[op] =
Index(dim_)*n_v + j;
437 orow_ptr[
Index(dim_)*n_v+n_p+1] = op;
474 const auto idata_a = matrix_a.val_view_r();
476 const auto idata_b = matrix_b.val_view_r();
478 const auto idata_d = matrix_d.val_view_r();
488 for(
Index i(0); i < n_v; ++i)
492 for(
int j(0); j < dim_; ++j, ++id)
494 Index op = orow_ptr[id];
496 for(
Index ip(irow_ptr_a[i]); ip < irow_ptr_a[i+1]; ++ip)
498 for(
int k(0); k < dim_; ++k, ++op)
499 odata[op] =
double(idata_a[ip][j][k]);
502 for(
Index ip(irow_ptr_b[i]); ip < irow_ptr_b[i+1]; ++ip, ++op)
503 odata[op] =
double(idata_b[ip][j][0]);
507 for(
Index i(0); i < n_p; ++i)
511 for(
Index ip(irow_ptr_d[i]); ip < irow_ptr_d[i+1]; ++ip)
514 for(
int k(0); k < dim_; ++k, ++op)
515 odata[op] =
double(idata_d[ip][0][k]);
518 odata[op] = double(weight[i]);
523 for(
Index j(0); j < n_p; ++j, ++op)
525 odata[op] = double(weight[j]);
554 const Index n_p = vec_sol.template at<1>().
size();
561 double *vb = vvb.
get_w();
564 for(
Index i(0); i < n_v; ++i, ++vb)
565 *vb =
double(vr_v[i]);
567 for(
Index i(0); i < n_p; ++i, ++vb)
568 *vb =
double(vr_p[i]);
581 const double* vx = vvx.
get_r();
584 for(
Index i(0); i < n_v; ++i, ++vx)
587 for(
Index i(0); i < n_p; ++i, ++vx)
608 template<
typename DT_,
typename IT_,
int dim_>
616 return std::make_shared<SaddleUmfpackMean<DT_, IT_, dim_>>(matrix, weight_vector);
631 template<
typename DT_,
typename IT_,
int dim_>
639 return std::make_shared<SaddleUmfpackMean<DT_, IT_, dim_>>(matrix, filter);
653 template<
typename Matrix_>
655 public SolverBase<typename Matrix_::VectorTypeL>
677 void _copy_matrix_vals(
const MatrixType& matrix)
680 typename MatrixType::template ContainerType<double, Index> mat_double;
681 mat_double.convert(matrix);
689 mat_double.get_row_values(i, &val.
get_w()[row_ptr[i]]);
692 template<
typename IT2_>
698 _copy_matrix_vals(matrix);
701 template<
typename MT_>
702 void _copy_matrix_values(
const MT_& matrix)
704 _copy_matrix_vals(matrix);
708 explicit GenericUmfpack(
const MatrixType& matrix) :
722 return "GenericUmfpack";
730 typename MatrixType::template ContainerType<double, Index> mat_double;
782 _tmp_vrhs.
copy(vec_rhs);
805 template<
typename Matrix_>
808 return std::make_shared<GenericUmfpack<Matrix_>> (matrix);
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
virtual void clear()
Free all allocated arrays.
Blocked Dense data vector class template.
Dense data vector class template.
void convert(const DenseVector< DT2_, IT2_ > &other)
Conversion method.
void copy_to(VT_ &a) const
Performs .
void copy(const VT_ &a)
Performs .
Index size() const
Returns the size of this vector, i.e. its number of entries.
Mean Filter class template.
Saddle-Point matrix meta class template.
MatrixTypeA & block_a()
Returns the sub-matrix block A.
MatrixTypeB & block_b()
Returns the sub-matrix block B.
MatrixTypeD & block_d()
Returns the sub-matrix block D.
CSR based blocked sparse matrix.
Index num_rows() const
Retrieve matrix row count.
Index num_nzes() const
Retrieve non zero element count.
Index num_cols() const
Retrieve matrix column count.
VectorTypeR create_vector_r() const
Returns a new compatible R-Vector.
void convert(const SparseMatrixCSR< DT2_, IT2_ > &other)
Conversion method.
Memory::Arbiter & val_arbiter()
Returns a reference to the values array arbiter.
Index num_rows() const
Retrieve matrix row count.
VectorTypeL create_vector_l() const
Returns a new compatible L-Vector.
Variadic TupleVector class template.
Index size() const
Returns the total size of this tuple-vector.
const T_ * get_r() const
Returns a const typed pointer to the array that grants read access.
T_ * get_w()
Returns a typed pointer to the array that grants write (and read) access.
Generic UMFPACK solver class.
virtual ~GenericUmfpack()
virtual destructor
Umfpack::MatrixType _umf_matrix
the matrix for our Umfpack solver (SparseMatrixCSR<double, Index>)
LAFEM::DenseVector< typename VectorType::DataType, typename VectorType::IndexType > _tmp_vsol
temporary vectors for datatype conversion
virtual void init_numeric() override
Numeric initialization method.
Matrix_ MatrixType
our matrix type
SolverBase< typename Matrix_::VectorTypeL > BaseClass
our base class
virtual String name() const override
Returns the name of the solver.
virtual void done_symbolic() override
Symbolic finalization method.
const MatrixType & _matrix
our matrix
Umfpack::VectorType _umf_vsol
the vectors for our Umfpack solver (DenseVector<double, Index>)
virtual void done_numeric() override
Numeric finalization method.
Umfpack _umfpack
the actual Umfpack solver object
virtual void init_symbolic() override
Symbolic initialization method.
MatrixType::VectorTypeL VectorType
our vector type
UMFPACK Saddle-Point Mean solver class.
virtual void init_numeric() override
Numeric initialization method.
UmfMatrixType _solver_matrix
our extended system matrix
SaddleUmfpackMean(const MatrixType &system_matrix, const VectorTypeP &weight_vector)
Constructor.
UmfVectorType _vec_x
two temporary extended vectors
Umfpack _umfpack
our internal Umfpack solver object
LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, dim_ > MatrixTypeA
compatible matrix type
SaddleUmfpackMean(const MatrixType &system_matrix, const LAFEM::MeanFilter< DT_, IT_ > &mean_filter)
Constructor.
SolverBase< VectorType > BaseClass
our base class
const VectorTypeP & _weight_vector
weight vector from mean filter
virtual void init_symbolic() override
Symbolic initialization method.
virtual String name() const override
Returns the name of the solver.
const MatrixType & _system_matrix
system matrix
virtual void done_symbolic() override
Symbolic finalization method.
virtual void done_numeric() override
Numeric finalization method.
LAFEM::DenseVectorBlocked< DT_, IT_, dim_ > VectorTypeV
compatible vector type
virtual Status apply(VectorType &vec_sol, const VectorType &vec_rhs) override
Solves a linear system with the factorized system matrix.
Polymorphic solver interface.
virtual void init_symbolic()
Symbolic initialization method.
virtual void init_numeric()
Numeric initialization method.
virtual void done_symbolic()
Symbolic finalization method.
virtual void done_numeric()
Numeric finalization method.
std::size_t _sym_mem_size
symbolic factorization memory size
virtual void init_symbolic() override
Symbolic initialization method.
virtual ~Umfpack()
virtual destructor
void * _umf_numeric
umfpack numeric factorization pointer
LAFEM::SparseMatrixCSR< double, Index > MatrixType
compatible matrix type
std::size_t _umf_peak_size
total peak memory size
const MatrixType & _system_matrix
system matrix
std::size_t _sym_peak_size
symbolic peak memory size
double * _umf_control
umfpack control array
LAFEM::DenseVector< double, Index > VectorType
compatible vector type
void * _umf_symbolic
umfpack symbolic factorization pointer
Umfpack(const MatrixType &system_matrix)
Constructor.
virtual String name() const override
Returns the name of the solver.
virtual void done_numeric() override
Numeric finalization method.
std::size_t _num_mem_size
numeric factorization memory size
SolverBase< VectorType > BaseClass
our base class
virtual void init_numeric() override
Numeric initialization method.
virtual void done_symbolic() override
Symbolic finalization method.
virtual Status apply(VectorType &vec_sol, const VectorType &vec_rhs) override
Solves a linear system with the factorized system matrix.
UMFPACK Mean solver class.
virtual Status apply(VectorType &vec_sol, const VectorType &vec_rhs) override
Solves a linear system with the factorized system matrix.
virtual void done_symbolic() override
Symbolic finalization method.
UmfpackMean(const MatrixType &system_matrix, const LAFEM::MeanFilter< double, Index > &mean_filter)
Constructor.
const MatrixType & _system_matrix
system matrix
virtual String name() const override
Returns the name of the solver.
SolverBase< VectorType > BaseClass
our base class
MatrixType _solver_matrix
our extended system matrix
virtual void done_numeric() override
Numeric finalization method.
VectorType _vec_x
two temporary extended vectors
UmfpackMean(const MatrixType &system_matrix, const VectorType &weight_vector)
Constructor.
virtual void init_numeric() override
Numeric initialization method.
const VectorType & _weight_vector
weight vector
Umfpack _umfpack
our internal Umfpack solver object
LAFEM::DenseVector< double, Index > VectorType
compatible vector type
virtual void init_symbolic() override
Symbolic initialization method.
LAFEM::SparseMatrixCSR< double, Index > MatrixType
compatible matrix type
String class implementation.
std::shared_ptr< UmfpackMean > new_umfpack_mean(const LAFEM::SparseMatrixCSR< double, Index > &matrix, const LAFEM::DenseVector< double, Index > &weight_vector)
Creates a new UmfpackMean solver object.
Status
Solver status return codes enumeration.
std::shared_ptr< SaddleUmfpackMean< DT_, IT_, dim_ > > new_saddle_umfpack_mean(const LAFEM::SaddlePointMatrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, dim_ >, LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ > > &matrix, const LAFEM::DenseVector< DT_, IT_ > &weight_vector)
Creates a new UmfpackMean solver object.
std::shared_ptr< GenericUmfpack< Matrix_ > > new_generic_umfpack(const Matrix_ &matrix)
Creates a new GenericUmfpack solver object.
std::shared_ptr< Umfpack > new_umfpack(const LAFEM::SparseMatrixCSR< double, Index > &matrix)
Creates a new Umfpack solver object.
std::uint64_t Index
Index data type.