18#ifdef DEAL_II_WITH_PETSC
32 const int m = 0,
n = 0, n_nonzero_per_row = 0;
33 const PetscErrorCode ierr = MatCreateSeqAIJ(
34 PETSC_COMM_SELF,
m,
n, n_nonzero_per_row,
nullptr, &
matrix);
45 const bool is_symmetric)
54 const std::vector<size_type> &row_lengths,
55 const bool is_symmetric)
62 template <
typename SparsityPatternType>
64 const bool preset_nonzero_locations)
66 do_reinit(sparsity_pattern, preset_nonzero_locations);
84 const bool is_symmetric)
88 const PetscErrorCode ierr = MatDestroy(&
matrix);
99 const std::vector<size_type> &row_lengths,
100 const bool is_symmetric)
104 const PetscErrorCode ierr = MatDestroy(&
matrix);
112 template <
typename SparsityPatternType>
115 const bool preset_nonzero_locations)
119 const PetscErrorCode ierr = MatDestroy(&
matrix);
122 do_reinit(sparsity_pattern, preset_nonzero_locations);
131 const bool is_symmetric)
136 const PetscErrorCode ierr = MatCreateSeqAIJ(
137 PETSC_COMM_SELF,
m,
n, n_nonzero_per_row,
nullptr, &
matrix);
152 const std::vector<size_type> &row_lengths,
153 const bool is_symmetric)
155 Assert(row_lengths.size() ==
m,
166 const std::vector<PetscInt> int_row_lengths(row_lengths.begin(),
169 const PetscErrorCode ierr = MatCreateSeqAIJ(
170 PETSC_COMM_SELF,
m,
n, 0, int_row_lengths.data(), &
matrix);
182 template <
typename SparsityPatternType>
185 const bool preset_nonzero_locations)
187 std::vector<size_type> row_lengths(sparsity_pattern.n_rows());
188 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
189 row_lengths[i] = sparsity_pattern.row_length(i);
192 sparsity_pattern.n_cols(),
209 if (preset_nonzero_locations ==
true)
211 std::vector<PetscInt> row_entries;
212 std::vector<PetscScalar> row_values;
213 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
215 row_entries.resize(row_lengths[i]);
216 row_values.resize(row_lengths[i], 0.0);
217 for (
size_type j = 0; j < row_lengths[i]; ++j)
218 row_entries[j] = sparsity_pattern.column_number(i, j);
220 const PetscInt int_row = i;
221 const PetscErrorCode ierr = MatSetValues(
matrix,
241 const PetscErrorCode ierr = MatGetSize(
matrix, &
m, &
n);
251 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)