From: Wolfgang Bangerth Date: Wed, 28 Aug 2013 15:01:45 +0000 (+0000) Subject: Correct type stored in one offset array. Remove some code duplication in hp::DoFHandler. X-Git-Tag: v8.1.0~940 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fc60a45127f6ff30afdcb2c16944063c3efb066;p=dealii.git Correct type stored in one offset array. Remove some code duplication in hp::DoFHandler. git-svn-id: https://svn.dealii.org/trunk@30518 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/hp/dof_objects.h b/deal.II/include/deal.II/hp/dof_objects.h index 1eb9a0e471..15bae95dad 100644 --- a/deal.II/include/deal.II/hp/dof_objects.h +++ b/deal.II/include/deal.II/hp/dof_objects.h @@ -104,6 +104,9 @@ namespace internal * Store the start index for * the degrees of freedom of each * object in the @p dofs array. + * + * The type we store is then obviously the type the @p dofs array + * uses for indexing. */ std::vector::size_type> dof_offsets; diff --git a/deal.II/source/hp/dof_handler.cc b/deal.II/source/hp/dof_handler.cc index b05e51e695..205071413e 100644 --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@ -577,7 +577,7 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { dof_handler.levels[level]->dof_object.dof_offsets - = std::vector ( + = std::vector::size_type> ( dof_handler.tria->n_raw_lines(level), DoFHandler::invalid_dof_index); @@ -694,7 +694,7 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { dof_handler.levels[level]->dof_object.dof_offsets - = std::vector ( + = std::vector::size_type> ( dof_handler.tria->n_raw_quads(level), DoFHandler::invalid_dof_index); @@ -846,7 +846,8 @@ namespace internal // active ones will have a // non-invalid value later on dof_handler.faces->lines.dof_offsets - = std::vector (dof_handler.tria->n_raw_lines(), + = std::vector::size_type> + (dof_handler.tria->n_raw_lines(), DoFHandler::invalid_dof_index); dof_handler.faces->lines.dofs = std::vector (n_line_slots, @@ -1059,7 +1060,8 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { dof_handler.levels[level]->dof_object.dof_offsets - = std::vector (dof_handler.tria->n_raw_hexs(level), + = std::vector::size_type> + (dof_handler.tria->n_raw_hexs(level), DoFHandler::invalid_dof_index); types::global_dof_index next_free_dof = 0; @@ -1214,7 +1216,8 @@ namespace internal if (true) { dof_handler.faces->quads.dof_offsets - = std::vector (dof_handler.tria->n_raw_quads(), + = std::vector::size_type> + (dof_handler.tria->n_raw_quads(), DoFHandler::invalid_dof_index); dof_handler.faces->quads.dofs = std::vector (n_quad_slots, @@ -3130,101 +3133,20 @@ namespace hp std::vector *has_children_level = new std::vector (cells_on_level); - // Check for each cell, if it has children. - std::transform (tria->levels[i]->cells.refinement_cases.begin (), - tria->levels[i]->cells.refinement_cases.end (), - has_children_level->begin (), - std::bind2nd (std::not_equal_to(), - static_cast(RefinementCase::no_refinement))); - - has_children.push_back (has_children_level); - } - } - - - - template <> - void DoFHandler<1>::pre_refinement_action () - { - create_active_fe_table (); - - // Remember if the cells already have - // children. That will make the transfer - // of the active_fe_index to the finer - // levels easier. - Assert (has_children.size () == 0, ExcInternalError ()); - for (unsigned int i=0; in_raw_cells (i); - std::vector *has_children_level = - new std::vector (cells_on_level); - - // Check for each cell, if it has - // children. here we cannot use - // refinement_cases, since it is unused in - // 1d (as there is only one choice - // anyway). use the 'children' vector - // instead - std::transform (tria->levels[i]->cells.children.begin (), - tria->levels[i]->cells.children.end (), - has_children_level->begin (), - std::bind2nd (std::not_equal_to(), -1)); - - has_children.push_back (has_children_level); - } - } - - - - template <> - void DoFHandler<1,2>::pre_refinement_action () - { - create_active_fe_table (); - - // Remember if the cells have already - // children. That will make the transfer - // of the active_fe_index to the finer - // levels easier. - Assert (has_children.size () == 0, ExcInternalError ()); - for (unsigned int i=0; in_raw_lines(i); - std::vector *has_children_level = - new std::vector (lines_on_level); - - // Check for each cell, if it has children. - std::transform (tria->levels[i]->cells.children.begin (), - tria->levels[i]->cells.children.end (), - has_children_level->begin (), - std::bind2nd (std::not_equal_to(), -1)); - - has_children.push_back (has_children_level); - } - } - - - - template <> - void DoFHandler<1,3>::pre_refinement_action () - { - create_active_fe_table (); - - // Remember if the cells have already - // children. That will make the transfer - // of the active_fe_index to the finer - // levels easier. - Assert (has_children.size () == 0, ExcInternalError ()); - for (unsigned int i=0; in_raw_lines(i); - std::vector *has_children_level = - new std::vector (lines_on_level); - - // Check for each cell, if it has children. - std::transform (tria->levels[i]->cells.children.begin (), - tria->levels[i]->cells.children.end (), - has_children_level->begin (), - std::bind2nd (std::not_equal_to(), -1)); + // Check for each cell, if it has children. in 1d, + // we don't store refinement cases, so use the 'children' + // vector instead + if (dim == 1) + std::transform (tria->levels[i]->cells.children.begin (), + tria->levels[i]->cells.children.end (), + has_children_level->begin (), + std::bind2nd (std::not_equal_to(), -1)); + else + std::transform (tria->levels[i]->cells.refinement_cases.begin (), + tria->levels[i]->cells.refinement_cases.end (), + has_children_level->begin (), + std::bind2nd (std::not_equal_to(), + static_cast(RefinementCase::no_refinement))); has_children.push_back (has_children_level); }