+++ /dev/null
-New: Helper function DoFCellAccessor::dominated_future_fe_on_children()
-to clean up code for hp-coarsening.
-<br>
-(Marc Fehling, 2020/10/05)
#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
*/
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!");
-
/**
* @}
*/
-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
#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 ----------------------------------
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:
# 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;
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;
}
};
} // namespace DoFHandlerImplementation
+
+
namespace hp
{
namespace DoFHandlerImplementation
#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});
/*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
// ---------------------------------------------------------------------
//
-// 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.
//
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
}
#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});
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();
// Verify functionality of
-// DoFCellAccessor:dominated_future_fe_on_children()
+// internal::hp::DoFHandlerImplementation::dominated_future_fe_on_children()
#include <deal.II/base/logstream.h>
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;
}