From 57d256ee2338e05d949efe39fca3863621d09715 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 25 Aug 2021 13:09:45 -0600 Subject: [PATCH] Short-circuit compute_hp_dof_identities() when possible. --- source/hp/fe_collection.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source/hp/fe_collection.cc b/source/hp/fe_collection.cc index 8b08beac85..0089db25a9 100644 --- a/source/hp/fe_collection.cc +++ b/source/hp/fe_collection.cc @@ -303,6 +303,40 @@ namespace hp const unsigned int, const unsigned int)> & query_identities) { + // Let's deal with the easy cases first. If the set of fe indices is empty + // or has only one entry, then there are no identities: + if (fes.size() <= 1) + return {}; + + // If the set has two entries, then the + // FiniteElement::hp_*_dof_identities() function directly returns what we + // need. We just need to prefix its output with the respective fe indices: + if (fes.size() == 2) + { + const unsigned int fe_index_1 = *fes.begin(); + const unsigned int fe_index_2 = *(++fes.begin()); + const auto reduced_identities = + query_identities(fe_index_1, fe_index_2); + + std::vector>> + complete_identities; + + for (const auto &reduced_identity : reduced_identities) + { + // Each identity returned by query_identities() is a pair of + // dof indices. Prefix each with its fe index and put the result + // into a vector + std::set> + complete_identity = {{fe_index_1, reduced_identity.first}, + {fe_index_2, reduced_identity.second}}; + complete_identities.emplace_back(std::move(complete_identity)); + } + + return complete_identities; + } + + // Now for the general case of three or more elements: + // // Consider all degrees of freedom of the identified elements (represented // via (fe_index,dof_index) pairs) as the nodes in a graph. Then draw // edges for all DoFs that are identified based on what the elements -- 2.39.5