29#ifdef DEAL_II_WITH_PSBLAS
37 : psblas_sparse_matrix(nullptr)
38 , psblas_descriptor(nullptr)
46 ExcMessage(
"PSBLAS matrix descriptor must not be initialized."));
49 ExcMessage(
"The given SparsityPattern is not valid."));
53 ExcMessage(
"MPI_COMM_NULL passed to SparseMatrix::reinit()."));
94 ExcMessage(
"An empty IndexSet has been given."));
97 ExcMessage(
"MPI_COMM_NULL passed to SparseMatrix::reinit()."));
113 const std::vector<types::global_dof_index> &indexes =
116 psb_i_t number_of_local_indexes = indexes.size();
119 std::vector<psb_l_t> vl(number_of_local_indexes);
120 for (psb_i_t i = 0; i < number_of_local_indexes; ++i)
122 const auto psblas_index =
static_cast<psb_l_t
>(indexes[i]);
124 vl[i] = psblas_index;
128 psb_c_cdall_vl(number_of_local_indexes,
151 ExcMessage(
"The given SparsityPattern is not valid."));
155 ExcMessage(
"MPI_COMM_NULL passed to SparseMatrix::reinit()."));
191 "SparsityPattern and IndexSet have different number of rows"));
212 "Each row has to be owned by exactly one owner (n_rows()=") +
213 std::to_string(sparsity_pattern.
n_rows()) +
214 " but sum(local_rows.n_elements())=" +
215 std::to_string(row_owners) +
")"));
225 const std::vector<types::global_dof_index> indexes =
227 const psb_i_t n_local =
static_cast<psb_i_t
>(indexes.size());
229 std::vector<psb_l_t> vl(n_local);
230 for (psb_i_t i = 0; i < n_local; ++i)
232 const auto idx =
static_cast<psb_l_t
>(indexes[i]);
237 psb_c_cdall_vl(n_local,
250 const psb_l_t local_row_start =
252 const psb_l_t local_row_end =
253 local_row_start +
static_cast<psb_l_t
>(local_rows.
n_elements());
256 for (psb_l_t i = local_row_start; i < local_row_end; ++i)
258 const auto row_length =
259 static_cast<psb_i_t
>(sparsity_pattern.
row_length(i));
263 std::vector<psb_l_t> irw(row_length, i);
264 std::vector<psb_l_t> icl(row_length);
268 sparsity_pattern.
begin(i);
269 p != sparsity_pattern.
end(i);
272 const auto col =
static_cast<psb_l_t
>(p->column());
277 err = psb_c_cdins(row_length,
309 std::pair<SparseMatrix::size_type, SparseMatrix::size_type>
312 std::vector<psb_l_t> local_indices(
local_size());
313 int err = psb_c_cd_get_global_indices(local_indices.data(),
320 return {local_indices[0], local_indices.back() + 1};
368 int err = psb_c_dspins(
379 const auto psblas_index_i =
static_cast<psb_l_t
>(i);
381 const auto psblas_index_j =
static_cast<psb_l_t
>(j);
440 ExcMessage(
"PSBLAS matrix has not been initialized."));
441 Assert(matrix.m() == indices.size(),
443 Assert(matrix.n() == indices.size(),
447 const unsigned int n_indices = indices.size();
448 psb_i_t nz = n_indices * n_indices;
451 std::vector<psb_l_t> irw(nz);
452 std::vector<psb_l_t> icl(nz);
453 std::vector<psb_d_t> val(nz);
454 for (
unsigned int i = 0; i < n_indices; ++i)
456 for (
unsigned int j = 0; j < n_indices; ++j)
458 const auto psblas_row_index =
static_cast<psb_l_t
>(indices[i]);
459 const auto psblas_col_index =
static_cast<psb_l_t
>(indices[j]);
462 irw[i * n_indices + j] = psblas_row_index;
463 icl[i * n_indices + j] = psblas_col_index;
464 val[i * n_indices + j] = matrix(i, j);
469 int err = psb_c_dspins(nz,
490 int info = psb_c_dspins(1 ,
504 const std::vector<SparseMatrix::size_type> &col_indices,
509 Assert(col_indices.size() == ncols,
512 add(row, ncols, col_indices.data(), values,
false,
false);
520 const std::vector<SparseMatrix::size_type> &col_indices,
521 const std::vector<SparseMatrix::value_type> &values,
525 Assert(col_indices.size() == ncols,
529 add(row, ncols, col_indices.data(), values.data(),
false,
false);
542 std::vector<psb_l_t> irw(ncols);
543 std::vector<psb_l_t> icl(ncols);
546 irw[i] =
static_cast<psb_l_t
>(row);
547 icl[i] =
static_cast<psb_l_t
>(col_indices[i]);
550 int info = psb_c_dspins(ncols ,
589 ExcMessage(
"PSBLAS matrix has not been initialized."));
591 ExcMessage(
"Source PSBLAS vector has not been initialized."));
594 ExcMessage(
"PSBLAS matrix has not been assembled."));
611 ExcMessage(
"PSBLAS matrix has not been initialized."));
613 ExcMessage(
"Source PSBLAS vector has not been initialized."));
616 ExcMessage(
"PSBLAS matrix has not been assembled."));
633 ExcMessage(
"PSBLAS matrix has not been initialized."));
635 ExcMessage(
"Source PSBLAS vector has not been initialized."));
638 ExcMessage(
"PSBLAS matrix has not been assembled."));
658 ExcMessage(
"PSBLAS matrix has not been initialized."));
660 ExcMessage(
"Source PSBLAS vector has not been initialized."));
663 ExcMessage(
"PSBLAS matrix has not been assembled."));
710 idx < local_indices.second;
size_type row_length(const size_type row) const
bool is_ascending_and_one_to_one(const MPI_Comm communicator) const
size_type n_elements() const
size_type nth_index_in_set(const size_type local_index) const
std::vector< size_type > get_index_vector() const
static psb_c_ctxt * get_psblas_context()
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define AssertIntegerConversion(index1, index2)
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcCallingPSBLASFunction(int arg1, std::string arg2)
static ::ExceptionBase & ExcAssemblePSBLASDescriptor(int arg1)
static ::ExceptionBase & ExcSourceEqualsDestination()
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcAssemblePSBLASMatrix(int arg1)
static ::ExceptionBase & ExcInsertionInPSBLASMatrix(int arg1)
#define Assert(cond, exc)
#define AssertIsFinite(number)
static ::ExceptionBase & ExcAllocationPSBLASMatrix(int arg1)
static ::ExceptionBase & ExcMatVecPSBLAS(int arg1)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNotQuadratic()
static ::ExceptionBase & ExcMessage(std::string arg1)
T sum(const T &t, const MPI_Comm mpi_communicator)