From: Daniel Arndt Date: Sun, 20 Aug 2017 22:54:49 +0000 (+0200) Subject: Store the hp::FECollection object for a DoFHandler X-Git-Tag: v9.0.0-rc1~1189^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cea85ac23e49f9bdb50fe9e68d52a1fc0219dcfc;p=dealii.git Store the hp::FECollection object for a DoFHandler --- 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 ();