]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tpetra: fix lac/vector_reinit_02 16597/head
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 5 Feb 2024 15:25:39 +0000 (10:25 -0500)
committerDaniel Arndt <arndtd@ornl.gov>
Mon, 5 Feb 2024 15:26:50 +0000 (10:26 -0500)
include/deal.II/lac/trilinos_tpetra_vector.h
include/deal.II/lac/trilinos_tpetra_vector.templates.h
tests/lac/vector_reinit_02.cc
tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=off.output [moved from tests/lac/vector_reinit_02.with_trilinos=true.output with 100% similarity]
tests/lac/vector_reinit_02.with_trilinos=true.with_trilinos_with_tpetra=on.output [new file with mode: 0644]

index 734495bb800cecb128f4d741d6716a4a6d41076a..80a140b1c7c4d3a745a1808ffb173fc893360745 100644 (file)
@@ -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
index a802f15980bfe8a04e5938d28fc467456db729bc..cfb5ecfb2bec580e7e6025e0924c5e0587b5b106 100644 (file)
@@ -140,6 +140,19 @@ namespace LinearAlgebra
 
 
 
+    template <typename Number, typename MemorySpace>
+    void
+    Vector<Number, MemorySpace>::clear()
+    {
+      vector = Utilities::Trilinos::internal::make_rcp<VectorType>(
+        Utilities::Trilinos::internal::make_rcp<MapType>(
+          0, 0, Utilities::Trilinos::tpetra_comm_self()));
+      has_ghost  = false;
+      compressed = true;
+    }
+
+
+
     template <typename Number, typename MemorySpace>
     void
     Vector<Number, MemorySpace>::reinit(const IndexSet &parallel_partitioner,
index 657e39c3ab991a2fcdff42bcf8439a40bba1405e..c7084ce67f668177aa534d58bb54b770beaf76cd 100644 (file)
@@ -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.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 (file)
index 0000000..037dda4
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.