From 1de3032ca530d8e6292f07da8e9637b423040c36 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 8 Jun 2020 12:15:54 -0400 Subject: [PATCH] Cleanup DoFTools hp::DoFhandler --- include/deal.II/dofs/dof_tools.h | 197 ------------------ .../fe/fe_tools_interpolate.templates.h | 10 +- .../deal.II/multigrid/mg_constrained_dofs.h | 2 +- .../vector_tools_boundary.templates.h | 10 +- source/dofs/dof_handler_policy.cc | 6 +- source/dofs/dof_tools.cc | 62 ++++-- source/dofs/dof_tools_constraints.cc | 6 +- source/dofs/dof_tools_sparsity.cc | 14 +- source/multigrid/mg_tools.cc | 4 +- 9 files changed, 67 insertions(+), 244 deletions(-) diff --git a/include/deal.II/dofs/dof_tools.h b/include/deal.II/dofs/dof_tools.h index 05c3b2f057..58a1d760c0 100644 --- a/include/deal.II/dofs/dof_tools.h +++ b/include/deal.II/dofs/dof_tools.h @@ -305,131 +305,6 @@ namespace DoFTools * @} */ - /** - * @name Generic Functions - * - * Functions to support code that generically uses both DoFHandler and - * hp::DoFHandler. - * @{ - */ - /** - * Maximal number of degrees of freedom on a cell. - * - * @deprecated Use dh.get_fe_collection().max_dofs_per_cell(). - * - * @relatesalso DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - max_dofs_per_cell(const DoFHandler &dh); - - - /** - * Maximal number of degrees of freedom on a face. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe_collection().max_dofs_per_face(). - * - * @relatesalso DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - max_dofs_per_face(const DoFHandler &dh); - - /** - * Maximal number of degrees of freedom on a vertex. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe_collection().max_dofs_per_vertex(). - * - * @relatesalso DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - max_dofs_per_vertex(const DoFHandler &dh); - - /** - * Maximal number of degrees of freedom on a vertex. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe_collection().max_dofs_per_vertex(). - * - * @relatesalso hp::DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - max_dofs_per_vertex(const DoFHandler &dh); - - /** - * Number of vector components in the finite element object used by this - * DoFHandler. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe_collection().n_components(). - * - * @relatesalso DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - n_components(const DoFHandler &dh); - - /** - * Number of vector components in the finite element object used by this - * DoFHandler. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe_collection().n_components(). - * - * @relatesalso hp::DoFHandler - */ - template - DEAL_II_DEPRECATED unsigned int - n_components(const DoFHandler &dh); - - /** - * Find out whether the first FiniteElement used by this DoFHandler is - * primitive or not. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe(0).is_primitive(). - * - * @relatesalso DoFHandler - */ - template - DEAL_II_DEPRECATED bool - fe_is_primitive(const DoFHandler &dh); - - /** - * Find out whether the first FiniteElement used by this DoFHandler is - * primitive or not. - * - * This function exists for both non-hp and hp DoFHandlers, to allow for a - * uniform interface to query this property. - * - * @deprecated Use dh.get_fe(0).is_primitive(). - * - * @relatesalso hp::DoFHandler - */ - template - DEAL_II_DEPRECATED bool - fe_is_primitive(const DoFHandler &dh); - - /** - * @} - */ - /** * @name Sparsity pattern generation * @{ @@ -1740,22 +1615,6 @@ namespace DoFTools const types::subdomain_id subdomain_id, std::vector & selected_dofs); - - /** - * Extract the set of global DoF indices that are owned by the current - * processor. For regular DoFHandler objects, this set is the complete set - * with all DoF indices. In either case, it equals what - * DoFHandler::locally_owned_dofs() returns. - * - * @deprecated Use DoFHandler::locally_owned_dofs() directly instead of this - * function. - */ - template - DEAL_II_DEPRECATED void - extract_locally_owned_dofs(const DoFHandlerType &dof_handler, - IndexSet & dof_set); - - /** * Extract the set of global DoF indices that are active on the current * DoFHandler. For regular DoFHandlers, these are all DoF indices, but for @@ -2820,62 +2679,6 @@ namespace DoFTools // ---------------------- inline and template functions -------------------- - template - inline unsigned int - max_dofs_per_cell(const DoFHandler &dh) - { - if (dh.hp_capability_enabled == true) - return dh.get_fe_collection().max_dofs_per_cell(); - else - return dh.get_fe().dofs_per_cell; - } - - - template - inline unsigned int - max_dofs_per_face(const DoFHandler &dh) - { - if (dh.hp_capability_enabled == true) - return dh.get_fe_collection().max_dofs_per_face(); - else - return dh.get_fe().dofs_per_face; - } - - - template - inline unsigned int - max_dofs_per_vertex(const DoFHandler &dh) - { - if (dh.hp_capability_enabled == true) - return dh.get_fe_collection().max_dofs_per_vertex(); - else - return dh.get_fe().dofs_per_vertex; - } - - - template - inline unsigned int - n_components(const DoFHandler &dh) - { - if (dh.hp_capability_enabled == true) - return dh.get_fe(0).n_components(); - else - return dh.get_fe().n_components(); - } - - - - template - inline bool - fe_is_primitive(const DoFHandler &dh) - { - if (dh.hp_capability_enabled == true) - return dh.get_fe(0).is_primitive(); - else - return dh.get_fe().is_primitive(); - } - - template void map_support_points_to_dofs( diff --git a/include/deal.II/fe/fe_tools_interpolate.templates.h b/include/deal.II/fe/fe_tools_interpolate.templates.h index f89a396640..01a278f9f8 100644 --- a/include/deal.II/fe/fe_tools_interpolate.templates.h +++ b/include/deal.II/fe/fe_tools_interpolate.templates.h @@ -120,9 +120,9 @@ namespace FETools // this does not lead to // reallocation of memory Vector u1_local( - DoFTools::max_dofs_per_cell(dof1)); + dof1.get_fe_collection().max_dofs_per_cell()); Vector u2_local( - DoFTools::max_dofs_per_cell(dof2)); + dof2.get_fe_collection().max_dofs_per_cell()); // have a map for interpolation matrices. // Using a unique_ptr makes sure that the @@ -141,7 +141,7 @@ namespace FETools (void)endc2; std::vector dofs; - dofs.reserve(DoFTools::max_dofs_per_cell(dof2)); + dofs.reserve(dof2.get_fe_collection().max_dofs_per_cell()); u2 = typename OutVector::value_type(0.); OutVector touch_count(u2); @@ -296,9 +296,9 @@ namespace FETools #endif Vector u1_local( - DoFTools::max_dofs_per_cell(dof1)); + dof1.get_fe_collection().max_dofs_per_cell()); Vector u1_int_local( - DoFTools::max_dofs_per_cell(dof1)); + dof1.get_fe_collection().max_dofs_per_cell()); const types::subdomain_id subdomain_id = dof1.get_triangulation().locally_owned_subdomain(); diff --git a/include/deal.II/multigrid/mg_constrained_dofs.h b/include/deal.II/multigrid/mg_constrained_dofs.h index d038e76e71..d60ac04867 100644 --- a/include/deal.II/multigrid/mg_constrained_dofs.h +++ b/include/deal.II/multigrid/mg_constrained_dofs.h @@ -388,7 +388,7 @@ MGConstrainedDoFs::make_no_normal_flux_constraints( { // For a given boundary id, find which vector component is on the boundary // and set a zero boundary constraint for those degrees of freedom. - const unsigned int n_components = DoFTools::n_components(dof); + const unsigned int n_components = dof.get_fe_collection().n_components(); AssertIndexRange(first_vector_component + dim - 1, n_components); ComponentMask comp_mask(n_components, false); diff --git a/include/deal.II/numerics/vector_tools_boundary.templates.h b/include/deal.II/numerics/vector_tools_boundary.templates.h index a2b39b271e..7c471864d9 100644 --- a/include/deal.II/numerics/vector_tools_boundary.templates.h +++ b/include/deal.II/numerics/vector_tools_boundary.templates.h @@ -80,7 +80,7 @@ namespace VectorTools ExcMessage("You cannot specify the special boundary indicator " "for interior faces in your function map.")); - const unsigned int n_components = DoFTools::n_components(dof); + const unsigned int n_components = dof.get_fe_collection().n_components(); for (typename std::map *>::const_iterator i = function_map.begin(); @@ -147,15 +147,17 @@ namespace VectorTools // field to store the indices std::vector face_dofs; - face_dofs.reserve(DoFTools::max_dofs_per_face(dof)); + face_dofs.reserve(dof.get_fe_collection().max_dofs_per_face()); // array to store the values of the boundary function at the boundary // points. have two arrays for scalar and vector functions to use the // more efficient one respectively std::vector dof_values_scalar; std::vector> dof_values_system; - dof_values_scalar.reserve(DoFTools::max_dofs_per_face(dof)); - dof_values_system.reserve(DoFTools::max_dofs_per_face(dof)); + dof_values_scalar.reserve( + dof.get_fe_collection().max_dofs_per_face()); + dof_values_system.reserve( + dof.get_fe_collection().max_dofs_per_face()); // before we start with the loop over all cells create an hp::FEValues // object that holds the interpolation points of all finite elements diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 6d5ac2be5b..381b1a78f4 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -2923,7 +2923,8 @@ namespace internal std::vector subdomain_association( n_dofs, numbers::invalid_subdomain_id); std::vector local_dof_indices; - local_dof_indices.reserve(DoFTools::max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // loop over all cells and record which subdomain a DoF belongs to. // give to the smaller subdomain_id in case it is on an interface @@ -2986,7 +2987,8 @@ namespace internal std::vector level_subdomain_association( n_dofs_on_level, numbers::invalid_subdomain_id); std::vector local_dof_indices; - local_dof_indices.reserve(DoFTools::max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // loop over all cells and record which subdomain a DoF belongs to. // interface goes to proccessor with smaller subdomain id diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index a3d55e9275..5d42d61249 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -321,14 +321,19 @@ namespace DoFTools AssertDimension(cell_data.size(), tria.n_active_cells()); AssertDimension(dof_data.size(), dof_handler.n_dofs()); - AssertIndexRange(component, n_components(dof_handler)); - Assert(fe_is_primitive(dof_handler) == true, - typename FiniteElement::ExcFENotPrimitive()); + const auto &fe_collection = dof_handler.get_fe_collection(); + AssertIndexRange(component, fe_collection.n_components()); + for (unsigned int i = 0; i < fe_collection.size(); ++i) + { + Assert(fe_collection[i].is_primitive() == true, + typename FiniteElement::ExcFENotPrimitive()); + } // store a flag whether we should care about different components. this // is just a simplification, we could ask for this at every single // place equally well - const bool consider_components = (n_components(dof_handler) != 1); + const bool consider_components = + (dof_handler.get_fe_collection().n_components() != 1); // zero out the components that we will touch if (consider_components == false) @@ -339,8 +344,7 @@ namespace DoFTools dof_handler.n_locally_owned_dofs()); internal::get_component_association( dof_handler, - dof_handler.get_fe_collection().component_mask( - FEValuesExtractors::Scalar(component)), + fe_collection.component_mask(FEValuesExtractors::Scalar(component)), component_dofs); for (unsigned int i = 0; i < dof_data.size(); ++i) @@ -355,7 +359,7 @@ namespace DoFTools dof_handler.begin_active(), endc = dof_handler.end(); std::vector dof_indices; - dof_indices.reserve(max_dofs_per_cell(dof_handler)); + dof_indices.reserve(fe_collection.max_dofs_per_cell()); for (unsigned int present_cell = 0; cell != endc; ++cell, ++present_cell) { @@ -571,7 +575,8 @@ namespace DoFTools const FiniteElement &fe = dof.get_fe(); - Assert(component_mask.represents_n_components(n_components(dof)), + Assert(component_mask.represents_n_components( + dof.get_fe_collection().n_components()), ExcMessage( "The given component mask is not sized correctly to represent the " "components of the given finite element.")); @@ -580,13 +585,15 @@ namespace DoFTools // two special cases: no component is selected, and all components are // selected, both rather stupid, but easy to catch - if (component_mask.n_selected_components(n_components(dof)) == 0) + if (component_mask.n_selected_components( + dof.get_fe_collection().n_components()) == 0) { std::fill_n(selected_dofs.begin(), dof.n_dofs(level), false); return; } - else if (component_mask.n_selected_components(n_components(dof)) == - n_components(dof)) + else if (component_mask.n_selected_components( + dof.get_fe_collection().n_components()) == + dof.get_fe_collection().n_components()) { std::fill_n(selected_dofs.begin(), dof.n_dofs(level), true); return; @@ -666,7 +673,8 @@ namespace DoFTools IndexSet & selected_dofs, const std::set &boundary_ids) { - Assert(component_mask.represents_n_components(n_components(dof_handler)), + Assert(component_mask.represents_n_components( + dof_handler.get_fe_collection().n_components()), ExcMessage("Component mask has invalid size.")); Assert(boundary_ids.find(numbers::internal_face_boundary_id) == boundary_ids.end(), @@ -685,11 +693,13 @@ namespace DoFTools // is selected, or all const bool check_vector_component = ((component_mask.represents_the_all_selected_mask() == false) || - (component_mask.n_selected_components(n_components(dof_handler)) != - n_components(dof_handler))); + (component_mask.n_selected_components( + dof_handler.get_fe_collection().n_components()) != + dof_handler.get_fe_collection().n_components())); std::vector face_dof_indices; - face_dof_indices.reserve(max_dofs_per_face(dof_handler)); + face_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_face()); // now loop over all cells and check whether their faces are at the // boundary. note that we need not take special care of single lines @@ -775,7 +785,8 @@ namespace DoFTools std::vector & selected_dofs, const std::set &boundary_ids) { - Assert(component_mask.represents_n_components(n_components(dof_handler)), + Assert(component_mask.represents_n_components( + dof_handler.get_fe_collection().n_components()), ExcMessage("This component mask has the wrong size.")); Assert(boundary_ids.find(numbers::internal_face_boundary_id) == boundary_ids.end(), @@ -794,7 +805,8 @@ namespace DoFTools selected_dofs.clear(); selected_dofs.resize(dof_handler.n_dofs(), false); std::vector cell_dof_indices; - cell_dof_indices.reserve(max_dofs_per_cell(dof_handler)); + cell_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // now loop over all cells and check whether their faces are at the // boundary. note that we need not take special care of single lines @@ -866,7 +878,8 @@ namespace DoFTools }; std::vector local_dof_indices; - local_dof_indices.reserve(max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // Get all the dofs that live on the subdomain: std::set predicate_dofs; @@ -1101,7 +1114,8 @@ namespace DoFTools std::fill_n(selected_dofs.begin(), dof_handler.n_dofs(), false); std::vector local_dof_indices; - local_dof_indices.reserve(max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // this function is similar to the make_sparsity_pattern function, see // there for more information @@ -1606,7 +1620,8 @@ namespace DoFTools numbers::invalid_subdomain_id); std::vector local_dof_indices; - local_dof_indices.reserve(max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // loop over all cells and record which subdomain a DoF belongs to. // give to the smaller subdomain_id in case it is on an interface @@ -1679,7 +1694,8 @@ namespace DoFTools IndexSet index_set(dof_handler.n_dofs()); std::vector local_dof_indices; - local_dof_indices.reserve(max_dofs_per_cell(dof_handler)); + local_dof_indices.reserve( + dof_handler.get_fe_collection().max_dofs_per_cell()); // first generate an unsorted list of all indices which we fill from // the back. could also insert them directly into the IndexSet, but @@ -2113,7 +2129,7 @@ namespace DoFTools numbers::invalid_dof_index); std::vector dofs_on_face; - dofs_on_face.reserve(max_dofs_per_face(dof_handler)); + dofs_on_face.reserve(dof_handler.get_fe_collection().max_dofs_per_face()); types::global_dof_index next_boundary_index = 0; // now loop over all cells and check whether their faces are at the @@ -2164,7 +2180,7 @@ namespace DoFTools return; std::vector dofs_on_face; - dofs_on_face.reserve(max_dofs_per_face(dof_handler)); + dofs_on_face.reserve(dof_handler.get_fe_collection().max_dofs_per_face()); types::global_dof_index next_boundary_index = 0; typename DoFHandlerType::active_cell_iterator cell = diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 6f28fb4829..708bcaaea7 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -3360,17 +3360,17 @@ namespace DoFTools "zero or equal to the number of components in the finite " "element.")); - const unsigned int n_components = DoFTools::n_components(dof); + const unsigned int n_components = dof.get_fe_collection().n_components(); Assert(component_mask.n_selected_components(n_components) > 0, ComponentMask::ExcNoComponentSelected()); // a field to store the indices on the face std::vector face_dofs; - face_dofs.reserve(max_dofs_per_face(dof)); + face_dofs.reserve(dof.get_fe_collection().max_dofs_per_face()); // a field to store the indices on the cell std::vector cell_dofs; - cell_dofs.reserve(max_dofs_per_cell(dof)); + cell_dofs.reserve(dof.get_fe_collection().max_dofs_per_cell()); typename DoFHandlerType::active_cell_iterator cell = dof.begin_active(), diff --git a/source/dofs/dof_tools_sparsity.cc b/source/dofs/dof_tools_sparsity.cc index a2f31f2198..49cde87a33 100644 --- a/source/dofs/dof_tools_sparsity.cc +++ b/source/dofs/dof_tools_sparsity.cc @@ -88,7 +88,7 @@ namespace DoFTools "than the locally owned one does not make sense.")); std::vector dofs_on_this_cell; - dofs_on_this_cell.reserve(max_dofs_per_cell(dof)); + dofs_on_this_cell.reserve(dof.get_fe_collection().max_dofs_per_cell()); typename DoFHandlerType::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); @@ -389,7 +389,7 @@ namespace DoFTools #endif std::vector dofs_on_this_face; - dofs_on_this_face.reserve(max_dofs_per_face(dof)); + dofs_on_this_face.reserve(dof.get_fe_collection().max_dofs_per_face()); // loop over all faces to check whether they are at a boundary. note // that we need not take special care of single lines (using @@ -489,7 +489,7 @@ namespace DoFTools #endif std::vector dofs_on_this_face; - dofs_on_this_face.reserve(max_dofs_per_face(dof)); + dofs_on_this_face.reserve(dof.get_fe_collection().max_dofs_per_face()); typename DoFHandlerType::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (; cell != endc; ++cell) @@ -547,8 +547,8 @@ namespace DoFTools std::vector dofs_on_this_cell; std::vector dofs_on_other_cell; - dofs_on_this_cell.reserve(max_dofs_per_cell(dof)); - dofs_on_other_cell.reserve(max_dofs_per_cell(dof)); + dofs_on_this_cell.reserve(dof.get_fe_collection().max_dofs_per_cell()); + dofs_on_other_cell.reserve(dof.get_fe_collection().max_dofs_per_cell()); typename DoFHandlerType::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); @@ -1100,9 +1100,9 @@ namespace DoFTools dof.get_fe_collection(); std::vector dofs_on_this_cell( - DoFTools::max_dofs_per_cell(dof)); + dof.get_fe_collection().max_dofs_per_cell()); std::vector dofs_on_other_cell( - DoFTools::max_dofs_per_cell(dof)); + dof.get_fe_collection().max_dofs_per_cell()); const unsigned int n_components = fe.n_components(); AssertDimension(int_mask.size(0), n_components); diff --git a/source/multigrid/mg_tools.cc b/source/multigrid/mg_tools.cc index f82fdd9682..e519ef601b 100644 --- a/source/multigrid/mg_tools.cc +++ b/source/multigrid/mg_tools.cc @@ -1301,11 +1301,11 @@ namespace MGTools if (boundary_indices[i].size() == 0) boundary_indices[i] = IndexSet(dof.n_dofs(i)); - const unsigned int n_components = DoFTools::n_components(dof); + const unsigned int n_components = dof.get_fe_collection().n_components(); const bool fe_is_system = (n_components != 1); std::vector local_dofs; - local_dofs.reserve(DoFTools::max_dofs_per_face(dof)); + local_dofs.reserve(dof.get_fe_collection().max_dofs_per_face()); std::fill(local_dofs.begin(), local_dofs.end(), numbers::invalid_dof_index); std::vector> dofs_by_level( -- 2.39.5