From 3be7231614498968902f5f283ff96af28743aaa5 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 18 Dec 2009 12:52:37 +0000 Subject: [PATCH] Implement extract_dofs for hp::DoFHandler. Make DoFRenumbering::component_wise actually working for hp elements. git-svn-id: https://svn.dealii.org/trunk@20254 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/dofs/dof_renumbering.cc | 74 +++---- deal.II/deal.II/source/dofs/dof_tools.cc | 209 +++++++----------- 2 files changed, 112 insertions(+), 171 deletions(-) diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 58bf0d7ba1..7809a142c0 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -538,7 +538,7 @@ namespace DoFRenumbering template void - component_wise (hp::DoFHandler &dof_handler, + component_wise (hp::DoFHandler &dof_handler, const std::vector &component_order_arg) { std::vector renumbering (dof_handler.n_dofs(), @@ -635,7 +635,7 @@ namespace DoFRenumbering const ENDITERATOR& end, const std::vector &component_order_arg) { - const hp::FECollection fe_collection (start->get_fe ()); + const hp::FECollection fe_collection (start->get_dof_handler().get_fe ()); // do nothing if the FE has only // one component @@ -645,9 +645,6 @@ namespace DoFRenumbering return 0; } - const FiniteElement& fe = fe_collection[0]; - const unsigned int dofs_per_cell = fe.dofs_per_cell; - // Assert (new_indices.size() == start->dof_handler().n_dofs(), // ExcDimensionMismatch(new_indices.size(), // start->dof_handler.n_dofs())); @@ -660,19 +657,19 @@ namespace DoFRenumbering // store components in the order // found in the system. if (component_order.size() == 0) - for (unsigned int i=0; i local_dof_indices(dofs_per_cell); + std::vector local_dof_indices; // prebuilt list to which component // a given dof on a cell @@ -684,31 +681,29 @@ namespace DoFRenumbering // belongs. in this case, assign it // to the first vector component to // which it belongs - std::vector component_list (dofs_per_cell); - for (unsigned int i=0; i > component_list (fe_collection.size()); + for (unsigned int f=0; f & fe = fe_collection[f]; + const unsigned int dofs_per_cell = fe.dofs_per_cell; + component_list[f].resize(dofs_per_cell); + for (unsigned int i=0; i > - component_to_dof_map (fe.n_components()); + component_to_dof_map (fe_collection.n_components()); for (;start!=end;++start) { // on each cell: get dof indices // and insert them into the global // list using their component + const unsigned int fe_index = start->active_fe_index(); + const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); start.get_dof_indices (local_dof_indices); for (unsigned int i=0; isubdomain_id())) { - const unsigned int fe_index - = cell->active_fe_index(); - - const unsigned int dofs_per_cell - = fe_collection[fe_index].dofs_per_cell; + const unsigned int fe_index = cell->active_fe_index(); + const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; dofs_on_this_cell.resize (dofs_per_cell); cell->get_dof_indices (dofs_on_this_cell); @@ -2910,36 +2907,42 @@ namespace internal // component can be assigned. Then, we sort // them to the first selected component of the // vector system. - template + template inline void - extract_dofs_by_component (const dealii::DoFHandler &dof, + extract_dofs_by_component (const DH &dof, const std::vector &component_select, const bool sort_by_blocks, std::vector &dofs_by_component) { - const FiniteElement &fe = dof.get_fe(); - Assert (fe.n_components() < 256, ExcNotImplemented()); + const dealii::hp::FECollection + fe_collection (dof.get_fe()); + Assert (fe_collection.n_components() < 256, ExcNotImplemented()); Assert(dofs_by_component.size() == dof.n_dofs(), ExcDimensionMismatch(dofs_by_component.size(), dof.n_dofs())); - // next set up a table for the // degrees of freedom on each of // the cells whether it is // something interesting or not - std::vector local_component_association (fe.dofs_per_cell); - if (sort_by_blocks == true) + std::vector > local_component_association + (fe_collection.size()); + for (unsigned int f=0; f &fe = + fe_collection[f]; + local_component_association[f].resize(fe.dofs_per_cell); + if (sort_by_blocks == true) + { + for (unsigned int i=0; i indices(fe.dofs_per_cell); - typename dealii::DoFHandler::active_cell_iterator c; - for (c=dof.begin_active(); c!=dof.end(); ++ c) + std::vector indices; + for (typename DH::active_cell_iterator c=dof.begin_active(); + c!=dof.end(); ++ c) { + const unsigned int fe_index = c->active_fe_index(); + const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell; + indices.resize(dofs_per_cell); c->get_dof_indices(indices); - for (unsigned int i=0; i - inline - void - extract_dofs_by_component (const dealii::hp::DoFHandler &, - const std::vector &, - const bool , - std::vector&) - { - Assert (false, ExcNotImplemented()); - } } @@ -3041,7 +3037,7 @@ void DoFTools::distribute_cell_to_dof_vector ( std::vector component_mask (dof_handler.get_fe().n_components(), false); component_mask[component] = true; - internal::extract_dofs_by_component (dof_handler, component_mask, + internal::extract_dofs_by_component (dof_handler, component_mask, false, component_dofs); for (unsigned int i=0; i void DoFTools::extract_dofs ( - const hp::DoFHandler &/*dof*/, - const std::vector &/*component_select*/, - std::vector &/*selected_dofs*/, - const bool /*count_by_blocks*/) + const hp::DoFHandler &dof, + const std::vector &component_select, + std::vector &selected_dofs, + const bool count_by_blocks) { -//TODO[WB]: implement this function - Assert (false, ExcNotImplemented()); -/* - const FiniteElement &fe = dof.get_fe(); + const FiniteElement &fe = dof.begin_active()->get_fe(); if (count_by_blocks == true) { @@ -3210,72 +3203,20 @@ DoFTools::extract_dofs ( // preset all values by false std::fill_n (selected_dofs.begin(), dof.n_dofs(), false); - // next set up a table for the - // degrees of freedom on each of - // the cells whether it is - // something interesting or not - std::vector local_selected_dofs (fe.dofs_per_cell, false); - for (unsigned int i=0; i dofs_by_component (dof.n_dofs()); + internal::extract_dofs_by_component (dof, component_select, count_by_blocks, + dofs_by_component); - // then loop over all cells and do - // the work - std::vector indices(fe.dofs_per_cell); - typename DoFHandler::active_cell_iterator c; - for (c=dof.begin_active(); c!=dof.end(); ++ c) - { - c->get_dof_indices(indices); - for (unsigned int i=0; i