Skip to content

Commit a4e7d2e

Browse files
la::petsc::create_matrix: the Python interface can pass "mpi"
1 parent c2d11dd commit a4e7d2e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cpp/dolfinx/la/petsc.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,20 @@ Mat la::petsc::create_matrix(MPI_Comm comm, const SparsityPattern& sp,
247247
const std::array bs = {sp.block_size(0), sp.block_size(1)};
248248

249249
if (type)
250-
MatSetType(A, type->c_str());
250+
{
251+
if (type == std::string("mpi"))
252+
{
253+
ierr = MatSetType(A, MATAIJ);
254+
if (ierr != 0)
255+
petsc::error(ierr, __FILE__, "MatSetType");
256+
}
257+
else
258+
{
259+
ierr = MatSetType(A, type->c_str());
260+
if (ierr != 0)
261+
petsc::error(ierr, __FILE__, "MatSetType");
262+
}
263+
}
251264

252265
// Get global and local dimensions
253266
const std::int64_t M = bs[0] * maps[0]->size_global();

0 commit comments

Comments
 (0)