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";
 
  378        const IT_* irow_ptr_a = matrix_a.
row_ptr();
 
  379        const IT_* icol_idx_a = matrix_a.
col_ind();
 
  380        const IT_* irow_ptr_b = matrix_b.
row_ptr();
 
  381        const IT_* icol_idx_b = matrix_b.
col_ind();
 
  382        const IT_* irow_ptr_d = matrix_d.
row_ptr();
 
  383        const IT_* icol_idx_d = matrix_d.
col_ind();
 
  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;
 
  473        const IT_* irow_ptr_a = matrix_a.
row_ptr();
 
  474        const auto* idata_a   = matrix_a.
val();
 
  475        const IT_* irow_ptr_b = matrix_b.
row_ptr();
 
  476        const auto* idata_b   = matrix_b.
val();
 
  477        const IT_* irow_ptr_d = matrix_d.
row_ptr();
 
  478        const auto* idata_d   = matrix_d.
val();
 
  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();
 
  557        const DT_* vr_v = vec_rhs.template at<0>().template elements<LAFEM::Perspective::pod>();
 
  558        const DT_* vr_p = vec_rhs.template at<1>().elements();
 
  562        for(
Index i(0); i < n_v; ++i, ++vb)
 
  563          *vb = 
double(vr_v[i]);
 
  565        for(
Index i(0); i < n_p; ++i, ++vb)
 
  566          *vb = 
double(vr_p[i]);
 
  575        DT_* vs_v = vec_sol.template at<0>().template elements<LAFEM::Perspective::pod>();
 
  576        DT_* vs_p = vec_sol.template at<1>().elements();
 
  578        for(
Index i(0); i < n_v; ++i, ++vx)
 
  581        for(
Index i(0); i < n_p; ++i, ++vx)
 
  601    template<
typename DT_, 
typename IT_, 
int dim_>
 
  609      return std::make_shared<SaddleUmfpackMean<DT_, IT_, dim_>>(matrix, weight_vector);
 
  624    template<
typename DT_, 
typename IT_, 
int dim_>
 
  632      return std::make_shared<SaddleUmfpackMean<DT_, IT_, dim_>>(matrix, filter);
 
  646    template<
typename Matrix_>
 
  648      public SolverBase<typename Matrix_::VectorTypeL>
 
  685        return "GenericUmfpack";
 
  693        typename MatrixType::template ContainerType<double, Index> mat_double;
 
  730        typename MatrixType::template ContainerType<double, Index> mat_double;
 
  740          mat_double.set_line(i, val + row_ptr[i], col_idx + row_ptr[i], 0);
 
  755        _tmp_vrhs.
copy(vec_rhs);
 
  778    template<
typename Matrix_>
 
  781      return std::make_shared<GenericUmfpack<Matrix_>> (matrix);
 
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Index size() const
Returns the containers size.
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.
DT_ * elements()
Get a pointer to the data array.
void copy_inv(VT_ &a) const
Performs .
void copy(const VT_ &a)
Performs .
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 rows() const
Retrieve matrix row count.
IT_ * col_ind()
Retrieve column indices array.
IT_ * row_ptr()
Retrieve row start index array.
Index columns() const
Retrieve matrix column count.
Index used_elements() const
Retrieve non zero element count.
auto val() const -> const typename Intern::BCSRPerspectiveHelper< DT_, BlockHeight_, BlockWidth_, perspective_ >::Type *
Retrieve non zero element array.
VectorTypeR create_vector_r() const
Returns a new compatible R-Vector.
void convert(const SparseMatrixCSR< DT2_, IT2_ > &other)
Conversion method.
VectorTypeL create_vector_l() const
Returns a new compatible L-Vector.
IT_ * col_ind()
Retrieve column indices array.
DT_ * val()
Retrieve non zero element array.
Index rows() const
Retrieve matrix row count.
IT_ * row_ptr()
Retrieve row start index array.
Variadic TupleVector class template.
Index size() const
Returns the total size of this tuple-vector.
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.
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.
Status
Solver status return codes enumeration.
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.