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);
43 const bool is_symmetric)
52 const std::vector<size_type> &row_lengths,
53 const bool is_symmetric)
60 template <
typename SparsityPatternType>
62 const bool preset_nonzero_locations)
64 do_reinit(sparsity_pattern, preset_nonzero_locations);
82 const bool is_symmetric)
97 const std::vector<size_type> &row_lengths,
98 const bool is_symmetric)
110 template <
typename SparsityPatternType>
113 const bool preset_nonzero_locations)
120 do_reinit(sparsity_pattern, preset_nonzero_locations);
129 const PetscErrorCode ierr =
130 PetscObjectGetComm(
reinterpret_cast<PetscObject
>(
matrix), &
comm);
141 const bool is_symmetric)
146 const PetscErrorCode ierr = MatCreateSeqAIJ(
147 PETSC_COMM_SELF,
m,
n, n_nonzero_per_row,
nullptr, &
matrix);
162 const std::vector<size_type> &row_lengths,
163 const bool is_symmetric)
165 Assert(row_lengths.size() ==
m,
176 const std::vector<PetscInt> int_row_lengths(row_lengths.begin(),
179 const PetscErrorCode ierr = MatCreateSeqAIJ(
180 PETSC_COMM_SELF,
m,
n, 0, int_row_lengths.data(), &
matrix);
192 template <
typename SparsityPatternType>
195 const bool preset_nonzero_locations)
197 std::vector<size_type> row_lengths(sparsity_pattern.n_rows());
198 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
199 row_lengths[i] = sparsity_pattern.row_length(i);
202 sparsity_pattern.n_cols(),
219 if (preset_nonzero_locations ==
true)
221 std::vector<PetscInt> row_entries;
222 std::vector<PetscScalar> row_values;
223 for (
size_type i = 0; i < sparsity_pattern.n_rows(); ++i)
225 row_entries.resize(row_lengths[i]);
226 row_values.resize(row_lengths[i], 0.0);
227 for (
size_type j = 0; j < row_lengths[i]; ++j)
228 row_entries[j] = sparsity_pattern.column_number(i, j);
230 const PetscInt int_row = i;
231 const PetscErrorCode ierr = MatSetValues(
matrix,
251 const PetscErrorCode ierr = MatGetSize(
matrix, &
m, &
n);
261 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)
virtual const MPI_Comm & get_mpi_communicator() const override
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)
PetscErrorCode destroy_matrix(Mat &matrix)
void close_matrix(Mat &matrix)
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
*braid_SplitCommworld & comm