]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduced DoFCellAccessor:get_future_fe(). 8672/head
authorMarc Fehling <marc.fehling@gmx.net>
Fri, 30 Aug 2019 21:08:10 +0000 (23:08 +0200)
committerMarc Fehling <marc.fehling@gmx.net>
Sat, 31 Aug 2019 00:39:42 +0000 (02:39 +0200)
include/deal.II/dofs/dof_accessor.h
include/deal.II/dofs/dof_accessor.templates.h
tests/hp/future_fe_indices.cc
tests/hp/future_fe_indices.output

index d0458fdfaa53123fb0788143ea42f81d2a395114..e1bd0a72c3c2059a4aae2950c7b6e765588dfc0c 100644 (file)
@@ -1946,6 +1946,28 @@ public:
    * @{
    */
 
+  /**
+   * Return the finite element that will be assigned to this cell next time the
+   * triangulation gets refined and coarsened. If no future finite element has
+   * been specified for this cell via the set_future_fe_index() function, the
+   * active one will remain unchanged, in which case the active finite element
+   * will be returned.
+   *
+   * For non-hp DoF handlers, this is of course always the same element,
+   * independent of the cell we are presently on, but for hp DoF handlers, this
+   * may change from cell to cell.
+   *
+   * @note Since degrees of freedom only exist on active cells for
+   * hp::DoFHandler (i.e., there is currently no implementation of multilevel
+   * hp::DoFHandler objects), it does not make sense to query the finite
+   * element on non-active cells since they do not have finite element spaces
+   * associated with them without having any degrees of freedom. Consequently,
+   * this function will produce an exception when called on non-active cells.
+   */
+  const FiniteElement<DoFHandlerType::dimension,
+                      DoFHandlerType::space_dimension> &
+  get_future_fe() const;
+
   /**
    * Return the fe_index of the finite element that will be assigned to this
    * cell next time the triangulation gets refined and coarsened. If no future
index bb90ee4087a53ab0da27d2d558a273cd3382b85a..ce84e10cced4372615f948c50ac812474d6dfc72 100644 (file)
@@ -3974,6 +3974,7 @@ inline const FiniteElement<DoFHandlerType::dimension,
                            DoFHandlerType::space_dimension> &
 DoFCellAccessor<DoFHandlerType, level_dof_access>::get_fe() const
 {
+  Assert(this->dof_handler != nullptr, typename BaseClass::ExcInvalidObject());
   Assert(
     (dynamic_cast<const dealii::DoFHandler<DoFHandlerType::dimension,
                                            DoFHandlerType::space_dimension> *>(
@@ -3982,7 +3983,6 @@ DoFCellAccessor<DoFHandlerType, level_dof_access>::get_fe() const
     ExcMessage("In hp::DoFHandler objects, finite elements are only associated "
                "with active cells. Consequently, you can not ask for the "
                "active finite element on cells with children."));
-  Assert(this->dof_handler != nullptr, typename BaseClass::ExcInvalidObject());
 
   return this->dof_handler->get_fe(active_fe_index());
 }
@@ -4048,6 +4048,26 @@ DoFCellAccessor<DoFHandlerType, level_dof_access>::set_active_fe_index(
 
 
 
+template <typename DoFHandlerType, bool level_dof_access>
+inline const FiniteElement<DoFHandlerType::dimension,
+                           DoFHandlerType::space_dimension> &
+DoFCellAccessor<DoFHandlerType, level_dof_access>::get_future_fe() const
+{
+  Assert(this->dof_handler != nullptr, typename BaseClass::ExcInvalidObject());
+  Assert(
+    (dynamic_cast<const dealii::DoFHandler<DoFHandlerType::dimension,
+                                           DoFHandlerType::space_dimension> *>(
+       this->dof_handler) != nullptr) ||
+      (this->has_children() == false),
+    ExcMessage("In hp::DoFHandler objects, finite elements are only associated "
+               "with active cells. Consequently, you can not ask for the "
+               "future finite element on cells with children."));
+
+  return this->dof_handler->get_fe(future_fe_index());
+}
+
+
+
 template <typename DoFHandlerType, bool level_dof_access>
 inline unsigned int
 DoFCellAccessor<DoFHandlerType, level_dof_access>::future_fe_index() const
index 440853672560a063d0b072f6f2d38b43d73361e1..6e4ba260841467400be01d45d20a2124ccc9b2ce 100644 (file)
@@ -52,20 +52,15 @@ test()
   auto cell = dh.begin_active();
   cell->set_future_fe_index(1);
 
-  // try to set future index to an invalid one
-  try
-    {
-      (++cell)->set_future_fe_index(2);
-    }
-  catch (const ExcIndexRange &)
-    {
-      deallog << "Set to 2 failed" << std::endl;
-    }
-
   // verify flags
   for (const auto &cell : dh.active_cell_iterators())
-    deallog << "cell:" << cell->id().to_string()
-            << ", future_fe:" << cell->future_fe_index() << std::endl;
+    {
+      deallog << "cell:" << cell->id().to_string()
+              << ", future_fe:" << cell->future_fe_index() << std::endl;
+      Assert(&(dh.get_fe(cell->future_fe_index())) == &(cell->get_future_fe()),
+             ExcMessage(
+               "DoFCellAccessor::get_future_fe() returns the wrong object."));
+    }
 
   // clear all flags and check if all were cleared
   for (const auto &cell : dh.active_cell_iterators())
index d5f4992a090b09b281b96579fa205c24ed17c1ec..a77d9096ba1f09f87d3b311ab4a98940b0918fb3 100644 (file)
@@ -1,12 +1,12 @@
 
 DEAL:1D::cell:0_1:0, future_fe:1
-DEAL:1D::cell:0_1:1, future_fe:2
+DEAL:1D::cell:0_1:1, future_fe:0
 DEAL:2D::cell:0_1:0, future_fe:1
-DEAL:2D::cell:0_1:1, future_fe:2
+DEAL:2D::cell:0_1:1, future_fe:0
 DEAL:2D::cell:0_1:2, future_fe:0
 DEAL:2D::cell:0_1:3, future_fe:0
 DEAL:3D::cell:0_1:0, future_fe:1
-DEAL:3D::cell:0_1:1, future_fe:2
+DEAL:3D::cell:0_1:1, future_fe:0
 DEAL:3D::cell:0_1:2, future_fe:0
 DEAL:3D::cell:0_1:3, future_fe:0
 DEAL:3D::cell:0_1:4, future_fe:0

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.