*/
DoFHandler (const Triangulation<dim,spacedim> &tria);
+ /**
+ * Copy constructor. DoFHandler objects are large and expensive.
+ * They should not be copied, in particular not by accident, but
+ * rather deliberately constructed. As a consequence, this constructor
+ * is explicitly removed from the interface of this class.
+ */
+ DoFHandler (const DoFHandler &) = delete;
+
/**
* Destructor.
*/
virtual ~DoFHandler ();
+ /**
+ * Copy operator. DoFHandler objects are large and expensive.
+ * They should not be copied, in particular not by accident, but
+ * rather deliberately constructed. As a consequence, this operator
+ * is explicitly removed from the interface of this class.
+ */
+ DoFHandler &operator = (const DoFHandler &) = delete;
+
/**
* Go through the triangulation and "distribute" the degrees of freedoms
* needed for the given finite element. "Distributing" degrees of freedom
private:
- /**
- * Copy constructor. I can see no reason why someone might want to use it,
- * so I don't provide it. Since this class has pointer members, making it
- * private prevents the compiler to provide it's own, incorrect one if
- * anyone chose to copy such an object.
- */
- DoFHandler (const DoFHandler &);
-
- /**
- * Copy operator. I can see no reason why someone might want to use it, so
- * I don't provide it. Since this class has pointer members, making it
- * private prevents the compiler to provide it's own, incorrect one if
- * anyone chose to copy such an object.
- */
- DoFHandler &operator = (const DoFHandler &);
-
/**
* Free all used memory.
*/
void clear_space ();
- template<int structdim>
- types::global_dof_index get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const;
+ template <int structdim>
+ types::global_dof_index get_dof_index (const unsigned int obj_level,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index) const;
- template<int structdim>
- void set_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index) const;
+ template <int structdim>
+ void set_dof_index (const unsigned int obj_level,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const types::global_dof_index global_index) const;
/**
* Create default tables for the active_fe_indices in the
* Space to store the DoF numbers for the different levels. Analogous to
* the <tt>levels[]</tt> tree of the Triangulation objects.
*/
- std::vector<dealii::internal::hp::DoFLevel *> levels;
+ std::vector<std::unique_ptr<dealii::internal::hp::DoFLevel> > levels;
/**
* Space to store the DoF numbers for the faces. Analogous to the
* <tt>faces</tt> pointer of the Triangulation objects.
*/
- dealii::internal::hp::DoFIndicesOnFaces<dim> *faces;
+ std::unique_ptr<dealii::internal::hp::DoFIndicesOnFaces<dim> > faces;
/**
* A structure that contains all sorts of numbers that characterize the
* refinement, i.e. from between when pre_refinement_action is called and
* when post_refinement_action runs.
*/
- std::vector<std::vector<bool> *> has_children;
+ std::vector<std::unique_ptr<std::vector<bool> > > has_children;
/**
* A list of connections with which this object connects to the
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel);
+ dof_handler.levels.emplace_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel);
+ dof_handler.levels.emplace_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
- dof_handler.faces = new internal::hp::DoFIndicesOnFaces<2>;
+ dof_handler.faces.reset (new internal::hp::DoFIndicesOnFaces<2>);
}
// QUAD (CELL) DOFs
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel);
+ dof_handler.levels.emplace_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
- dof_handler.faces = new internal::hp::DoFIndicesOnFaces<3>;
+ dof_handler.faces.reset (new internal::hp::DoFIndicesOnFaces<3>);
}
// HEX (CELL) DOFs
// Create sufficiently many
// hp::DoFLevels.
while (levels.size () < tria->n_levels ())
- levels.push_back (new dealii::internal::hp::DoFLevel);
+ levels.emplace_back (new dealii::internal::hp::DoFLevel);
// then make sure that on each
// level we have the appropriate
for (unsigned int i=0; i<levels.size(); ++i)
{
const unsigned int cells_on_level = tria->n_raw_cells(i);
- std::vector<bool> *has_children_level =
- new std::vector<bool> (cells_on_level);
+ std::unique_ptr<std::vector<bool> > has_children_level(new std::vector<bool> (cells_on_level));
// Check for each cell, if it has children. in 1d,
// we don't store refinement cases, so use the 'children'
std::placeholders::_1,
static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
- has_children.push_back (has_children_level);
+ has_children.emplace_back (std::move(has_children_level));
}
}
// Normally only one level is added, but if this Triangulation
// is created by copy_triangulation, it can be more than one level.
while (levels.size () < tria->n_levels ())
- levels.push_back (new dealii::internal::hp::DoFLevel);
+ levels.emplace_back (new dealii::internal::hp::DoFLevel);
// Coarsening can lead to the loss
// of levels. Hence remove them.
while (levels.size () > tria->n_levels ())
{
- delete levels[levels.size ()-1];
+ // drop the last element. that also releases the memory pointed to
levels.pop_back ();
}
}
// Free buffer objects
- std::vector<std::vector<bool> *>::iterator children_level;
- for (children_level = has_children.begin ();
- children_level != has_children.end ();
- ++children_level)
- delete (*children_level);
has_children.clear ();
}
template<int dim, int spacedim>
void DoFHandler<dim,spacedim>::clear_space ()
{
- for (unsigned int i=0; i<levels.size(); ++i)
- delete levels[i];
- levels.resize (0);
- delete faces;
- faces = nullptr;
+ levels.clear ();
+ faces.reset ();
{
std::vector<types::global_dof_index> tmp;