19#ifdef DEAL_II_WITH_PSBLAS
20# include <psb_base_cbind.h>
21# include <psb_c_base.h>
22# include <psb_c_dbase.h>
30 : psblas_vector(nullptr)
32 , psblas_descriptor(nullptr)
33 , communicator(MPI_COMM_NULL)
37 , remote_entries_pending(false)
92 const bool omit_zeroing_entries)
95 ExcMessage(
"MPI_COMM_NULL passed to Vector::reinit()."));
101 const bool partitioning_changes_locally =
110 const bool partitioning_will_change =
120 if (partitioning_will_change ==
true)
126 const std::vector<types::global_dof_index> &indexes =
129 const auto number_of_local_indexes =
132 std::vector<psb_l_t> vl(number_of_local_indexes);
133 for (std::size_t i = 0; i < number_of_local_indexes; ++i)
135 const auto psblas_index =
static_cast<psb_l_t
>(indexes[i]);
137 vl[i] = psblas_index;
142 ierr = psb_c_cdall_vl(number_of_local_indexes,
160 if (omit_zeroing_entries ==
false)
180 ExcMessage(
"MPI_COMM_NULL passed to Vector::reinit()."));
182 IndexSet new_ghost_indices = ghosts;
189 const bool partitioning_changes_locally =
199 const bool partitioning_will_change =
210 if (partitioning_will_change ==
true)
216 const std::vector<types::global_dof_index> &indexes =
219 const auto number_of_local_indexes =
222 std::vector<psb_l_t> vl(number_of_local_indexes);
223 std::vector<psb_i_t> lidx(number_of_local_indexes);
224 for (std::size_t i = 0; i < number_of_local_indexes; ++i)
226 const auto psblas_index =
static_cast<psb_l_t
>(indexes[i]);
227 const auto idx =
static_cast<psb_i_t
>(i);
230 vl[i] = psblas_index;
242 ierr = psb_c_cdall_vl_lidx(number_of_local_indexes,
251 const std::vector<types::global_dof_index> &ghost_indexes =
253 const auto number_of_ghost_indices = ghost_indexes.size();
255 std::vector<psb_l_t> global_ghost_indices(number_of_ghost_indices);
256 std::vector<psb_i_t> local_ghost_indices(number_of_ghost_indices);
258 psb_i_t extended_idx_counter = number_of_local_indexes;
259 for (std::size_t i = 0; i < number_of_ghost_indices; ++i)
261 const auto psblas_index =
static_cast<psb_l_t
>(ghost_indexes[i]);
263 global_ghost_indices[i] = psblas_index;
264 const auto idx =
static_cast<psb_i_t
>(extended_idx_counter);
266 local_ghost_indices[i] = extended_idx_counter++;
270 ierr = psb_c_cdins_lidx(number_of_ghost_indices,
271 global_ghost_indices.data(),
272 local_ghost_indices.data(),
319 if (!omit_zeroing_entries)
330 omit_zeroing_entries);
486 for (
const value_type *ptr = start_ptr; ptr != end_ptr; ++ptr)
487 local_sum_of_values += *ptr;
500 Assert(start_ptr !=
nullptr,
501 ExcMessage(
"Error getting underlying PSBLAS vector."));
503 const bool has_nonzero_local =
504 std::any_of(start_ptr,
508 unsigned int num_nonzero =
510 return num_nonzero == 0;
523 int ierr = psb_c_dgeaxpby(
581 const std::vector<Vector::value_type> &values)
589 for (std::size_t i = 0; i < indices.size(); ++i)
592 ExcMessage(
"You are trying to write to an element of the vector "
593 "that is not locally owned. This is not allowed for "
594 "the current interface to PSBLAS vectors."));
603 const std::vector<Vector::value_type> &values)
607 Assert(indices.size() == values.size(),
608 ExcMessage(
"Indices and values size mismatch."));
614 std::vector<psb_l_t> irw;
615 std::vector<psb_d_t> val;
617 for (std::size_t i = 0; i < indices.size(); ++i)
622 const auto psblas_index =
static_cast<psb_l_t
>(indices[i]);
624 irw.push_back(psblas_index);
625 val.push_back(values[i]);
628 if (irw.empty() ==
false)
630 const auto nz =
static_cast<psb_i_t
>(irw.size());
633 const int ierr = psb_c_dgeins(
648 int ierr = psb_c_dgeaxpby(s,
665 while (start_ptr != end_ptr)
693 int ierr = psb_c_dgeaxpby(
707 while (start_ptr != end_ptr)
709 *start_ptr *= (*start_ptr_v);
754 ExcMessage(
"Calling compress() is only useful if a vector "
755 "has been written into, but this is a vector with ghost "
756 "elements and consequently is read-only. It does "
757 "not make sense to call compress() for such "
766 "Missing compress() or calling with wrong VectorOperation argument."));
799 const std::vector<types::global_dof_index> &indices =
804 std::vector<psb_l_t> irw(indices.size());
805 std::vector<psb_d_t> val(indices.size());
806 for (std::size_t i = 0; i < indices.size(); ++i)
808 const auto psblas_index =
static_cast<psb_l_t
>(indices[i]);
810 irw[i] = psblas_index;
811 val[i] = local_values[i];
814 const auto nz =
static_cast<psb_i_t
>(irw.size());
size_type index_within_set(const size_type global_index) const
size_type n_elements() const
bool is_element(const size_type index) const
void set_size(const size_type size)
void subtract_set(const IndexSet &other)
std::vector< size_type > get_index_vector() const
static psb_c_ctxt * get_psblas_context()
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertIntegerConversion(index1, index2)
static ::ExceptionBase & ExcCallingPSBLASFunction(int arg1, std::string arg2)
static ::ExceptionBase & ExcAssemblePSBLASDescriptor(int arg1)
static ::ExceptionBase & ExcInitializePSBLASVector(int arg1)
static ::ExceptionBase & ExcGhostsPresent()
static ::ExceptionBase & ExcAssemblePSBLASVector(int arg1)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcAXPBY(int arg1)
static ::ExceptionBase & ExcInitializePSBLASDescriptor(int arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcWrongMode(int arg1, int arg2)
static ::ExceptionBase & ExcFreePSBLASVector(int arg1)
#define AssertIsFinite(number)
#define AssertDimension(dim1, dim2)
#define AssertNothrow(cond, exc)
static ::ExceptionBase & ExcInvalidDefault()
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcInvalidStateAssembled(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInsertionInPSBLASVector(int arg1)
#define AssertThrow(cond, exc)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
T sum(const T &t, const MPI_Comm mpi_communicator)
T logical_or(const T &t, const MPI_Comm mpi_communicator)