From c24756d1c4343fef0a2dab59863c1c73b6a2fbb6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 27 Jun 2017 08:23:05 -0600 Subject: [PATCH] Provide the hp::DoFHandler class with a policy object. --- include/deal.II/dofs/dof_handler.h | 2 +- include/deal.II/hp/dof_handler.h | 62 +++++++++++++++++++++++++----- source/hp/dof_handler.cc | 1 + 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index b3862ebe3d..ae3fe3df73 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -1272,7 +1272,7 @@ DoFHandler::n_boundary_dofs (const std::map class Triangulation; namespace internal { + namespace DoFHandler + { + struct Implementation; + + namespace Policy + { + template class PolicyBase; + struct Implementation; + } + } + namespace hp { class DoFLevel; @@ -734,7 +745,12 @@ namespace hp */ SmartPointer,hp::DoFHandler > finite_elements; - private: + /** + * An object that describes how degrees of freedom should be distributed and + * renumbered. + */ + std::unique_ptr > policy; + /** * Free all used memory. @@ -919,9 +935,25 @@ namespace hp // then just hand everything over to the other function that does the work return n_boundary_dofs(boundary_ids_only); } +} +namespace internal +{ + /** + * Return a string representing the dynamic type of the given argument. + * This is basically the same what typeid(...).name() does, but it turns out + * this is broken on Intel 13+. + * + * Defined in source/dofs/dof_handler.cc. + */ + template + std::string policy_to_string(const dealii::internal::DoFHandler::Policy::PolicyBase &policy); +} + +namespace hp +{ template template void DoFHandler::save(Archive &ar, unsigned int) const @@ -934,12 +966,16 @@ namespace hp ar &has_children; // write out the number of triangulation cells and later check during - // loading that this number is indeed correct; + // loading that this number is indeed correct; same with something that + // identifies the policy unsigned int n_cells = tria->n_cells(); + std::string policy_name = dealii::internal::policy_to_string(*policy); - ar &n_cells; + ar &n_cells &policy_name; } + + template template void DoFHandler::load(Archive &ar, unsigned int) @@ -968,12 +1004,20 @@ namespace hp // these are the checks that correspond to the last block in the save() // function unsigned int n_cells; - - ar &n_cells; - - AssertThrow(n_cells == tria->n_cells(), - ExcMessage("The object being loaded into does not match the triangulation " - "that has been stored previously.")); + std::string policy_name; + + ar &n_cells &policy_name; + + AssertThrow (n_cells == tria->n_cells(), + ExcMessage ("The object being loaded into does not match the triangulation " + "that has been stored previously.")); + AssertThrow (policy_name == dealii::internal::policy_to_string(*policy), + ExcMessage (std::string ("The policy currently associated with this DoFHandler (") + + dealii::internal::policy_to_string(*policy) + +std::string(") does not match the one that was associated with the " + "DoFHandler previously stored (") + + policy_name + + ").")); } template diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 34a11d2df9..55b874de1e 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include -- 2.39.5