Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two tests with complex PETSc #13960

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions tests/petsc_complex/assemble_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// combinations of PETScWrappers objects is correctly instantiated and works.

#include <deal.II/lac/affine_constraints.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/petsc_sparse_matrix.h>
#include <deal.II/lac/petsc_vector.h>
Expand All @@ -37,9 +38,20 @@ main(int argc, char **argv)

const unsigned int n = 4;

PETScWrappers::SparseMatrix serial_matrix(n, n, n);
PETScWrappers::MPI::SparseMatrix mpi_matrix(MPI_COMM_WORLD, n, n, n, n, n);
PETScWrappers::MPI::Vector mpi_vector(MPI_COMM_WORLD, n, n);
PETScWrappers::SparseMatrix serial_matrix(n, n, n);

// PETSc requires us to set up the sparsity pattern ahead of construction
DynamicSparsityPattern dsp(n, n);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/tests/petsc_complex/assemble_01.cc b/tests/petsc_complex/assemble_01.cc
index b055c8a93b..e31b5a3c49 100644
--- a/tests/petsc_complex/assemble_01.cc
+++ b/tests/petsc_complex/assemble_01.cc
@@ -19,6 +19,7 @@
 // combinations of PETScWrappers objects is correctly instantiated and works.
 
 #include <deal.II/lac/affine_constraints.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
 #include <deal.II/lac/full_matrix.h>
 #include <deal.II/lac/petsc_sparse_matrix.h>
 #include <deal.II/lac/petsc_vector.h>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

for (unsigned int i = 0; i < n; ++i)
for (unsigned int j = 0; j < n; ++j)
dsp.add(i, j);
IndexSet all_dofs(n);
all_dofs.add_range(0, n);

PETScWrappers::MPI::SparseMatrix mpi_matrix;
mpi_matrix.reinit(all_dofs, all_dofs, dsp, MPI_COMM_WORLD);

PETScWrappers::MPI::Vector mpi_vector(MPI_COMM_WORLD, n, n);

FullMatrix<PetscScalar> cell_matrix(n, n);
Vector<PetscScalar> cell_rhs(n);
Expand Down
6 changes: 3 additions & 3 deletions tests/petsc_complex/sparse_matrix_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ---------------------------------------------------------------------


// check SparseMatrix::add(other, factor)
// check SparseMatrix::add(factor, other)

#include <deal.II/lac/petsc_sparse_matrix.h>

Expand Down Expand Up @@ -50,14 +50,14 @@ test()
deallog << m(k, k) << ' ';
deallog << std::endl;

m.add(m2, 1.0);
m.add(1.0, m2);

deallog << "after: " << m(0, 1) << std::endl;
for (unsigned int k = 0; k < s; ++k)
deallog << m(k, k) << ' ';
deallog << std::endl;

m.add(m2, -1.0);
m.add(-1.0, m2);

deallog << "back to original: " << m(0, 1) << std::endl;
for (unsigned int k = 0; k < s; ++k)
Expand Down