From cea85ac23e49f9bdb50fe9e68d52a1fc0219dcfc Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 21 Aug 2017 00:54:49 +0200 Subject: [PATCH] Store the hp::FECollection object for a DoFHandler --- include/deal.II/dofs/dof_handler.h | 16 +++++++++++----- source/dofs/dof_handler.cc | 8 +++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 7fa090decb..c3b2e206ce 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -848,7 +848,7 @@ public: * FiniteElement, only this one object is returned wrapped in a * hp::FECollection. */ - hp::FECollection get_fe_collection () const; + const hp::FECollection &get_fe_collection () const; /** * Return a constant reference to the triangulation underlying this object. @@ -953,6 +953,12 @@ private: SmartPointer,DoFHandler > selected_fe; + /** + * Store a pointer to a hp::FECollection object containing the (one) + * FiniteElement this object is initialized with. + */ + std::unique_ptr > fe_collection; + /** * An object that describes how degrees of freedom should be distributed and * renumbered. @@ -1258,12 +1264,12 @@ DoFHandler::get_finite_element template inline -hp::FECollection +const hp::FECollection & DoFHandler::get_fe_collection () const { - Assert(selected_fe!=nullptr, - ExcMessage("You are trying to access the DoFHandler's FiniteElement object before it has been initialized.")); - return hp::FECollection(*selected_fe); + Assert(fe_collection != nullptr, + ExcMessage("You are trying to access the DoFHandler's FECollection object before it has been initialized.")); + return *fe_collection; } diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 9a655fb48b..8210a0db24 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -653,6 +654,7 @@ DoFHandler::DoFHandler (const Triangulation &tria) : tria(&tria, typeid(*this).name()), selected_fe(nullptr, typeid(*this).name()), + fe_collection(nullptr), faces(nullptr), mg_faces (nullptr) { @@ -674,7 +676,8 @@ template DoFHandler::DoFHandler () : tria(nullptr, typeid(*this).name()), - selected_fe(nullptr, typeid(*this).name()) + selected_fe(nullptr, typeid(*this).name()), + fe_collection(nullptr) {} @@ -963,6 +966,7 @@ DoFHandler::memory_consumption () const { std::size_t mem = (MemoryConsumption::memory_consumption (tria) + MemoryConsumption::memory_consumption (selected_fe) + + MemoryConsumption::memory_consumption (fe_collection) + MemoryConsumption::memory_consumption (block_info_object) + MemoryConsumption::memory_consumption (levels) + MemoryConsumption::memory_consumption (*faces) + @@ -991,6 +995,7 @@ template void DoFHandler::distribute_dofs (const FiniteElement &ff) { selected_fe = &ff; + fe_collection = std_cxx14::make_unique>(ff); // delete all levels and set them // up newly. note that we still @@ -1087,6 +1092,7 @@ void DoFHandler::clear () { // release lock to old fe selected_fe = nullptr; + fe_collection.release(); // release memory clear_space (); -- 2.39.5