]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bug when we have no DoFs on a line 14083/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Thu, 30 Jun 2022 08:01:21 +0000 (10:01 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Thu, 30 Jun 2022 08:01:51 +0000 (10:01 +0200)
source/dofs/dof_handler_policy.cc

index 90f57d392a72d1db3ef0ffdccd1514688270d176..df67d3c0388ccd7e534ddc8d05a2ea98517ae2ed 100644 (file)
@@ -2550,7 +2550,9 @@ namespace internal
           const unsigned int         level,
           const bool                 check_validity)
         {
-          if (dof_handler.get_fe().n_dofs_per_line() > 0 ||
+          const unsigned int dofs_per_line =
+            dof_handler.get_fe().n_dofs_per_line();
+          if (dofs_per_line > 0 ||
               (dim > 2 && dof_handler.get_fe().max_dofs_per_quad() > 0))
             {
               // visit all lines/quads adjacent to cells of the current level
@@ -2566,41 +2568,40 @@ namespace internal
                     numbers::artificial_subdomain_id)
                   {
                     // lines
-                    for (const auto l : cell->line_indices())
-                      {
-                        const auto line = cell->line(l);
-                        if (!line_touched[line->index()])
-                          {
-                            const unsigned int dofs_per_line =
-                              dof_handler.get_fe().n_dofs_per_line();
-                            dealii::types::global_dof_index *indices =
-                              &internal::DoFAccessorImplementation::
-                                Implementation::get_mg_dof_index(
-                                  dof_handler,
-                                  dof_handler.mg_levels[level],
-                                  dof_handler.mg_faces,
-                                  line->index(),
-                                  0,
-                                  0,
-                                  std::integral_constant<int, 1>());
-                            for (unsigned int d = 0; d < dofs_per_line; ++d)
-                              {
-                                if (check_validity)
-                                  Assert(indices[d] !=
-                                           numbers::invalid_dof_index,
-                                         ExcInternalError());
-
-                                if (indices[d] != numbers::invalid_dof_index)
-                                  indices[d] =
-                                    (indices_we_care_about.size() == 0) ?
-                                      new_numbers[indices[d]] :
-                                      new_numbers[indices_we_care_about
-                                                    .index_within_set(
-                                                      indices[d])];
-                              }
-                            line_touched[line->index()] = true;
-                          }
-                      }
+                    if (dofs_per_line > 0)
+                      for (const auto l : cell->line_indices())
+                        {
+                          const auto line = cell->line(l);
+                          if (!line_touched[line->index()])
+                            {
+                              dealii::types::global_dof_index *indices =
+                                &internal::DoFAccessorImplementation::
+                                  Implementation::get_mg_dof_index(
+                                    dof_handler,
+                                    dof_handler.mg_levels[level],
+                                    dof_handler.mg_faces,
+                                    line->index(),
+                                    0,
+                                    0,
+                                    std::integral_constant<int, 1>());
+                              for (unsigned int d = 0; d < dofs_per_line; ++d)
+                                {
+                                  if (check_validity)
+                                    Assert(indices[d] !=
+                                             numbers::invalid_dof_index,
+                                           ExcInternalError());
+
+                                  if (indices[d] != numbers::invalid_dof_index)
+                                    indices[d] =
+                                      (indices_we_care_about.size() == 0) ?
+                                        new_numbers[indices[d]] :
+                                        new_numbers[indices_we_care_about
+                                                      .index_within_set(
+                                                        indices[d])];
+                                }
+                              line_touched[line->index()] = true;
+                            }
+                        }
 
                     // quads
                     if (dim > 2)
@@ -2609,30 +2610,34 @@ namespace internal
                           {
                             const unsigned int dofs_per_quad =
                               dof_handler.get_fe().n_dofs_per_quad(quad);
-                            dealii::types::global_dof_index *indices =
-                              &internal::DoFAccessorImplementation::
-                                Implementation::get_mg_dof_index(
-                                  dof_handler,
-                                  dof_handler.mg_levels[level],
-                                  dof_handler.mg_faces,
-                                  cell->quad(quad)->index(),
-                                  0,
-                                  0,
-                                  std::integral_constant<int, 2>());
-                            for (unsigned int d = 0; d < dofs_per_quad; ++d)
+                            if (dofs_per_quad > 0)
                               {
-                                if (check_validity)
-                                  Assert(indices[d] !=
-                                           numbers::invalid_dof_index,
-                                         ExcInternalError());
-
-                                if (indices[d] != numbers::invalid_dof_index)
-                                  indices[d] =
-                                    (indices_we_care_about.size() == 0) ?
-                                      new_numbers[indices[d]] :
-                                      new_numbers[indices_we_care_about
-                                                    .index_within_set(
-                                                      indices[d])];
+                                dealii::types::global_dof_index *indices =
+                                  &internal::DoFAccessorImplementation::
+                                    Implementation::get_mg_dof_index(
+                                      dof_handler,
+                                      dof_handler.mg_levels[level],
+                                      dof_handler.mg_faces,
+                                      cell->quad(quad)->index(),
+                                      0,
+                                      0,
+                                      std::integral_constant<int, 2>());
+                                for (unsigned int d = 0; d < dofs_per_quad; ++d)
+                                  {
+                                    if (check_validity)
+                                      Assert(indices[d] !=
+                                               numbers::invalid_dof_index,
+                                             ExcInternalError());
+
+                                    if (indices[d] !=
+                                        numbers::invalid_dof_index)
+                                      indices[d] =
+                                        (indices_we_care_about.size() == 0) ?
+                                          new_numbers[indices[d]] :
+                                          new_numbers[indices_we_care_about
+                                                        .index_within_set(
+                                                          indices[d])];
+                                  }
                               }
                             quad_touched[cell->quad(quad)->index()] = true;
                           }

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.