]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Refactored FECollection::find_least_face_dominating_fe_in_collection(). 7304/head
authorMarc Fehling <marc.fehling@gmx.net>
Mon, 8 Oct 2018 20:50:14 +0000 (14:50 -0600)
committerMarc Fehling <marc.fehling@gmx.net>
Wed, 10 Oct 2018 00:16:51 +0000 (18:16 -0600)
12 files changed:
doc/news/changes/incompatibilities/20181008Fehling [new file with mode: 0644]
include/deal.II/distributed/active_fe_indices_transfer.h
include/deal.II/distributed/solution_transfer.h
include/deal.II/hp/fe_collection.h
source/distributed/active_fe_indices_transfer.cc
source/distributed/cell_weights.cc
source/distributed/solution_transfer.cc
source/dofs/dof_tools_constraints.cc
source/fe/fe_enriched.cc
source/hp/fe_collection.cc
tests/fe/fe_enriched_color_08.cc
tests/hp/fe_collection_05.cc

diff --git a/doc/news/changes/incompatibilities/20181008Fehling b/doc/news/changes/incompatibilities/20181008Fehling
new file mode 100644 (file)
index 0000000..c31c8d4
--- /dev/null
@@ -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().
+<br>
+(Marc Fehling, 2018/10/08)
index 3392015b76bad11ddb5442b8ea4cd691da4144fd..c1c8702fe4e70bdf2545d77ad1a8cf9fbec538b6 100644 (file)
@@ -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
index 9df10505ebb945007f1fbae9a21c6f092fb5fdfa..a0d47d7544cca46071e65fe276addc1a520a74f3 100644 (file)
@@ -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
index 15a41dde80e679197f5326cf54f265f6cc60eb79..7284bdd119e85b5db9d81f08c33b3e840a204f11 100644 (file)
@@ -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<unsigned int> &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<unsigned int> &fes) const;
 
     /**
index eefa36de66ab468a9ef6fdedf8460dd12f459c73..e956c7f6bb570460c8f7283bcf7e44bc9ecafccd 100644 (file)
@@ -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(
index 750375b98581f74236648a3bffd65c56e05167ba..3c29bf7156680380178c9365b63f9d797449ac91 100644 (file)
@@ -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(
index 40ebf5782365bd147f85fa06db979139f44624d1..e1b57c8da48a729f9802e56f0c98b7626a51f9da 100644 (file)
@@ -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,
index 93c7132fbc959efcce613bfc6fff2fab21a4b327..c0ecfcdefae6a9cc518538005bd775cdf65393bd 100644 (file)
@@ -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<dim, spacedim>
                               &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 !=
index a7f482d8cab8d7de2a62c19806f80e6c732755e1..6eb0b2069c87965e2276febfd242943c9fd4c3b3 100644 (file)
@@ -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
index 73b086645df0875205da2e9d5a8343cdbb2f75f9..e01b11a101d96b4194bddc7457f201b06eb35ba0 100644 (file)
@@ -24,9 +24,12 @@ namespace hp
 {
   template <int dim, int spacedim>
   unsigned int
-  FECollection<dim, spacedim>::find_least_face_dominating_fe(
+  FECollection<dim, spacedim>::find_least_face_dominating_fe_in_collection(
     const std::set<unsigned int> &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<dim, spacedim> &fe_collection = *this;
-    std::set<unsigned int>                 candidate_fes;
+    std::set<unsigned int> 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<unsigned int>::const_iterator it = fes.begin();
-             it != fes.end();
-             ++it)
-          {
-            Assert(*it < fe_collection.size(),
-                   ExcIndexRangeType<unsigned int>(*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<unsigned int>::const_iterator it = candidate_fes.begin();
-           it != candidate_fes.end();
-           ++it)
+      for (const auto &current_fe : candidate_fes)
         {
           FiniteElementDomination::Domination domination =
             FiniteElementDomination::no_requirements;
-          for (std::set<unsigned int>::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 <int dim, int spacedim>
+  unsigned int
+  FECollection<dim, spacedim>::find_least_face_dominating_fe(
+    const std::set<unsigned int> &fes) const
+  {
+    return find_least_face_dominating_fe_in_collection(fes);
+  }
+
+
+
   template <int dim, int spacedim>
   FECollection<dim, spacedim>::FECollection(
     const FiniteElement<dim, spacedim> &fe)
index 64c86c34365fce94e492bce7c76eab74f33fde17..945f6b9a118c3834316962e8abc20573b5f4cce5 100644 (file)
@@ -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);
 
index af047f07dd58f5865a54a3e39dd89bd414186d76..5ad07d1344514b52c505e427b6284f552c1c7eb2 100644 (file)
@@ -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<dim>(2));
     fe_collection.push_back(FE_Q<dim>(3));
     fe_collection.push_back(FE_Q<dim>(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<dim>(FE_Q<dim>(2), 1, FE_Q<dim>(2), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(3), 1, FE_Q<dim>(4), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(4), 1, FE_Q<dim>(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<unsigned int> 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<dim>(FE_Q<dim>(1), 1, FE_Nothing<dim>(), 1));
     fe_collection.push_back(
       FESystem<dim>(FE_Nothing<dim>(), 1, FE_Q<dim>(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<dim>(FE_Q<dim>(1), 1, FE_Nothing<dim>(1, true), 1));
     fe_collection.push_back(
       FESystem<dim>(FE_Nothing<dim>(1, true), 1, FE_Q<dim>(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<dim>(FE_Q<dim>(1), 1, FE_Q<dim>(1), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(2), 1, FE_Q<dim>(1), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(1), 1, FE_Q<dim>(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<dim>(FE_Q<dim>(5), 1, FE_Q<dim>(5), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(3), 1, FE_Q<dim>(4), 1));
     fe_collection.push_back(FESystem<dim>(FE_Q<dim>(4), 1, FE_Q<dim>(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<dim>(3));
     std::set<unsigned int> 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<dim>(4));
     fe_collection.push_back(FE_Q<dim>(1));
     fe_collection.push_back(FE_Q<dim>(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;
   }
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.