From 0577e99078807f4c8ef392c452ecac52dad5b34c Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 5 Feb 2024 10:25:39 -0500 Subject: [PATCH] Tpetra: fix lac/vector_reinit_02 --- include/deal.II/lac/trilinos_tpetra_vector.h | 7 +++++++ .../deal.II/lac/trilinos_tpetra_vector.templates.h | 13 +++++++++++++ tests/lac/vector_reinit_02.cc | 9 +++++++++ ...linos=true.with_trilinos_with_tpetra=off.output} | 0 ...rilinos=true.with_trilinos_with_tpetra=on.output | 13 +++++++++++++ 5 files changed, 42 insertions(+) rename tests/lac/{vector_reinit_02.with_trilinos=true.output => vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=off.output} (100%) create mode 100644 tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=on.output diff --git a/include/deal.II/lac/trilinos_tpetra_vector.h b/include/deal.II/lac/trilinos_tpetra_vector.h index 734495bb80..80a140b1c7 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.h @@ -320,6 +320,13 @@ namespace LinearAlgebra const MPI_Comm communicator, const bool vector_writable = false); + /** + * Release all memory and return to a state just like after having called + * the default constructor. + */ + void + clear(); + /** * Reinit functionality. This function destroys the old vector content * and generates a new one based on the input partitioning. The flag diff --git a/include/deal.II/lac/trilinos_tpetra_vector.templates.h b/include/deal.II/lac/trilinos_tpetra_vector.templates.h index a802f15980..cfb5ecfb2b 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.templates.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.templates.h @@ -140,6 +140,19 @@ namespace LinearAlgebra + template + void + Vector::clear() + { + vector = Utilities::Trilinos::internal::make_rcp( + Utilities::Trilinos::internal::make_rcp( + 0, 0, Utilities::Trilinos::tpetra_comm_self())); + has_ghost = false; + compressed = true; + } + + + template void Vector::reinit(const IndexSet ¶llel_partitioner, diff --git a/tests/lac/vector_reinit_02.cc b/tests/lac/vector_reinit_02.cc index 657e39c3ab..c7084ce67f 100644 --- a/tests/lac/vector_reinit_02.cc +++ b/tests/lac/vector_reinit_02.cc @@ -42,6 +42,7 @@ do_test() v1.reinit(set, communicator); deallog << "reinit: " << v1.size() << ' '; + v1.clear(); #ifdef DEAL_II_WITH_MPI MPI_Comm_free(&communicator); #endif @@ -56,6 +57,8 @@ do_test() v1.reinit(v2); deallog << v1.size() << std::endl; + v1.clear(); + v2.clear(); #ifdef DEAL_II_WITH_MPI MPI_Comm_free(&communicator); #endif @@ -70,6 +73,8 @@ do_test() v1 = v2; deallog << v1.size() << std::endl; + v1.clear(); + v2.clear(); #ifdef DEAL_II_WITH_MPI MPI_Comm_free(&communicator); #endif @@ -84,6 +89,8 @@ do_test() v3->reinit(v1); deallog << "reinit pool " << v1.size() << ' ' << v3->size() << ' '; + v1.clear(); + v3->clear(); #ifdef DEAL_II_WITH_MPI MPI_Comm_free(&communicator); #endif @@ -98,6 +105,8 @@ do_test() v3->reinit(v1); deallog << "reinit pool " << v3->size() << std::endl; + v1.clear(); + v3->clear(); #ifdef DEAL_II_WITH_MPI MPI_Comm_free(&communicator); #endif diff --git a/tests/lac/vector_reinit_02.with_trilinos=true.output b/tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=off.output similarity index 100% rename from tests/lac/vector_reinit_02.with_trilinos=true.output rename to tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=off.output diff --git a/tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=on.output b/tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=on.output new file mode 100644 index 0000000000..037dda4f8d --- /dev/null +++ b/tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=on.output @@ -0,0 +1,13 @@ + +DEAL::reinit: 5 5 5 +DEAL::assign 5 5 +DEAL::reinit pool 5 5 reinit pool 5 +DEAL::reinit: 5 5 5 +DEAL::assign 5 5 +DEAL::reinit pool 5 5 reinit pool 5 +DEAL::reinit: 5 5 5 +DEAL::assign 5 5 +DEAL::reinit pool 5 5 reinit pool 5 +DEAL::reinit: 5 5 5 +DEAL::assign 5 5 +DEAL::reinit pool 5 5 reinit pool 5 -- 2.39.5