From: Marc Fehling Date: Mon, 8 Oct 2018 20:50:14 +0000 (-0600) Subject: Refactored FECollection::find_least_face_dominating_fe_in_collection(). X-Git-Tag: v9.1.0-rc1~645^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7304%2Fhead;p=dealii.git Refactored FECollection::find_least_face_dominating_fe_in_collection(). --- diff --git a/doc/news/changes/incompatibilities/20181008Fehling b/doc/news/changes/incompatibilities/20181008Fehling new file mode 100644 index 0000000000..c31c8d4365 --- /dev/null +++ b/doc/news/changes/incompatibilities/20181008Fehling @@ -0,0 +1,6 @@ +Changed: The function previously called +FECollection::find_least_face_dominating_fe() +is now named +FECollection::find_least_face_dominating_fe_in_collection(). +
+(Marc Fehling, 2018/10/08) diff --git a/include/deal.II/distributed/active_fe_indices_transfer.h b/include/deal.II/distributed/active_fe_indices_transfer.h index 3392015b76..c1c8702fe4 100644 --- a/include/deal.II/distributed/active_fe_indices_transfer.h +++ b/include/deal.II/distributed/active_fe_indices_transfer.h @@ -42,7 +42,7 @@ namespace parallel * a refined cell inherit the `active_fe_index` from their parent. If * cells get coarsened into one, the latter will get the least dominating * `active_fe_index` amongst its children, as determined by the function - * hp::FECollection::find_least_face_dominating_fe(). + * hp::FECollection::find_least_face_dominating_fe_in_collection(). * * @note If you use more than one object to attach data to a * parallel::distributed::Triangulation at the same time (e.g. a diff --git a/include/deal.II/distributed/solution_transfer.h b/include/deal.II/distributed/solution_transfer.h index 9df10505eb..a0d47d7544 100644 --- a/include/deal.II/distributed/solution_transfer.h +++ b/include/deal.II/distributed/solution_transfer.h @@ -187,8 +187,8 @@ namespace parallel * unpacked later with the same index on its children. If cells get * coarsened into one, data will be packed on the latter with the least * dominating `active_fe_index` amongst its children, as determined by the - * function hp::FECollection::find_least_face_dominating_fe(), and unpacked - * later on the same cell with the same index. + * function hp::FECollection::find_least_face_dominating_fe_in_collection(), + * and unpacked on the same cell with the same index. * * Code snippets to demonstrate the usage of the * parallel::distributed::SolutionTransfer class with hp::DoFHandler diff --git a/include/deal.II/hp/fe_collection.h b/include/deal.II/hp/fe_collection.h index 15a41dde80..7284bdd119 100644 --- a/include/deal.II/hp/fe_collection.h +++ b/include/deal.II/hp/fe_collection.h @@ -277,7 +277,7 @@ namespace hp * * If the function is not able to find a finite element that satisfies * the description above, the function - * returns numbers::invalid_unsigned_int . An example would go like this: + * returns numbers::invalid_unsigned_int. An example would go like this: * If the FECollection consists of `{FE_Nothing * x FE_Nothing, FE_Q(1)xFE_Q(2), FE_Q(2)xFE_Q(1)}` with @p fes as `{1}`, * the function will not find a most dominating element as the default @@ -289,6 +289,16 @@ namespace hp * numbers::invalid_unsigned_int. */ unsigned int + find_least_face_dominating_fe_in_collection( + const std::set &fes) const; + + /** + * @copydoc FECollection::find_least_face_dominating_fe_in_collection() + * + * @deprecated This function has been renamed. Use + * hp::FECollection::find_least_face_dominating_fe_in_collection() instead. + */ + DEAL_II_DEPRECATED unsigned int find_least_face_dominating_fe(const std::set &fes) const; /** diff --git a/source/distributed/active_fe_indices_transfer.cc b/source/distributed/active_fe_indices_transfer.cc index eefa36de66..e956c7f6bb 100644 --- a/source/distributed/active_fe_indices_transfer.cc +++ b/source/distributed/active_fe_indices_transfer.cc @@ -138,8 +138,9 @@ namespace parallel fe_indices_children.insert(child->active_fe_index()); } - fe_index = dof_handler->get_fe().find_least_face_dominating_fe( - fe_indices_children); + fe_index = dof_handler->get_fe() + .find_least_face_dominating_fe_in_collection( + fe_indices_children); Assert(fe_index != numbers::invalid_unsigned_int, ExcMessage( diff --git a/source/distributed/cell_weights.cc b/source/distributed/cell_weights.cc index 750375b985..3c29bf7156 100644 --- a/source/distributed/cell_weights.cc +++ b/source/distributed/cell_weights.cc @@ -157,8 +157,9 @@ namespace parallel fe_indices_children.insert( cell->child(child_index)->active_fe_index()); - fe_index = dof_handler->get_fe().find_least_face_dominating_fe( - fe_indices_children); + fe_index = dof_handler->get_fe() + .find_least_face_dominating_fe_in_collection( + fe_indices_children); Assert(fe_index != numbers::invalid_unsigned_int, ExcMessage( diff --git a/source/distributed/solution_transfer.cc b/source/distributed/solution_transfer.cc index 40ebf57823..e1b57c8da4 100644 --- a/source/distributed/solution_transfer.cc +++ b/source/distributed/solution_transfer.cc @@ -252,9 +252,9 @@ namespace parallel fe_indices_children.insert( cell->child(child_index)->active_fe_index()); - fe_index = - dof_handler->get_fe_collection() - .find_least_face_dominating_fe(fe_indices_children); + fe_index = dof_handler->get_fe_collection() + .find_least_face_dominating_fe_in_collection( + fe_indices_children); Assert( fe_index != numbers::invalid_unsigned_int, diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 93c7132fbc..c0ecfcdefa 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -1284,19 +1284,21 @@ namespace DoFTools // 2) there is no dominating FE among sub faces (e.g. // Q1xQ2 vs Q2xQ1), but subfaces still dominate mother // face (e.g. Q2xQ2). To cover this case we would have - // to use find_least_face_dominating_fe() of - // FECollection with fe_indices of sub faces. 3) + // to use find_least_face_dominating_fe_in_collection() + // of FECollection with fe_indices of sub faces. 3) // Finally, it could happen that we got here because // neither_element_dominates (e.g. Q1xQ1xQ2 and Q1xQ2xQ1 // for subfaces and Q2xQ1xQ1 for mother face). This - // requires usage of find_least_face_dominating_fe() - // with fe_indices of sub-faces and the mother face. + // requires usage of + // find_least_face_dominating_fe_in_collection() with + // fe_indices of sub-faces and the mother face. // Note that the last solution covers the first two // scenarios, thus we stick with it assuming that we // won't lose much time/efficiency. const unsigned int dominating_fe_index = - fe_collection.find_least_face_dominating_fe( - fe_ind_face_subface); + fe_collection + .find_least_face_dominating_fe_in_collection( + fe_ind_face_subface); AssertThrow( dominating_fe_index != numbers::invalid_unsigned_int, ExcMessage( @@ -1594,7 +1596,9 @@ namespace DoFTools const dealii::hp::FECollection &fe_collection = dof_handler.get_fe_collection(); const unsigned int dominating_fe_index = - fe_collection.find_least_face_dominating_fe(fes); + fe_collection + .find_least_face_dominating_fe_in_collection( + fes); AssertThrow( dominating_fe_index != diff --git a/source/fe/fe_enriched.cc b/source/fe/fe_enriched.cc index a7f482d8ca..6eb0b2069c 100644 --- a/source/fe/fe_enriched.cc +++ b/source/fe/fe_enriched.cc @@ -1258,13 +1258,13 @@ namespace ColorEnriched * Each time we build constraints at the * interface between two different FE_Enriched, we look for the least * dominating FE via - * hp::FECollection< dim, spacedim >::find_least_face_dominating_fe(). - * If we don't take further actions, we may find a dominating FE that - * is too restrictive, i.e. enriched FE consisting of only FE_Nothing. - * New elements needs to be added to FECollection object to help - * find the correct enriched FE underlying the spaces in the - * adjacent cells. This is done by creating an appropriate - * set in fe_sets and a call to the function + * hp::FECollection< dim, spacedim + * >::find_least_face_dominating_fe_in_collection(). If we don't take + * further actions, we may find a dominating FE that is too restrictive, + * i.e. enriched FE consisting of only FE_Nothing. New elements needs to + * be added to FECollection object to help find the correct enriched FE + * underlying the spaces in the adjacent cells. This is done by creating + * an appropriate set in fe_sets and a call to the function * make_fe_collection_from_colored_enrichments at a later stage. * * Consider a domain with three predicates and hence with three different @@ -1275,7 +1275,7 @@ namespace ColorEnriched * on adjacent cells, an enriched FE [0 0 1] should exist and is * found as the least dominating finite element for the two cells by * DoFTools::make_hanging_node_constraints using a call to the function - * hp::FECollection::find_least_face_dominating_fe. + * hp::FECollection::find_least_face_dominating_fe_in_collection. * Denoting the fe set in adjacent cells as {1,3} and {2,3}, this * implies that an fe set {3} needs to be added! Based on the * predicate configuration, this may not be automatically done without diff --git a/source/hp/fe_collection.cc b/source/hp/fe_collection.cc index 73b086645d..e01b11a101 100644 --- a/source/hp/fe_collection.cc +++ b/source/hp/fe_collection.cc @@ -24,9 +24,12 @@ namespace hp { template unsigned int - FECollection::find_least_face_dominating_fe( + FECollection::find_least_face_dominating_fe_in_collection( const std::set &fes) const { + for (auto it = fes.cbegin(); it != fes.cend(); ++it) + AssertIndexRange(*it, finite_elements.size()); + // If the set of elements to be dominated contains only a single element X, // then by definition the dominating set contains this single element X // (because each element can dominate itself). There may also be others, @@ -39,27 +42,18 @@ namespace hp if (fes.size() == 1) return *fes.begin(); - const hp::FECollection &fe_collection = *this; - std::set candidate_fes; + std::set candidate_fes; // first loop over all FEs and check which can dominate those given in @p fes: - for (unsigned int cur_fe = 0; cur_fe < fe_collection.size(); cur_fe++) + for (unsigned int cur_fe = 0; cur_fe < finite_elements.size(); ++cur_fe) { FiniteElementDomination::Domination domination = FiniteElementDomination::no_requirements; // check if cur_fe can dominate all FEs in @p fes: - for (std::set::const_iterator it = fes.begin(); - it != fes.end(); - ++it) - { - Assert(*it < fe_collection.size(), - ExcIndexRangeType(*it, - 0, - fe_collection.size())); - domination = - domination & fe_collection[cur_fe].compare_for_face_domination( - fe_collection[*it]); - } + for (const auto &other_fe : fes) + domination = + domination & finite_elements[cur_fe]->compare_for_face_domination( + *finite_elements[other_fe]); // if we found dominating element, keep them in a set. if ( @@ -75,27 +69,24 @@ namespace hp return *candidate_fes.begin(); } else - for (std::set::const_iterator it = candidate_fes.begin(); - it != candidate_fes.end(); - ++it) + for (const auto ¤t_fe : candidate_fes) { FiniteElementDomination::Domination domination = FiniteElementDomination::no_requirements; - for (std::set::const_iterator ito = - candidate_fes.begin(); - ito != candidate_fes.end(); - ++ito) - if (it != ito) - { - domination = - domination & fe_collection[*it].compare_for_face_domination( - fe_collection[*ito]); - } - - if ( - domination == FiniteElementDomination::other_element_dominates || - domination == FiniteElementDomination::either_element_can_dominate /*covers cases like candidate_fes={Q1,Q1}*/) - return *it; + + for (const auto &other_fe : candidate_fes) + if (current_fe != other_fe) + domination = + domination & + finite_elements[current_fe]->compare_for_face_domination( + *finite_elements[other_fe]); + + if ((domination == + FiniteElementDomination::other_element_dominates) || + (domination == + FiniteElementDomination::either_element_can_dominate + /*covers cases like candidate_fes={Q1,Q1}*/)) + return current_fe; } // We couldn't find the FE, return invalid_unsigned_int : return numbers::invalid_unsigned_int; @@ -103,6 +94,16 @@ namespace hp + template + unsigned int + FECollection::find_least_face_dominating_fe( + const std::set &fes) const + { + return find_least_face_dominating_fe_in_collection(fes); + } + + + template FECollection::FECollection( const FiniteElement &fe) diff --git a/tests/fe/fe_enriched_color_08.cc b/tests/fe/fe_enriched_color_08.cc index 64c86c3436..945f6b9a11 100644 --- a/tests/fe/fe_enriched_color_08.cc +++ b/tests/fe/fe_enriched_color_08.cc @@ -269,7 +269,8 @@ main(int argc, char **argv) } deallog << "Dominating set for 1 and 2: " - << fe_collection.find_least_face_dominating_fe({1, 2}) << std::endl; + << fe_collection.find_least_face_dominating_fe_in_collection({1, 2}) + << std::endl; dof_handler.distribute_dofs(fe_collection); diff --git a/tests/hp/fe_collection_05.cc b/tests/hp/fe_collection_05.cc index af047f07dd..5ad07d1344 100644 --- a/tests/hp/fe_collection_05.cc +++ b/tests/hp/fe_collection_05.cc @@ -15,7 +15,7 @@ /* clang-format off */ -// test the results of FECollection::find_least_face_dominating_fe(), namely for: +// test the results of FECollection::find_least_face_dominating_fe_in_collection(), namely for: // {Q1, Q2, Q3, Q4} with {2,3} => Q3 2 // {Q1xQ1, Q2xQ2, Q3xQ4, Q4xQ3} with {2,3} => Q2xQ2 1 // {Q1xQ1, Q3xQ4, Q4xQ3} with {1,2} => Q1xQ1 0 @@ -53,7 +53,8 @@ test() fe_collection.push_back(FE_Q(2)); fe_collection.push_back(FE_Q(3)); fe_collection.push_back(FE_Q(4)); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } // {Q1xQ1, Q2xQ2, Q3xQ4, Q4xQ3} @@ -63,7 +64,8 @@ test() fe_collection.push_back(FESystem(FE_Q(2), 1, FE_Q(2), 1)); fe_collection.push_back(FESystem(FE_Q(3), 1, FE_Q(4), 1)); fe_collection.push_back(FESystem(FE_Q(4), 1, FE_Q(3), 1)); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } // {Q1xQ1, Q3xQ4, Q4xQ3} @@ -75,7 +77,8 @@ test() std::set fes; fes.insert(1); fes.insert(2); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } // {0x0, 0x0, Q1x0, 0xQ1} @@ -89,7 +92,8 @@ test() FESystem(FE_Q(1), 1, FE_Nothing(), 1)); fe_collection.push_back( FESystem(FE_Nothing(), 1, FE_Q(1), 1)); - const unsigned int ind = fe_collection.find_least_face_dominating_fe(fes); + const unsigned int ind = + fe_collection.find_least_face_dominating_fe_in_collection(fes); if (ind == numbers::invalid_unsigned_int) deallog << "numbers::invalid_unsigned_int" << std::endl; else @@ -108,7 +112,8 @@ test() FESystem(FE_Q(1), 1, FE_Nothing(1, true), 1)); fe_collection.push_back( FESystem(FE_Nothing(1, true), 1, FE_Q(1), 1)); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } @@ -119,7 +124,8 @@ test() fe_collection.push_back(FESystem(FE_Q(1), 1, FE_Q(1), 1)); fe_collection.push_back(FESystem(FE_Q(2), 1, FE_Q(1), 1)); fe_collection.push_back(FESystem(FE_Q(1), 1, FE_Q(2), 1)); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } // {Q4xQ4, Q5xQ5, Q3xQ4, Q4xQ3} @@ -129,7 +135,8 @@ test() fe_collection.push_back(FESystem(FE_Q(5), 1, FE_Q(5), 1)); fe_collection.push_back(FESystem(FE_Q(3), 1, FE_Q(4), 1)); fe_collection.push_back(FESystem(FE_Q(4), 1, FE_Q(3), 1)); - const unsigned int ind = fe_collection.find_least_face_dominating_fe(fes); + const unsigned int ind = + fe_collection.find_least_face_dominating_fe_in_collection(fes); if (ind == numbers::invalid_unsigned_int) deallog << "numbers::invalid_unsigned_int" << std::endl; else @@ -145,7 +152,8 @@ test() fe_collection.push_back(FE_Q(3)); std::set fes; fes.insert(3); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } // {Q3, Q4, Q1, Q1} @@ -155,7 +163,8 @@ test() fe_collection.push_back(FE_Q(4)); fe_collection.push_back(FE_Q(1)); fe_collection.push_back(FE_Q(1)); - deallog << fe_collection.find_least_face_dominating_fe(fes) << std::endl; + deallog << fe_collection.find_least_face_dominating_fe_in_collection(fes) + << std::endl; } }