66
77namespace Rodin ::Math
88{
9- LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::LinearSystem()
10- : m_comm(MPI_COMM_NULL)
11- {}
12-
139 LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::LinearSystem(MPI_Comm comm)
1410 : m_comm(comm)
1511 {
16- MatCreate (comm, &m_operator);
17- VecCreate (comm, &m_solution);
18- VecCreate (comm, &m_vector);
12+ PetscErrorCode ierr;
13+ ierr = MatCreate (comm, &m_operator);
14+ assert (ierr == PETSC_SUCCESS);
15+ ierr = VecCreate (comm, &m_solution);
16+ assert (ierr == PETSC_SUCCESS);
17+ ierr = VecCreate (comm, &m_vector);
18+ assert (ierr == PETSC_SUCCESS);
1919 }
2020
2121 LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::LinearSystem(const LinearSystem& other)
@@ -34,6 +34,18 @@ namespace Rodin::Math
3434 m_vector(std::exchange(other.m_vector, PETSC_NULLPTR))
3535 {}
3636
37+ LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::~LinearSystem ()
38+ {
39+ m_comm = MPI_COMM_NULL;
40+ PetscErrorCode ierr;
41+ ierr = MatDestroy (&m_operator);
42+ assert (ierr == PETSC_SUCCESS);
43+ ierr = VecDestroy (&m_solution);
44+ assert (ierr == PETSC_SUCCESS);
45+ ierr = VecDestroy (&m_vector);
46+ assert (ierr == PETSC_SUCCESS);
47+ }
48+
3749 LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>&
3850 LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::operator =(const LinearSystem& other)
3951 {
@@ -61,24 +73,4 @@ namespace Rodin::Math
6173 }
6274 return *this ;
6375 }
64-
65- LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>&
66- LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::create(MPI_Comm comm)
67- {
68- m_comm = comm;
69- MatCreate (comm, &m_operator);
70- VecCreate (comm, &m_solution);
71- VecCreate (comm, &m_vector);
72- return *this ;
73- }
74-
75- LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>&
76- LinearSystem<PETSc::Math::Matrix, PETSc::Math::Vector>::destroy()
77- {
78- m_comm = MPI_COMM_NULL;
79- MatDestroy (&m_operator);
80- VecDestroy (&m_solution);
81- VecDestroy (&m_vector);
82- return *this ;
83- }
8476}
0 commit comments