17#ifdef DEAL_II_WITH_PETSC
31 const int m = 0,
n = 0, n_nonzero_per_row = 0;
32 const PetscErrorCode ierr = MatCreateSeqAIJ(
33 PETSC_COMM_SELF,
m,
n, n_nonzero_per_row,
nullptr, &
matrix);
44 const bool is_symmetric)
53 const std::vector<size_type> &row_lengths,
54 const bool is_symmetric)
61 template <
typename SparsityPatternType>
63 const bool preset_nonzero_locations)
65 do_reinit(sparsity_pattern, preset_nonzero_locations);
83 const bool is_symmetric)
87 const PetscErrorCode ierr = MatDestroy(&
matrix);
98 const std::vector<size_type> &row_lengths,
99 const bool is_symmetric)
103 const PetscErrorCode ierr = MatDestroy(&
matrix);
111 template <
typename SparsityPatternType>
114 const bool preset_nonzero_locations)
118 const PetscErrorCode ierr = MatDestroy(&
matrix);
121 do_reinit(sparsity_pattern, preset_nonzero_locations);
130 const bool is_symmetric)
135 const PetscErrorCode ierr = MatCreateSeqAIJ(
136 PETSC_COMM_SELF,
m,
n, n_nonzero_per_row,
nullptr, &
matrix);
151 const std::vector<size_type> &row_lengths,
152 const bool is_symmetric)
154 Assert(row_lengths.size() ==
m,
165 const std::vector<PetscInt> int_row_lengths(row_lengths.begin(),
168 const PetscErrorCode ierr = MatCreateSeqAIJ(
169 PETSC_COMM_SELF,
m,
n, 0, int_row_lengths.data(), &
matrix);
181 template <
typename SparsityPatternType>
184 const bool preset_nonzero_locations)
186 std::vector<size_type> row_lengths(sparsity_pattern.n_rows());
187 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
188 row_lengths[i] = sparsity_pattern.row_length(i);
191 sparsity_pattern.n_cols(),
208 if (preset_nonzero_locations ==
true)
210 std::vector<PetscInt> row_entries;
211 std::vector<PetscScalar> row_values;
212 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
214 row_entries.resize(row_lengths[i]);
215 row_values.resize(row_lengths[i], 0.0);
216 for (
size_type j = 0; j < row_lengths[i]; ++j)
217 row_entries[j] = sparsity_pattern.column_number(i, j);
219 const PetscInt int_row = i;
220 const PetscErrorCode ierr = MatSetValues(
matrix,
240 const PetscErrorCode ierr = MatGetSize(
matrix, &
m, &
n);
250 const PetscErrorCode ierr = MatGetSize(
matrix, &
m, &
n);
void mmult(MatrixBase &C, const MatrixBase &B, const VectorBase &V) const
PetscBool is_symmetric(const double tolerance=1.e-12)
MatrixBase & operator=(const MatrixBase &)=delete
void Tmmult(MatrixBase &C, const MatrixBase &B, const VectorBase &V) const
void compress(const VectorOperation::values operation)
void mmult(SparseMatrix &C, const SparseMatrix &B, const MPI::Vector &V=MPI::Vector()) const
void do_reinit(const size_type m, const size_type n, const size_type n_nonzero_per_row, const bool is_symmetric=false)
void Tmmult(SparseMatrix &C, const SparseMatrix &B, const MPI::Vector &V=MPI::Vector()) const
void reinit(const size_type m, const size_type n, const size_type n_nonzero_per_row, const bool is_symmetric=false)
SparseMatrix & operator=(const double d)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define AssertThrow(cond, exc)
void set_keep_zero_rows(Mat &matrix)
void set_matrix_option(Mat &matrix, const MatOption option_name, const PetscBool option_value=PETSC_FALSE)
void close_matrix(Mat &matrix)