* 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::DoFHandler::DoFLevel<dim>*> levels;
+ std::vector<std::unique_ptr<dealii::internal::DoFHandler::DoFLevel<dim> > > levels;
- std::vector<dealii::internal::DoFHandler::DoFLevel<dim>*> mg_levels;
+ std::vector<std::unique_ptr<dealii::internal::DoFHandler::DoFLevel<dim> > > mg_levels;
/**
* Space to store DoF numbers of faces. They are not stored in
* <tt>levels</tt> since faces are not organized hierarchically, but in a
* flat array.
*/
- dealii::internal::DoFHandler::DoFFaces<dim> *faces;
+ std::unique_ptr<dealii::internal::DoFHandler::DoFFaces<dim> > faces;
- dealii::internal::DoFHandler::DoFFaces<dim> *mg_faces;
+ std::unique_ptr<dealii::internal::DoFHandler::DoFFaces<dim> > mg_faces;
/**
* Make accessor objects friends.
// pointer object still points to something useful, that object is not
// destroyed and we end up with a memory leak. consequently, first delete
// previous content before re-loading stuff
- for (unsigned int i=0; i<levels.size(); ++i)
- delete levels[i];
- levels.resize (0);
- delete faces;
- faces = nullptr;
+ levels.clear();
+ faces.reset();
ar &levels;
ar &faces;
DEAL_II_NAMESPACE_OPEN
-//TODO[WB]: do not use a plain pointer for DoFHandler::faces, but rather an
-//unique_ptr or some such thing. alternatively, why not use the DoFFaces object
-//right away?
-
template<int dim, int spacedim>
const unsigned int DoFHandler<dim,spacedim>::dimension;
for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
{
- dof_handler.levels
- .push_back (new internal::DoFHandler::DoFLevel<1>);
+ dof_handler.levels.emplace_back (new internal::DoFHandler::DoFLevel<1>);
dof_handler.levels.back()->dof_object.dofs
.resize (dof_handler.tria->n_raw_cells(i) *
for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
{
- dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>);
+ dof_handler.levels.emplace_back (new internal::DoFHandler::DoFLevel<2>);
dof_handler.levels.back()->dof_object.dofs
.resize (dof_handler.tria->n_raw_cells(i) *
DoFHandler<2,spacedim>::invalid_dof_index);
}
- dof_handler.faces = new internal::DoFHandler::DoFFaces<2>;
+ dof_handler.faces.reset (new internal::DoFHandler::DoFFaces<2>);
// avoid access to n_raw_lines when there are no cells
if (dof_handler.tria->n_cells() > 0)
{
for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
{
- dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>);
+ dof_handler.levels.emplace_back (new internal::DoFHandler::DoFLevel<3>);
dof_handler.levels.back()->dof_object.dofs
.resize (dof_handler.tria->n_raw_cells(i) *
dof_handler.selected_fe->dofs_per_cell,
DoFHandler<3,spacedim>::invalid_dof_index);
}
- dof_handler.faces = new internal::DoFHandler::DoFFaces<3>;
+ dof_handler.faces.reset (new internal::DoFHandler::DoFFaces<3>);
// avoid access to n_raw_lines when there are no cells
if (dof_handler.tria->n_cells() > 0)
for (unsigned int i = 0; i < n_levels; ++i)
{
- dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<1>);
+ dof_handler.mg_levels.emplace_back (new internal::DoFHandler::DoFLevel<1>);
dof_handler.mg_levels.back ()->dof_object.dofs = std::vector<types::global_dof_index> (tria.n_raw_lines (i) * dofs_per_line, DoFHandler<1>::invalid_dof_index);
}
for (unsigned int i = 0; i < n_levels; ++i)
{
- dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<2>);
+ dof_handler.mg_levels.emplace_back (new internal::DoFHandler::DoFLevel<2>);
dof_handler.mg_levels.back ()->dof_object.dofs = std::vector<types::global_dof_index> (tria.n_raw_quads (i) * fe.dofs_per_quad, DoFHandler<2>::invalid_dof_index);
}
- dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<2>;
+ dof_handler.mg_faces.reset (new internal::DoFHandler::DoFFaces<2>);
dof_handler.mg_faces->lines.dofs = std::vector<types::global_dof_index> (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<2>::invalid_dof_index);
const unsigned int &n_vertices = tria.n_vertices ();
for (unsigned int i = 0; i < n_levels; ++i)
{
- dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<3>);
+ dof_handler.mg_levels.emplace_back (new internal::DoFHandler::DoFLevel<3>);
dof_handler.mg_levels.back ()->dof_object.dofs = std::vector<types::global_dof_index> (tria.n_raw_hexs (i) * fe.dofs_per_hex, DoFHandler<3>::invalid_dof_index);
}
- dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<3>;
+ dof_handler.mg_faces.reset (new internal::DoFHandler::DoFFaces<3>);
dof_handler.mg_faces->lines.dofs = std::vector<types::global_dof_index> (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<3>::invalid_dof_index);
dof_handler.mg_faces->quads.dofs = std::vector<types::global_dof_index> (tria.n_raw_quads () * fe.dofs_per_quad, DoFHandler<3>::invalid_dof_index);
DoFHandler<dim,spacedim>::DoFHandler ()
:
tria(nullptr, typeid(*this).name()),
- selected_fe(nullptr, typeid(*this).name()),
- faces(nullptr),
- mg_faces (nullptr)
+ selected_fe(nullptr, typeid(*this).name())
{}
block_info_object.initialize (*this, true, false);
}
+
+
template<int dim, int spacedim>
void DoFHandler<dim, spacedim>::reserve_space ()
{
//TODO: move this to distribute_mg_dofs and remove function
}
+
+
template<int dim, int spacedim>
void DoFHandler<dim, spacedim>::clear_mg_space ()
{
- for (unsigned int i = 0; i < mg_levels.size (); ++i)
- delete mg_levels[i];
-
mg_levels.clear ();
- delete mg_faces;
- mg_faces = nullptr;
+ mg_faces.reset ();
std::vector<MGVertexDoFs> tmp;
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;
std::swap (vertex_dofs, tmp);