From: kronbichler Date: Thu, 22 Nov 2012 13:32:48 +0000 (+0000) Subject: Avoid segmentation fault when calling DoFHandler::distribute_dofs on empty triangulation. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6ba026fb11e8d2fec40325c20d10f3964eea76d;p=dealii-svn.git Avoid segmentation fault when calling DoFHandler::distribute_dofs on empty triangulation. git-svn-id: https://svn.dealii.org/trunk@27671 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/dofs/dof_handler.cc b/deal.II/source/dofs/dof_handler.cc index b8eeff9a05..a91f82f6c2 100644 --- a/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/source/dofs/dof_handler.cc @@ -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); + } } }; }