]> https://gitweb.dealii.org/ - dealii.git/commitdiff
MatrixFree: do not update ghost values of a ghosted src vector 15959/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 4 Sep 2023 20:23:42 +0000 (22:23 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 18 Jun 2024 08:03:49 +0000 (10:03 +0200)
include/deal.II/matrix_free/matrix_free.h
tests/matrix_free/step-48.cc
tests/matrix_free/step-48c.cc
tests/matrix_free/stokes_computation.cc
tests/multigrid-global-coarsening/stokes_computation.cc

index 78410ba48dd2cdb2e0f37e66aa4ea88d85cd2eb6..f109651ec60aee5c920e1191c69caa79331d02c3 100644 (file)
@@ -3413,7 +3413,10 @@ namespace internal
              ExcNotImplemented());
 
       if (ghosts_set)
-        ghosts_were_set = true;
+        {
+          ghosts_were_set = true;
+          return;
+        }
 
       vec.update_ghost_values();
     }
@@ -3441,7 +3444,10 @@ namespace internal
              ExcNotImplemented());
 
       if (ghosts_set)
-        ghosts_were_set = true;
+        {
+          ghosts_were_set = true;
+          return;
+        }
 
       vec.update_ghost_values_start(component_in_block_vector + channel_shift);
     }
@@ -3472,7 +3478,10 @@ namespace internal
              ExcNotImplemented());
 
       if (ghosts_set)
-        ghosts_were_set = true;
+        {
+          ghosts_were_set = true;
+          return;
+        }
 
       if (vec.size() != 0)
         {
@@ -3536,6 +3545,10 @@ namespace internal
                                const VectorType  &vec)
     {
       (void)component_in_block_vector;
+
+      if (ghosts_were_set)
+        return;
+
       vec.update_ghost_values_finish();
     }
 
@@ -3559,6 +3572,9 @@ namespace internal
                     "Type mismatch between VectorType and VectorDataExchange");
       (void)component_in_block_vector;
 
+      if (ghosts_were_set)
+        return;
+
       if (vec.size() != 0)
         {
 #  ifdef DEAL_II_WITH_MPI
@@ -4092,7 +4108,10 @@ namespace internal
                ExcNotImplemented());
 
         if (ghosts_set)
-          exchanger.ghosts_were_set = true;
+          {
+            exchanger.ghosts_were_set = true;
+            return;
+          }
 
         vec.update_ghost_values();
       }
@@ -4463,6 +4482,10 @@ namespace internal
     const VectorStruct                                   &vec,
     VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
   {
+    // return immediately if there is nothing to do.
+    if (exchanger.ghosts_were_set == true)
+      return;
+
     exchanger.reset_ghost_values(vec);
   }
 
index 8c62ae82582483387220ccdfc8d2e7628f977052..165e0811e973c122fa7eab44da1a744a39313f06 100644 (file)
@@ -329,6 +329,7 @@ namespace Step48
                                       norm_per_cell,
                                       QGauss<dim>(fe_degree + 1),
                                       VectorTools::L2_norm);
+    solution.zero_out_ghost_values();
     const double solution_norm =
       std::sqrt(Utilities::MPI::sum(norm_per_cell.norm_sqr(), MPI_COMM_WORLD));
 
index 330eb55f8438a67c674276817579254fbdd8ec24..a8d747994639be8f76bd00a42bb17fb38a0ba431 100644 (file)
@@ -299,6 +299,7 @@ namespace Step48
                                       norm_per_cell,
                                       QGauss<dim>(fe_degree + 1),
                                       VectorTools::L2_norm);
+    solution.zero_out_ghost_values();
     const double solution_norm =
       std::sqrt(Utilities::MPI::sum(norm_per_cell.norm_sqr(), MPI_COMM_WORLD));
 
index c685e92c4dc9891bd13ec9d7cf9ea3a125f81f75..2661b52c6c9971cccc781676a1cce3b12eb92cf7 100644 (file)
@@ -1148,10 +1148,7 @@ namespace StokesClass
     stokes_matrix.initialize_dof_vector(solution);
     stokes_matrix.initialize_dof_vector(system_rhs);
 
-    solution.update_ghost_values();
     solution.collect_sizes();
-
-    system_rhs.update_ghost_values();
     system_rhs.collect_sizes();
   }
 
index 9810667cbcae5327f8228b7b1ecd5d40a6baa530..c0ab2be5bb5f236a78f273b63a45116bbae7f2fa 100644 (file)
@@ -1148,10 +1148,7 @@ namespace StokesClass
     stokes_matrix.initialize_dof_vector(solution);
     stokes_matrix.initialize_dof_vector(system_rhs);
 
-    solution.update_ghost_values();
     solution.collect_sizes();
-
-    system_rhs.update_ghost_values();
     system_rhs.collect_sizes();
   }
 

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.