]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Moved `dominated_future_fe_on_children` from class member to internal namespace. 11966/head
authorMarc Fehling <mafehling.git@gmail.com>
Fri, 26 Mar 2021 04:09:31 +0000 (22:09 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Fri, 26 Mar 2021 23:26:55 +0000 (17:26 -0600)
14 files changed:
doc/news/changes/minor/20201005Fehling [deleted file]
include/deal.II/distributed/cell_weights.h
include/deal.II/dofs/dof_accessor.h
include/deal.II/dofs/dof_accessor.templates.h
include/deal.II/dofs/dof_handler.h
source/distributed/cell_weights.cc
source/distributed/error_predictor.cc
source/distributed/solution_transfer.cc
source/dofs/dof_handler.cc
source/dofs/dof_handler.inst.in
source/hp/refinement.cc
source/numerics/solution_transfer.cc
tests/hp/dominated_future_fe_on_children_01.cc [moved from tests/grid/accessor_04.cc with 90% similarity]
tests/hp/dominated_future_fe_on_children_01.output [moved from tests/grid/accessor_04.output with 100% similarity]

diff --git a/doc/news/changes/minor/20201005Fehling b/doc/news/changes/minor/20201005Fehling
deleted file mode 100644 (file)
index a9d4679..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-New: Helper function DoFCellAccessor::dominated_future_fe_on_children()
-to clean up code for hp-coarsening.
-<br>
-(Marc Fehling, 2020/10/05)
index 169308862722df193454fe01c380924aaca03a82..e8c16491789ee78ec7191524c577d578f6ab7929 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <deal.II/distributed/tria_base.h>
 
-#include <deal.II/hp/dof_handler.h>
+#include <deal.II/dofs/dof_handler.h>
 
 
 DEAL_II_NAMESPACE_OPEN
index c3b39e4212d4545432af424f109e9a3ba168bc6d..2adb5e7a4319106597d46deeb4391c07ff69455b 100644 (file)
@@ -2060,48 +2060,6 @@ public:
    */
   void
   clear_future_fe_index() const;
-
-  /**
-   * Return the index of the finite element from the entire hp::FECollection
-   * that is dominated by those assigned as future finite elements to the
-   * children of this cell.
-   *
-   * We find the corresponding finite element among the future finite elements
-   * on the children of this cell. If none of them qualify, we extend our search
-   * on the whole hp::FECollection, which is the element that describes the
-   * smallest finite element space that includes all future finite elements
-   * assigned to the children. If the function is not able to find a finite
-   * element at all, an assertion will be triggered.
-   *
-   * In this way, we determine the finite element of the parent cell in case of
-   * h-coarsening in the hp-context.
-   *
-   * @note This function can only be called on direct parent cells, i.e.,
-   * non-active cells whose children are all active.
-   */
-  unsigned int
-  dominated_future_fe_on_children() const;
-  /**
-   * @}
-   */
-
-  /**
-   * @name Exceptions
-   */
-  /**
-   * @{
-   */
-
-  /**
-   * Exception
-   *
-   * @ingroup Exceptions
-   */
-  DeclExceptionMsg(
-    ExcNoDominatedFiniteElementOnChildren,
-    "No FiniteElement has been found in your FECollection that is "
-    "dominated by all children of a cell you are trying to coarsen!");
-
   /**
    * @}
    */
index 265f83249ef82361d8f17607380bcc3d3f7f2a5f..3ed210610f17e4504c1c918d62f3b49a0cacdf38 100644 (file)
@@ -2934,45 +2934,6 @@ DoFCellAccessor<dimension_, space_dimension_, level_dof_access>::
 
 
 
-template <int dimension_, int space_dimension_, bool level_dof_access>
-inline unsigned int
-DoFCellAccessor<dimension_, space_dimension_, level_dof_access>::
-  dominated_future_fe_on_children() const
-{
-  Assert(!this->is_active(),
-         ExcMessage(
-           "You ask for information on children of this cell which is only "
-           "available for active cells. This cell has no children."));
-
-  std::set<unsigned int> future_fe_indices_children;
-  for (const auto &child : this->child_iterators())
-    {
-      Assert(
-        child->is_active(),
-        ExcMessage(
-          "You ask for information on children of this cell which is only "
-          "available for active cells. One of its children is not active."));
-      Assert(child->is_locally_owned(),
-             ExcMessage(
-               "You ask for information on children of this cell which is only "
-               "available for locally owned cells. One of its children is not "
-               "locally owned."));
-      future_fe_indices_children.insert(child->future_fe_index());
-    }
-  Assert(!future_fe_indices_children.empty(), ExcInternalError());
-
-  const unsigned int future_fe_index =
-    this->dof_handler->fe_collection.find_dominated_fe_extended(
-      future_fe_indices_children, /*codim=*/0);
-
-  Assert(future_fe_index != numbers::invalid_unsigned_int,
-         ExcNoDominatedFiniteElementOnChildren());
-
-  return future_fe_index;
-}
-
-
-
 template <int dimension_, int space_dimension_, bool level_dof_access>
 template <typename number, typename OutputVector>
 inline void
index c4c15ab2e8c9be9958bbdcd9c1ea055a246ac55b..6353304739bb4e1df8cddd8001c480f4e63075e7 100644 (file)
@@ -1817,6 +1817,46 @@ private:
 #endif
 };
 
+namespace internal
+{
+  namespace hp
+  {
+    namespace DoFHandlerImplementation
+    {
+      /**
+       * Return the index of the finite element from the entire hp::FECollection
+       * that is dominated by those assigned as future finite elements to the
+       * children of @p parent.
+       *
+       * We find the corresponding finite element among the future finite
+       * elements on the children of this cell. If none of them qualify, we
+       * extend our search on the whole hp::FECollection, which is the element
+       * that describes the smallest finite element space that includes all
+       * future finite elements assigned to the children. If the function is not
+       * able to find a finite element at all, an assertion will be triggered.
+       *
+       * In this way, we determine the finite element of the parent cell in case
+       * of h-coarsening in the hp-context.
+       *
+       * @note This function can only be called on direct parent cells, i.e.,
+       * non-active cells whose children are all active.
+       */
+      template <int dim, int spacedim = dim>
+      unsigned int
+      dominated_future_fe_on_children(
+        const typename DoFHandler<dim, spacedim>::cell_iterator &parent);
+
+      /**
+       * Exception
+       */
+      DeclExceptionMsg(
+        ExcNoDominatedFiniteElementOnChildren,
+        "No FiniteElement has been found in your FECollection that is "
+        "dominated by all children of a cell you are trying to coarsen!");
+    } // namespace DoFHandlerImplementation
+  }   // namespace hp
+} // namespace internal
+
 #ifndef DOXYGEN
 
 /* ----------------------- Inline functions ----------------------------------
index 0688d1db9822068fdf5e1d38b0bd191957f20112..d493728065ba6a943082cd309ae6be9cd713c061 100644 (file)
@@ -200,7 +200,8 @@ namespace parallel
                      dim>::ExcInconsistentCoarseningFlags());
 #endif
 
-          fe_index = cell->dominated_future_fe_on_children();
+          fe_index = dealii::internal::hp::DoFHandlerImplementation::
+            dominated_future_fe_on_children<dim, spacedim>(cell);
           break;
 
         default:
index 1fb13c38f94561fe00a19a98f80419d7cfd266ed..df2f4eb39c94287d4ba61f7631f12ef1edff8fd1 100644 (file)
@@ -240,7 +240,8 @@ namespace parallel
 #  endif
 
                 const unsigned int future_fe_index =
-                  cell->dominated_future_fe_on_children();
+                  dealii::internal::hp::DoFHandlerImplementation::
+                    dominated_future_fe_on_children<dim, spacedim>(cell);
 
                 const unsigned int future_fe_degree =
                   dof_handler->get_fe_collection()[future_fe_index].degree;
index 50104891cdffcfb17f1b467041c90506e85ace7a..037d0d70e26ece88e6c15c3097a91fa714f92bc1 100644 (file)
@@ -324,7 +324,10 @@ namespace parallel
                              dim>::ExcInconsistentCoarseningFlags());
 #  endif
 
-                  fe_index = cell->dominated_future_fe_on_children();
+                  fe_index = dealii::internal::hp::DoFHandlerImplementation::
+                    dominated_future_fe_on_children<
+                      dim,
+                      DoFHandlerType::space_dimension>(cell);
                   break;
                 }
 
index 0fb78f4f63d5ff8cb42349a7400977e7067b29da..9cffc4ccc9d26fab472681a9ec241655362a3532 100644 (file)
@@ -1000,6 +1000,8 @@ namespace internal
     };
   } // namespace DoFHandlerImplementation
 
+
+
   namespace hp
   {
     namespace DoFHandlerImplementation
@@ -1872,7 +1874,9 @@ namespace internal
 #endif
 
                         const unsigned int fe_index =
-                          parent->dominated_future_fe_on_children();
+                          dealii::internal::hp::DoFHandlerImplementation::
+                            dominated_future_fe_on_children<dim, spacedim>(
+                              parent);
 
                         fe_transfer->coarsened_cells_fe_index.insert(
                           {parent, fe_index});
@@ -1969,12 +1973,74 @@ namespace internal
                                                      /*codim=*/0);
 
           Assert(dominated_fe_index != numbers::invalid_unsigned_int,
-                 (typename dealii::DoFCellAccessor<dim, spacedim, false>::
-                    ExcNoDominatedFiniteElementOnChildren()));
+                 ExcNoDominatedFiniteElementOnChildren());
 
           return dominated_fe_index;
         }
+
+
+        /**
+         * Return the index of the finite element from the entire
+         * hp::FECollection that is dominated by those assigned as future finite
+         * elements to the
+         * children of @p parent.
+         *
+         * See documentation in the header file for more information.
+         */
+        template <int dim, int spacedim>
+        static unsigned int
+        dominated_future_fe_on_children(
+          const typename DoFHandler<dim, spacedim>::cell_iterator &parent)
+        {
+          Assert(
+            !parent->is_active(),
+            ExcMessage(
+              "You ask for information on children of this cell which is only "
+              "available for active cells. This cell has no children."));
+
+          std::set<unsigned int> future_fe_indices_children;
+          for (const auto &child : parent->child_iterators())
+            {
+              Assert(
+                child->is_active(),
+                ExcMessage(
+                  "You ask for information on children of this cell which is only "
+                  "available for active cells. One of its children is not active."));
+              Assert(
+                child->is_locally_owned(),
+                ExcMessage(
+                  "You ask for information on children of this cell which is only "
+                  "available for locally owned cells. One of its children is not "
+                  "locally owned."));
+              future_fe_indices_children.insert(child->future_fe_index());
+            }
+          Assert(!future_fe_indices_children.empty(), ExcInternalError());
+
+          const unsigned int future_fe_index =
+            parent->get_dof_handler().fe_collection.find_dominated_fe_extended(
+              future_fe_indices_children,
+              /*codim=*/0);
+
+          Assert(future_fe_index != numbers::invalid_unsigned_int,
+                 ExcNoDominatedFiniteElementOnChildren());
+
+          return future_fe_index;
+        }
       };
+
+
+
+      /**
+       * Public wrapper for the above function.
+       */
+      template <int dim, int spacedim>
+      unsigned int
+      dominated_future_fe_on_children(
+        const typename DoFHandler<dim, spacedim>::cell_iterator &parent)
+      {
+        return Implementation::dominated_future_fe_on_children<dim, spacedim>(
+          parent);
+      }
     } // namespace DoFHandlerImplementation
   }   // namespace hp
 } // namespace internal
index 9d572717845046a1f1a35d16fa46ce3ff789b036..b6fb6cb84011fd8ce1583c976cc17b7cd47c795c 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 1998 - 2020 by the deal.II authors
+// Copyright (C) 1998 - 2021 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -22,6 +22,12 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS)
     template std::string internal::policy_to_string(
       const dealii::internal::DoFHandlerImplementation::Policy::
         PolicyBase<deal_II_dimension, deal_II_space_dimension> &policy);
+
+    template unsigned int internal::hp::DoFHandlerImplementation::
+      dominated_future_fe_on_children<deal_II_dimension,
+                                      deal_II_space_dimension>(
+        const typename DoFHandler<deal_II_dimension,
+                                  deal_II_space_dimension>::cell_iterator &);
 #endif
   }
 
index def4bb4a8c264c711c841ffb67c79eee0ad29458..5eebda33550b251fc6115545874f462ec1b8a956 100644 (file)
@@ -573,7 +573,8 @@ namespace hp
 #endif
 
                     parent_future_fe_index =
-                      parent->dominated_future_fe_on_children();
+                      dealii::internal::hp::DoFHandlerImplementation::
+                        dominated_future_fe_on_children<dim, spacedim>(parent);
 
                     future_fe_indices_on_coarsened_cells.insert(
                       {parent, parent_future_fe_index});
index c67ae4dc419e8ce770e9a1d417008ffbcd0c98e3..49cd4a72b6325ab0c9749bd56b7a3392af182e11 100644 (file)
@@ -397,10 +397,8 @@ SolutionTransfer<dim, VectorType, DoFHandlerType>::
               fe_indices_children, /*codim=*/0);
 
           Assert(target_fe_index != numbers::invalid_unsigned_int,
-                 (typename dealii::DoFCellAccessor<
-                   dim,
-                   DoFHandlerType::space_dimension,
-                   false>::ExcNoDominatedFiniteElementOnChildren()));
+                 internal::hp::DoFHandlerImplementation::
+                   ExcNoDominatedFiniteElementOnChildren());
 
           const unsigned int dofs_per_cell =
             dof_handler->get_fe(target_fe_index).n_dofs_per_cell();
similarity index 90%
rename from tests/grid/accessor_04.cc
rename to tests/hp/dominated_future_fe_on_children_01.cc
index 6593fd965d99ce4f9583017aab7f12183775174c..0040a04a62ea854d229fcfc9c9a64ecc0ef90c6e 100644 (file)
@@ -16,7 +16,7 @@
 
 
 // Verify functionality of
-// DoFCellAccessor:dominated_future_fe_on_children()
+// internal::hp::DoFHandlerImplementation::dominated_future_fe_on_children()
 
 #include <deal.II/base/logstream.h>
 
@@ -52,7 +52,8 @@ test()
 
   const auto &       parent = dofh.begin(/*level=*/0);
   const unsigned int parent_future_fe =
-    parent->dominated_future_fe_on_children();
+    internal::hp::DoFHandlerImplementation::dominated_future_fe_on_children<
+      dim>(parent);
 
   deallog << parent_future_fe << 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.