]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix 1D bug in one version of make_flux_sparsity_pattern. 9398/head
authorSimon Sticko <simon@sticko.se>
Fri, 17 Jan 2020 16:59:07 +0000 (17:59 +0100)
committerSimon Sticko <simon@sticko.se>
Mon, 20 Jan 2020 09:31:03 +0000 (10:31 +0100)
When a neighbor has children, the function loops over each face and the
children of each face_iterator. But in 1D the number of children of a
face is always zero. The result is that flux-couplings are missed in
the 1D case when not all cells are on the same level.

Fix this by avoiding to iterate over the children of the face in 1D.
This is the same solutions that is already used in line 597 of
source/dofs/dof_tools_sparsity.cc.

source/dofs/dof_tools_sparsity.cc

index 67c1536dcef274afc0a9e9129b630427920e113a..b3c05e9e931e0a265235d77a5eebf05637b88734 100644 (file)
@@ -880,6 +880,16 @@ namespace DoFTools
                           cell->periodic_neighbor_face_no(face_n) :
                           cell->neighbor_face_no(face_n);
 
+
+                      // In 1D, go straight to the cell behind this particular
+                      // cell's most terminal cell. This makes us skip the
+                      // if (neighbor->has_children()) section below. We need to
+                      // do this since we otherwise iterate over the children of
+                      // the face, which are always 0 in 1D.
+                      if (DoFHandlerType::dimension == 1)
+                        while (neighbor->has_children())
+                          neighbor = neighbor->child(face_n == 0 ? 1 : 0);
+
                       if (neighbor->has_children())
                         {
                           for (unsigned int sub_nr = 0;
@@ -1174,6 +1184,15 @@ namespace DoFTools
                           neighbor->is_locally_owned())
                         continue; // (the neighbor is finer)
 
+                      // In 1D, go straight to the cell behind this particular
+                      // cell's most terminal cell. This makes us skip the
+                      // if (neighbor->has_children()) section below. We need to
+                      // do this since we otherwise iterate over the children of
+                      // the face, which are always 0 in 1D.
+                      if (dim == 1)
+                        while (neighbor->has_children())
+                          neighbor = neighbor->child(face == 0 ? 1 : 0);
+
                       if (neighbor->has_children())
                         {
                           for (unsigned int sub_nr = 0;

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.