]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Store the hp::FECollection object for a DoFHandler
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 20 Aug 2017 22:54:49 +0000 (00:54 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 20 Aug 2017 22:54:49 +0000 (00:54 +0200)
include/deal.II/dofs/dof_handler.h
source/dofs/dof_handler.cc

index 7fa090decb38ea4271fc3321a600c006d707f676..c3b2e206cea2247a55cf4c26d55d19257e1c42c1 100644 (file)
@@ -848,7 +848,7 @@ public:
     * FiniteElement, only this one object is returned wrapped in a
     * hp::FECollection.
     */
-  hp::FECollection<dim,spacedim> get_fe_collection () const;
+  const hp::FECollection<dim,spacedim> &get_fe_collection () const;
 
   /**
    * Return a constant reference to the triangulation underlying this object.
@@ -953,6 +953,12 @@ private:
   SmartPointer<const FiniteElement<dim,spacedim>,DoFHandler<dim,spacedim> >
   selected_fe;
 
+  /**
+   * Store a pointer to a hp::FECollection object containing the (one)
+   * FiniteElement this object is initialized with.
+   */
+  std::unique_ptr<const hp::FECollection<dim,spacedim> > fe_collection;
+
   /**
    * An object that describes how degrees of freedom should be distributed and
    * renumbered.
@@ -1258,12 +1264,12 @@ DoFHandler<dim,spacedim>::get_finite_element
 
 template <int dim, int spacedim>
 inline
-hp::FECollection<dim,spacedim>
+const hp::FECollection<dim,spacedim> &
 DoFHandler<dim,spacedim>::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<dim,spacedim>(*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;
 }
 
 
index 9a655fb48bfdf531577624f46935aef23646444d..8210a0db24b43b0e65e4caf4eb9a065f9743c3cb 100644 (file)
@@ -27,6 +27,7 @@
 #include <deal.II/fe/fe.h>
 #include <deal.II/distributed/shared_tria.h>
 #include <deal.II/distributed/tria.h>
+#include <deal.II/base/std_cxx14/memory.h>
 
 #include <set>
 #include <algorithm>
@@ -653,6 +654,7 @@ DoFHandler<dim,spacedim>::DoFHandler (const Triangulation<dim,spacedim> &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 <int dim, int spacedim>
 DoFHandler<dim,spacedim>::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<dim,spacedim>::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 <int dim, int spacedim>
 void DoFHandler<dim,spacedim>::distribute_dofs (const FiniteElement<dim,spacedim> &ff)
 {
   selected_fe = &ff;
+  fe_collection = std_cxx14::make_unique<hp::FECollection<dim, spacedim>>(ff);
 
   // delete all levels and set them
   // up newly. note that we still
@@ -1087,6 +1092,7 @@ void DoFHandler<dim,spacedim>::clear ()
 {
   // release lock to old fe
   selected_fe = nullptr;
+  fe_collection.release();
 
   // release memory
   clear_space ();

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.