]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Avoid segmentation fault when calling DoFHandler::distribute_dofs on empty triangulation.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Nov 2012 13:32:48 +0000 (13:32 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Nov 2012 13:32:48 +0000 (13:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@27671 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/dofs/dof_handler.cc

index b8eeff9a0558a6d113d59504b27926038736559a..a91f82f6c296e84dfd6e06cbec4e452e494d553e 100644 (file)
@@ -149,19 +149,10 @@ namespace internal
                           16*dof_handler.selected_fe->dofs_per_quad;
             break;
 
-            // the following
-            // numbers are not
-            // based on actual
-            // counting but by
-            // extrapolating the
-            // number sequences
-            // from the previous
-            // ones (for example,
-            // for dofs_per_vertex,
-            // the sequence above
-            // is 19, 21, 28, 30,
-            // 37, and is continued
-            // as follows):
+            // the following numbers are not based on actual counting but by
+            // extrapolating the number sequences from the previous ones (for
+            // example, for dofs_per_vertex, the sequence above is 19, 21, 28,
+            // 30, 37, and is continued as follows):
           case 9:
             max_couplings=39*dof_handler.selected_fe->dofs_per_vertex +
                           59*dof_handler.selected_fe->dofs_per_line +
@@ -309,10 +300,14 @@ namespace internal
           }
 
         dof_handler.faces = new internal::DoFHandler::DoFFaces<2>;
-        dof_handler.faces->lines.dofs
-        .resize (dof_handler.tria->n_raw_lines() *
-                 dof_handler.selected_fe->dofs_per_line,
-                 DoFHandler<2,spacedim>::invalid_dof_index);
+        // avoid access to n_raw_lines when there are no cells
+        if (dof_handler.tria->n_cells() > 0)
+          {
+            dof_handler.faces->lines.dofs
+            .resize (dof_handler.tria->n_raw_lines() *
+                     dof_handler.selected_fe->dofs_per_line,
+                     DoFHandler<2,spacedim>::invalid_dof_index);
+          }
       }
 
 
@@ -341,14 +336,18 @@ namespace internal
           }
         dof_handler.faces = new internal::DoFHandler::DoFFaces<3>;
 
-        dof_handler.faces->lines.dofs
-        .resize (dof_handler.tria->n_raw_lines() *
-                 dof_handler.selected_fe->dofs_per_line,
-                 DoFHandler<3,spacedim>::invalid_dof_index);
-        dof_handler.faces->quads.dofs
-        .resize (dof_handler.tria->n_raw_quads() *
-                 dof_handler.selected_fe->dofs_per_quad,
-                 DoFHandler<3,spacedim>::invalid_dof_index);
+        // avoid access to n_raw_lines when there are no cells
+        if (dof_handler.tria->n_cells() > 0)
+          {
+            dof_handler.faces->lines.dofs
+            .resize (dof_handler.tria->n_raw_lines() *
+                     dof_handler.selected_fe->dofs_per_line,
+                     DoFHandler<3,spacedim>::invalid_dof_index);
+            dof_handler.faces->quads.dofs
+            .resize (dof_handler.tria->n_raw_quads() *
+                     dof_handler.selected_fe->dofs_per_quad,
+                     DoFHandler<3,spacedim>::invalid_dof_index);
+          }
       }
     };
   }

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.