From 8e50cb3342c6c2682e903bcdb40f6a833e9294a6 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Tue, 20 Dec 2022 18:54:13 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: David Wells --- include/deal.II/lac/petsc_matrix_base.h | 18 ++++++++++++++++-- source/lac/petsc_matrix_base.cc | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/deal.II/lac/petsc_matrix_base.h b/include/deal.II/lac/petsc_matrix_base.h index dea9e730cb..2fd3d37f0c 100644 --- a/include/deal.II/lac/petsc_matrix_base.h +++ b/include/deal.II/lac/petsc_matrix_base.h @@ -305,8 +305,22 @@ namespace PETScWrappers MatrixBase(); /** - * Initialize a Matrix from a PETSc Mat object. Note that we do not copy - * the matrix. + * Initialize a Matrix from a PETSc Mat object. Note that we do not copy the + * matrix. Any PETSc object (including the Mat type) is in fact a reference + * counted pointer. + * + * A reference counted pointer is a type of pointer that maintains a + * reference count for the object it points to. The reference count is + * incremented each time a new reference to the object is created, and + * decremented each time a reference is destroyed. When the reference count + * reaches zero, the object is automatically deleted, freeing up the memory + * it was using. + * + * In the context of PETSc, reference counted pointers are used to manage + * the memory of objects such as vectors, matrices, and solvers. By using + * reference counted pointers, PETSc ensures that memory is automatically + * released when it is no longer needed, without the need for explicit + * memory management. */ explicit MatrixBase(const Mat &); diff --git a/source/lac/petsc_matrix_base.cc b/source/lac/petsc_matrix_base.cc index 185fbf9997..72e0217b97 100644 --- a/source/lac/petsc_matrix_base.cc +++ b/source/lac/petsc_matrix_base.cc @@ -86,8 +86,7 @@ namespace PETScWrappers { const PetscErrorCode ierr = PetscObjectReference(reinterpret_cast(matrix)); - AssertNothrow(ierr == 0, ExcPETScError(ierr)); - (void)ierr; + AssertThrow(ierr == 0, ExcPETScError(ierr)); } -- 2.39.5