Skip to content

Commit 33ce8db

Browse files
committed
Update
1 parent a4e12ca commit 33ce8db

File tree

9 files changed

+57
-912
lines changed

9 files changed

+57
-912
lines changed

src/Rodin/PETSc/Assembly/Generic.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,15 @@ namespace Rodin::Assembly
9393

9494
void execute(LinearSystemType& out, const InputType& input) const override
9595
{
96+
PetscErrorCode ierr;
9697
const auto& u = input.getTrialFunction();
9798
const auto& v = input.getTestFunction();
9899
const auto& trialFES = u.getFiniteElementSpace();
99100
const auto& testFES = v.getFiniteElementSpace();
100101
auto& pb = input.getProblemBody();
101102
auto& [stiffness, solution, mass] = out;
102103

103-
MPI_Comm comm;
104-
PetscErrorCode ierr;
105-
ierr = PetscObjectGetComm(reinterpret_cast<PetscObject>(stiffness), &comm);
106-
assert(ierr == PETSC_SUCCESS);
104+
const MPI_Comm comm = out.getCommunicator();
107105

108106
const BilinearFormAssemblyType bfa;
109107
bfa.execute(

src/Rodin/PETSc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ set(RodinPETSc_SRCS
2525
Assembly/MPI.cpp
2626
Assembly/OpenMP.cpp
2727
Assembly/Sequential.cpp
28-
Math/Vector.cpp
29-
Math/Matrix.cpp
3028
Math/LinearSystem.cpp
3129
Variational/GridFunction.cpp
3230
Variational/TrialFunction.cpp

src/Rodin/PETSc/Math/LinearSystem.cpp

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
namespace 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
}

src/Rodin/PETSc/Math/LinearSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace Rodin::Math
4040

4141
LinearSystem(LinearSystem&& other) noexcept;
4242

43-
virtual ~LinearSystem() = default;
43+
virtual ~LinearSystem();
4444

4545
LinearSystem& operator=(const LinearSystem& other);
4646

src/Rodin/PETSc/Math/Matrix.cpp

Lines changed: 0 additions & 261 deletions
This file was deleted.

0 commit comments

Comments
 (0)