9#include <kernel/solver/base.hpp>
10#include <kernel/global/alg_dof_parti_system.hpp>
11#include <kernel/global/matrix.hpp>
12#include <kernel/global/filter.hpp>
13#include <kernel/global/vector.hpp>
14#include <kernel/global/pmdcdsc_matrix.hpp>
44 template<
typename Matrix_,
typename Filter_,
typename SolverBase_ = Solver::SolverBase<
typename Matrix_::VectorTypeL>>
53 explicit ADPSolverBase(
const GlobalMatrixType& matrix,
const GlobalFilterType& filter);
96 template<
typename RPT_,
typename CIT_>
114 template<
typename DTV_,
typename RPT_,
typename CIT_>
127 template<
typename DTV_>
141 template<
typename DTV_>
161 template<
typename LocalMatrix_,
typename Mirror_,
typename LocalFilter_,
typename SolverBase_>
236 return this->_system_matrix.
get_comm();
248 BaseClass::init_symbolic();
251 this->_adp_system = std::make_shared<AlgDofPartiSystemType>(this->_system_matrix, this->_system_filter);
252 this->_adp_system->init_symbolic();
264 BaseClass::done_symbolic();
271 return this->_adp_system->get_adp_vector_size();
277 return this->_adp_system->get_adp_matrix_rows();
283 return this->_adp_system->get_adp_matrix_cols();
289 return this->_adp_system->get_adp_matrix_nzes();
295 return this->_adp_system->get_num_global_nonzeros();
301 return this->_adp_system->get_num_global_dofs();
307 return this->_adp_system->get_num_owned_dofs();
313 return this->_adp_system->get_global_dof_offset();
319 return this->_adp_system->get_alg_dof_parti()->get_block_information();
333 template<
typename RPT_,
typename CIT_>
336 this->_adp_system->upload_matrix_symbolic(row_ptr, col_idx);
354 template<
typename DTV_,
typename RPT_,
typename CIT_>
357 this->_adp_system->upload_matrix_numeric(val, row_ptr, col_idx);
358 this->_adp_system->upload_filter();
359 this->_adp_system->filter_matrix(val, row_ptr, col_idx);
372 template<
typename DTV_>
375 this->_adp_system->upload_vector(val, vector.
local());
388 template<
typename DTV_>
391 this->_adp_system->upload_vector(val, vector);
405 template<
typename DTV_>
408 this->_adp_system->download_vector(vector.
local(), val);
422 template<
typename DTV_>
425 this->_adp_system->download_vector(vector, val);
449 template<
typename MatrixB_,
typename MatrixD_,
typename GlobalFilter_,
typename SolverBase_>
450 class ADPSolverBase<Global::PMDCDSCMatrix<MatrixB_, MatrixD_>, GlobalFilter_, SolverBase_> :
473 typedef typename LocalMatrixTypeS::DataType
DataType;
509 _global_dof_count(0),
510 _global_dof_offset(0),
521 return this->_system_matrix.get_comm();
532 BaseClass::init_symbolic();
535 _system_matrix.adp_compute_counts(_global_dof_offset, _global_dof_count, _owned_dof_count, _owned_num_nzes, _global_num_nzes);
560 return _owned_num_nzes;
566 return _global_num_nzes;
572 return _global_dof_count;
578 return _owned_dof_count;
584 return _global_dof_offset;
590 XABORTM(
"Block information for ADPSolverBase<PMDCDSCMatrix> not available yet!");
605 template<
typename RPT_,
typename CIT_>
608 _system_matrix.adp_upload_symbolic(row_ptr, col_idx, _global_dof_offset);
626 template<
typename DTV_,
typename RPT_,
typename CIT_>
630 this->
_filter_mat(val, row_ptr, col_idx, this->_system_filter.local());
643 template<
typename DTV_>
651 FEAT_PRAGMA_OMP(parallel
for)
652 for(
Index i = 0; i < n; ++i)
653 val[i] = DTV_(vx[i]);
667 template<
typename DTV_>
675 FEAT_PRAGMA_OMP(parallel
for)
676 for(
Index i = 0; i < n; ++i)
681 template<
typename DTV_,
typename RPT_,
typename CIT_>
689 template<
typename DTV_,
typename RPT_,
typename CIT_>
690 void _filter_mat(DTV_* val,
const RPT_* row_ptr,
const CIT_* col_idx,
693 const IndexType n = filter.used_elements();
694 const IndexType* fil_idx = filter.get_indices();
697 const Index row = fil_idx[i];
698 for(RPT_ j = row_ptr[row]; j < row_ptr[row+1]; ++j)
699 val[j] = DTV_(
Index(col_idx[j]) == row ? 1 : 0);
704 template<
typename DTV_,
typename RPT_,
typename CIT_>
708 XASSERTM(filter.empty(),
"LAFEM::MeanFilter is not supported by ADPSolverBase yet!");
712 template<
typename DTV_,
typename RPT_,
typename CIT_>
716 XASSERTM(filter.empty(),
"LAFEM::MeanFilter is not supported by ADPSolverBase yet!");
720 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename SubFilter_>
721 void _filter_mat(DTV_* val,
const RPT_* row_ptr,
const CIT_* col_idx,
724 for(
const auto& sf : filter)
725 this->
_filter_mat(val, row_ptr, col_idx, sf.second);
729 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename First_,
typename... Rest_>
730 void _filter_mat(DTV_* val,
const RPT_* row_ptr,
const CIT_* col_idx,
733 this->
_filter_mat(val, row_ptr, col_idx, filter.first());
734 this->
_filter_mat(val, row_ptr, col_idx, filter.rest());
738 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename First_>
739 void _filter_mat(DTV_* val,
const RPT_* row_ptr,
const CIT_* col_idx,
742 this->
_filter_mat(val, row_ptr, col_idx, filter.first());
764 template<
typename Matrix_,
typename Filter_,
typename SolverBase_>
765 class ADPSolverBase :
769 static_assert(Matrix_::is_local,
"invalid instantiation of ADPSolverBase for non-local matrix type!");
845 return _system_matrix.template used_elements<LAFEM::Perspective::pod>();
851 return _system_matrix.template used_elements<LAFEM::Perspective::pod>();
875 XABORTM(
"Block information for ADPSolverBase<...> not available yet!");
890 template<
typename RPT_,
typename CIT_>
894 row_ptr[0] = RPT_(0);
895 for(
Index i(0); i < num_rows; ++i)
897 row_ptr[i+1u] = row_ptr[i] + RPT_(
_system_matrix.get_row_col_indices(i, &col_idx[row_ptr[i]], CIT_(0)));
916 template<
typename DTV_,
typename RPT_,
typename CIT_>
920 for(
Index i(0); i < num_rows; ++i)
925 this->
_filter_mat(val, row_ptr, col_idx, this->_system_filter);
938 template<
typename DTV_>
955 template<
typename DTV_>
958 vector.set_vec_inv(val);
962 template<
typename DTV_,
typename RPT_,
typename CIT_>
970 template<
typename DTV_,
typename RPT_,
typename CIT_>
971 void _filter_mat(DTV_* val,
const RPT_* row_ptr,
const CIT_* col_idx,
974 const IndexType n = filter.used_elements();
975 const IndexType* fil_idx = filter.get_indices();
978 const Index row = fil_idx[i];
979 for(RPT_ j = row_ptr[row]; j < row_ptr[row+1]; ++j)
980 val[j] = DTV_(
Index(col_idx[j]) == row ? 1 : 0);
985 template<
typename DTV_,
typename RPT_,
typename CIT_>
989 XASSERTM(filter.empty(),
"LAFEM::MeanFilter is not supported by ADPSolverBase yet!");
993 template<
typename DTV_,
typename RPT_,
typename CIT_>
997 XASSERTM(filter.empty(),
"LAFEM::MeanFilter is not supported by ADPSolverBase yet!");
1001 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename SubFilter_>
1005 for(
const auto& sf : filter)
1006 this->
_filter_mat(val, row_ptr, col_idx, sf.second);
1010 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename First_,
typename... Rest_>
1014 this->
_filter_mat(val, row_ptr, col_idx, filter.first());
1015 this->
_filter_mat(val, row_ptr, col_idx, filter.rest());
1019 template<
typename DTV_,
typename RPT_,
typename CIT_,
typename First_>
1023 this->
_filter_mat(val, row_ptr, col_idx, filter.first());
#define XABORTM(msg)
Abortion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Algebraic DOF Partitioning implementation.
LocalVectorType::DataType DataType
our data type
LocalVectorType::IndexType IndexType
our index type
Algebraic DOF partitioning linear system conversion class.
Global Filter wrapper class template.
Global Matrix wrapper class template.
const Dist::Comm * get_comm() const
Returns a const pointer to the internal communicator of the gates of the matrix.
Mean Filter class template.
Pre-Multiplied Discontinuous Diagonal Schur-Complement Matrix.
Global vector wrapper class template.
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Index size() const
Returns the containers size.
Dense data vector class template.
DT_ * elements()
Get a pointer to the data array.
Filter Chainclass template.
Sequence of filters of the same type.
Mean Filter class template.
None Filter class template.
Unit Filter class template.
GlobalVectorType VectorType
the system vector type; coincides with the global vector type
virtual void init_symbolic() override
Symbolic initialization.
LAFEM::SparseMatrixCSR< DataType, IndexType > ADPMatrixType
the ADP matrix type; this is always a (globally partitioned) CSR matrix
SolverBase_ BaseClass
our base class
Index _get_adp_matrix_num_rows() const
Global::Vector< LocalVectorType, MirrorType > GlobalVectorType
the global vector type
LocalMatrix_ LocalMatrixType
the local matrix type
Index _get_num_owned_dofs() const
AlgDofPartiType::IndexType IndexType
our internal index type
AlgDofPartiType::DataType DataType
our internal data type
void _download_vector(GlobalVectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
Index _get_global_dof_offset() const
GlobalMatrixType MatrixType
the system matrix type; coincides with the global matrix type
Global::Filter< LocalFilterType, MirrorType > GlobalFilterType
the global filter type
void _upload_vector(DTV_ *val, const LocalVectorType &vector)
Uploads the ADP vector values to the given array.
String _get_adp_block_information() const
Global::Matrix< LocalMatrixType, MirrorType, MirrorType > GlobalMatrixType
the global matrix type
Index _get_num_global_dofs() const
LAFEM::DenseVector< DataType, IndexType > ADPVectorType
the ADP vector type; this is always a (globally partitioned) dense vector
Global::AlgDofParti< LocalVectorType, MirrorType > AlgDofPartiType
the algebraic dof partitioning instance for this class
void _upload_vector(DTV_ *val, const GlobalVectorType &vector)
Uploads the ADP vector values to the given array.
Index _get_num_global_nonzeros() const
Global::AlgDofPartiSystem< LocalMatrixType, LocalFilterType, MirrorType > AlgDofPartiSystemType
the algebraic dof partitioning system instance for this class
const GlobalFilterType & _system_filter
the global system filter
std::shared_ptr< AlgDofPartiSystemType > _adp_system
the algebraic DOF partitioning
ADPSolverBase(const GlobalMatrixType &matrix, const GlobalFilterType &filter)
protected constructor
Index _get_adp_vector_size() const
void _upload_numeric(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Uploads the (filtered) ADP matrix values to the given array.
Index _get_adp_matrix_num_cols() const
virtual void done_symbolic() override
Symbolic finalization.
LocalFilter_ LocalFilterType
the local filter type
Index _get_adp_matrix_num_nzes() const
void _upload_symbolic(RPT_ *row_ptr, CIT_ *col_idx)
Uploads the ADP matrix structure to the given arrays.
LocalMatrixType::VectorTypeL LocalVectorType
the local vector type
void _download_vector(LocalVectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
const Dist::Comm * _get_comm() const
Mirror_ MirrorType
the mirror type
GlobalFilterType FilterType
the system filter type; coincides with the global filter type
const GlobalMatrixType & _system_matrix
the global system matrix
LocalMatrixTypeS::IndexType IndexType
our internal index type
Index _get_adp_matrix_num_nzes() const
Index _owned_num_nzes
the number of owned non-zero entries
Index _get_adp_matrix_num_rows() const
GlobalMatrixType::VectorTypeL GlobalVectorType
the global vector type
Index _get_adp_vector_size() const
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterChain< First_ > &filter)
auxiliary function: filters the local ADP matrix
virtual void init_symbolic() override
Symbolic initialization.
const GlobalFilterType & _system_filter
the global system filter
Index _global_num_nzes
the number of global non-zero entries
Index _get_adp_matrix_num_cols() const
Global::PMDCDSCMatrix< MatrixB_, MatrixD_ > GlobalMatrixType
the global matrix type
void _upload_numeric(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Uploads the (filtered) ADP matrix values to the given array.
Index _get_num_owned_dofs() const
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const LAFEM::NoneFilter< DataType, IndexType > &)
auxiliary function: filters the local ADP matrix
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const LAFEM::MeanFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
Index _global_dof_offset
our global DOF offset
GlobalVectorType VectorType
the system vector type
void _download_vector(LAFEM::DenseVector< DataType, IndexType > &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::UnitFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
LocalMatrixTypeS::DataType DataType
our internal data type
Index _get_num_global_nonzeros() const
Index _global_dof_count
the total global DOF count
void _upload_symbolic(RPT_ *row_ptr, CIT_ *col_idx)
Uploads the ADP matrix structure to the given arrays.
SolverBase_ BaseClass
our base class
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterChain< First_, Rest_... > &filter)
auxiliary function: filters the local ADP matrix
void _upload_vector(DTV_ *val, const LAFEM::DenseVector< DataType, IndexType > &vector)
Uploads the ADP vector values to the given array.
GlobalMatrixType::LocalMatrixTypeS LocalMatrixTypeS
the local Schur-complement matrix type
GlobalFilter_ GlobalFilterType
the global filter type
ADPSolverBase(const GlobalMatrixType &matrix, const GlobalFilterType &filter)
protected constructor
const Dist::Comm * _get_comm() const
LocalMatrixTypeS::VectorTypeL LocalVectorType
our internal local vector type; always a DenseVector<DataType, IndexType>
String _get_adp_block_information() const
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const Global::MeanFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
Index _get_global_dof_offset() const
Index _owned_dof_count
the owned DOF count
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterSequence< SubFilter_ > &filter)
auxiliary function: filters the local ADP matrix
const GlobalMatrixType & _system_matrix
the global system matrix
Index _get_num_global_dofs() const
Base-Class for solvers based on Algebraic-DOF-Partitioning.
const Dist::Comm * _get_comm() const
const FilterType & _system_filter
the system filter
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterSequence< SubFilter_ > &filter)
auxiliary function: filters the local ADP matrix
Dist::Comm _comm_self
self-communicator object
ADPSolverBase(const GlobalMatrixType &matrix, const GlobalFilterType &filter)
constructor
Index _get_adp_matrix_num_cols() const
SolverBase_ BaseClass
our base class
void _upload_symbolic(RPT_ *row_ptr, CIT_ *col_idx)
Uploads the ADP matrix structure to the given arrays.
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterChain< First_ > &filter)
auxiliary function: filters the local ADP matrix
void _upload_vector(DTV_ *val, const VectorType &vector)
Uploads the ADP vector values to the given array.
Index _get_num_owned_dofs() const
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::FilterChain< First_, Rest_... > &filter)
auxiliary function: filters the local ADP matrix
Index _get_global_dof_offset() const
String _get_adp_block_information() const
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const LAFEM::MeanFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
MatrixType::IndexType IndexType
our internal index type
void _download_vector(LocalVectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
void _upload_vector(DTV_ *val, const LocalVectorType &vector)
Uploads the ADP vector values to the given array.
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const LAFEM::NoneFilter< DataType, IndexType > &)
auxiliary function: filters the local ADP matrix
Index _get_num_global_nonzeros() const
const MatrixType & _system_matrix
the system matrix
Index _get_adp_vector_size() const
MatrixType::VectorTypeL VectorType
the (local) vector type
Index _get_num_global_dofs() const
Filter_ FilterType
the (local) filter type
void _filter_mat(DTV_ *, const RPT_ *, const CIT_ *, const Global::MeanFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
ADPSolverBase(const MatrixType &matrix, const FilterType &filter)
protected constructor
void _download_vector(VectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
void _filter_mat(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LAFEM::UnitFilter< DataType, IndexType > &filter)
auxiliary function: filters the local ADP matrix
Index _get_adp_matrix_num_nzes() const
Index _get_adp_matrix_num_rows() const
Matrix_ MatrixType
this specialization expects a local matrix
MatrixType::DataType DataType
our internal data type
void _upload_numeric(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Uploads the (filtered) ADP matrix values to the given array.
String class implementation.
std::uint64_t Index
Index data type.