- /**
- * Destroy a PETSc matrix. This function wraps MatDestroy with a version
- * check (the signature of this function changed in PETSc 3.2.0).
- *
- * @warning Since the primary intent of this function is to enable RAII
- * semantics in the PETSc wrappers, this function will not throw an
- * exception if an error occurs, but instead just returns the error code
- * given by MatDestroy.
- */
- inline PetscErrorCode
- destroy_matrix(Mat &matrix)
- {
- // PETSc will check whether or not matrix is nullptr.
- return MatDestroy(&matrix);
- }
-
-
-
/**
* Destroy a Krylov Subspace (KSP) PETSc solver. This function wraps
* KSPDestroy with a version check (the signature of this function changed
{
// get rid of old matrix and generate a
// new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(m, n);
PetscErrorCode ierr =
PetscObjectReference(reinterpret_cast<PetscObject>(A));
AssertThrow(ierr == 0, ExcPETScError(ierr));
- destroy_matrix(matrix);
+ ierr = MatDestroy(&matrix);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
matrix = A;
}
MatrixBase::~MatrixBase()
{
- destroy_matrix(matrix);
+ PetscErrorCode ierr = MatDestroy(&matrix);
+ (void)ierr;
+ AssertNothrow(ierr == 0, ExcPETScError(ierr));
}
void
{
// destroy the matrix...
{
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
}
PETSC_DEFAULT,
&result.petsc_matrix());
AssertThrow(ierr == 0, ExcPETScError(ierr));
- ierr = PETScWrappers::destroy_matrix(tmp);
+ ierr = MatDestroy(&tmp);
AssertThrow(ierr == 0, ExcPETScError(ierr));
}
}
}
if (vmatrix != matrix)
{
- ierr = PETScWrappers::destroy_matrix(vmatrix);
+ ierr = MatDestroy(&vmatrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
}
AssertThrow(out.fail() == false, ExcIO());
const unsigned int local_columns)
{
// destroy the matrix and generate a new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(communicator, m, n, local_rows, local_columns);
local_columns_per_process.size()));
Assert(this_process < local_rows_per_process.size(), ExcInternalError());
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr != 0, ExcPETScError(ierr));
do_reinit(communicator,
void
MatrixFree::clear()
{
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
const int m = 0;
BlockSparseMatrix::~BlockSparseMatrix()
{
- PetscErrorCode ierr = destroy_matrix(petsc_nest_matrix);
+ PetscErrorCode ierr = MatDestroy(&petsc_nest_matrix);
(void)ierr;
AssertNothrow(ierr == 0, ExcPETScError(ierr));
}
MPI_Comm comm = PETSC_COMM_SELF;
- ierr = destroy_matrix(petsc_nest_matrix);
+ ierr = MatDestroy(&petsc_nest_matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
std::vector<Mat> psub_objects(m * n);
for (unsigned int r = 0; r < m; r++)
SparseMatrix::~SparseMatrix()
{
- destroy_matrix(matrix);
+ PetscErrorCode ierr = MatDestroy(&matrix);
+ (void)ierr;
+ AssertNothrow(ierr == 0, ExcPETScError(ierr));
}
if (&other == this)
return;
- PetscErrorCode ierr = destroy_matrix(matrix);
+ PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
ierr = MatDuplicate(other.matrix, MAT_DO_NOT_COPY_VALUES, &matrix);
const MPI_Comm & communicator)
{
// get rid of old matrix and generate a new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(communicator,
const bool preset_nonzero_locations)
{
// get rid of old matrix and generate a new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
const MPI_Comm & communicator)
{
// get rid of old matrix and generate a new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(communicator, local_rows, local_columns, sparsity_pattern);
{
// get rid of old matrix and generate a
// new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(m, n, n_nonzero_per_row, is_symmetric);
{
// get rid of old matrix and generate a
// new one
- const PetscErrorCode ierr = destroy_matrix(matrix);
+ const PetscErrorCode ierr = MatDestroy(&matrix);
AssertThrow(ierr == 0, ExcPETScError(ierr));
do_reinit(sparsity_pattern, preset_nonzero_locations);