]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fixed a bug where exchanger.ghosts_were_set was not set
authorDenis Davydov <davydden@gmail.com>
Tue, 12 Jun 2018 13:30:33 +0000 (15:30 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 12 Jun 2018 14:22:34 +0000 (16:22 +0200)
for vectors with large number of blocks. Update the test
to make sure this is being checked.

doc/news/changes/minor/20180612DenisDavydov [new file with mode: 0644]
include/deal.II/matrix_free/matrix_free.h
tests/matrix_free/matrix_vector_blocks.cc

diff --git a/doc/news/changes/minor/20180612DenisDavydov b/doc/news/changes/minor/20180612DenisDavydov
new file mode 100644 (file)
index 0000000..8219f34
--- /dev/null
@@ -0,0 +1,4 @@
+Bugfix: Fixed a bug where VectorDataExchange::ghosts_were_set was
+not set inside MatrixFree::cell_loop() for block vectors
+with many blocks.
+(Denis Davydov 2018/06/12)
index ce79cd6dfdc39c1ec06bf7fc6a959529aa3776e2..337069426be245873c68c99c8e2121c96c9c1fe4 100644 (file)
@@ -3271,10 +3271,17 @@ namespace internal
                                   VectorDataExchange<dim, Number> &exchanger)
   {
     if (get_communication_block_size(vec) < vec.n_blocks())
-      vec.update_ghost_values();
+      {
+        // don't forget to set ghosts_were_set, that otherwise happens
+        // inside VectorDataExchange::update_ghost_values_start()
+        exchanger.ghosts_were_set = vec.has_ghost_elements();
+        vec.update_ghost_values();
+      }
     else
-      for (unsigned int i = 0; i < vec.n_blocks(); ++i)
-        update_ghost_values_start(vec.block(i), exchanger, channel + i);
+      {
+        for (unsigned int i = 0; i < vec.n_blocks(); ++i)
+          update_ghost_values_start(vec.block(i), exchanger, channel + i);
+      }
   }
 
 
index 46d71eaa1b580ab53038783e8a78413343ffe506..93c42c4d927a27b653bf4ecc513bcd4ff45a4a66 100644 (file)
@@ -100,7 +100,6 @@ test()
   tria.refine_global(1);
   typename Triangulation<dim>::active_cell_iterator cell = tria.begin_active(),
                                                     endc = tria.end();
-  cell                                                   = tria.begin_active();
   for (; cell != endc; ++cell)
     if (cell->is_locally_owned())
       if (cell->center().norm() < 0.2)
@@ -172,6 +171,10 @@ test()
       out.reinit(in);
       ref.reinit(in);
 
+      // after initialization via MatrixFree we are in the write state for
+      // ghosts
+      AssertThrow(in.has_ghost_elements() == false, ExcInternalError());
+
       // fill each block with random numbers and do the block-wise
       // matrix-vector product for reference
       for (unsigned int block = 0; block < n_blocks; ++block)
@@ -186,6 +189,10 @@ test()
           mf_ref.vmult(ref.block(block), in.block(block));
         }
 
+      // explicitly update ghosts so that we can read them:
+      in.update_ghost_values();
+      AssertThrow(in.has_ghost_elements(), ExcInternalError());
+
       deallog << "Norm of difference with " << n_blocks << " blocks:";
 
       // run 10 times to make a possible error more
@@ -193,6 +200,10 @@ test()
       for (unsigned int run = 0; run < 10; ++run)
         {
           mf.vmult(out, in);
+
+          // since we made "in" ghosted, make sure it is still ghosted
+          AssertThrow(in.has_ghost_elements(), ExcInternalError());
+
           out -= ref;
           const double diff_norm = out.linfty_norm();
           deallog << " " << diff_norm;

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.