From: Daniel Arndt Date: Mon, 5 Feb 2024 15:25:39 +0000 (-0500) Subject: Tpetra: fix lac/vector_reinit_02 X-Git-Tag: relicensing~75^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0577e99078807f4c8ef392c452ecac52dad5b34c;p=dealii.git Tpetra: fix lac/vector_reinit_02 --- 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