From: Wolfgang Bangerth Date: Fri, 24 Feb 2006 17:20:13 +0000 (+0000) Subject: Avoid trying to set active_fe_indices if no fe collection is available yet. X-Git-Tag: v8.0.0~12184 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d727465b3e4f24926373f3b2ccd2e875b986944;p=dealii.git Avoid trying to set active_fe_indices if no fe collection is available yet. git-svn-id: https://svn.dealii.org/trunk@12498 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/hp_dof_handler.cc b/deal.II/deal.II/source/dofs/hp_dof_handler.cc index 6136b59d3c..8e90572e36 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_handler.cc @@ -2484,37 +2484,56 @@ namespace hp levels.pop_back (); } - // Resize active_fe_indices vectors + // Resize active_fe_indices + // vectors. use zero indicator to + // extend for (unsigned int i=0; iactive_fe_indices.resize (tria.n_raw_cells(i)); - - cell_iterator cell = begin(), - endc = end (); - for (; cell != endc; ++cell) + levels[i]->active_fe_indices.resize (tria.n_raw_cells(i), 0); + + // if a finite element collection + // has already been set, then + // actually try to set + // active_fe_indices for child + // cells of refined cells to the + // active_fe_index of the mother + // cell. if no finite element + // collection has been assigned + // yet, then all indicators are + // zero anyway, and there is no + // point trying to set anything + // (besides, we would trip over + // an assertion in + // set_active_fe_index) + if (finite_elements != 0) { - // Look if the cell got children during - // refinement - // Note: Although one level is added to - // the DoFHandler levels, when the - // triangulation got one, for the buffer - // has_children this new level is not - // required, because the cells on the - // finest level never have children. Hence - // cell->has_children () will always return - // false on that level, which would cause - // shortcut evaluation of the following - // expression. Thus an index error in - // has_children should never occur. - if (cell->has_children () && - !(*has_children [cell->level ()])[cell->index ()]) + cell_iterator cell = begin(), + endc = end (); + for (; cell != endc; ++cell) { - // Set active_fe_index in children to the - // same value as in the parent cell. - for (unsigned int i = 0; i < GeometryInfo::children_per_cell; ++i) - cell->child (i)->set_active_fe_index (cell->active_fe_index ()); + // Look if the cell got children during + // refinement + // Note: Although one level is added to + // the DoFHandler levels, when the + // triangulation got one, for the buffer + // has_children this new level is not + // required, because the cells on the + // finest level never have children. Hence + // cell->has_children () will always return + // false on that level, which would cause + // shortcut evaluation of the following + // expression. Thus an index error in + // has_children should never occur. + if (cell->has_children () && + !(*has_children [cell->level ()])[cell->index ()]) + { + // Set active_fe_index in children to the + // same value as in the parent cell. + for (unsigned int i = 0; i < GeometryInfo::children_per_cell; ++i) + cell->child (i)->set_active_fe_index (cell->active_fe_index ()); + } } } - + // Free buffer objects std::vector *>::iterator children_level; for (children_level = has_children.begin ();