From: Daniel Arndt Date: Sat, 10 Feb 2018 14:46:59 +0000 (+0100) Subject: Use make_unique/shared in dofs X-Git-Tag: v9.0.0-rc1~425^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d6ce702064df959e2bc66d54876d92350eed1a;p=dealii.git Use make_unique/shared in dofs --- diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 502af9ab8f..a519a22583 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -319,7 +319,7 @@ namespace internal numbers::invalid_dof_index); } - dof_handler.faces.reset (new internal::DoFHandler::DoFFaces<2>); + dof_handler.faces = std_cxx14::make_unique> (); // avoid access to n_raw_lines when there are no cells if (dof_handler.tria->n_cells() > 0) { @@ -354,7 +354,7 @@ namespace internal dof_handler.get_fe().dofs_per_cell, numbers::invalid_dof_index); } - dof_handler.faces.reset (new internal::DoFHandler::DoFFaces<3>); + dof_handler.faces = std_cxx14::make_unique> (); // avoid access to n_raw_lines when there are no cells if (dof_handler.tria->n_cells() > 0) @@ -439,11 +439,11 @@ namespace internal for (unsigned int i = 0; i < n_levels; ++i) { - dof_handler.mg_levels.emplace_back (new internal::DoFHandler::DoFLevel<2>); + dof_handler.mg_levels.emplace_back (std_cxx14::make_unique> ()); dof_handler.mg_levels.back ()->dof_object.dofs = std::vector (tria.n_raw_quads (i) * fe.dofs_per_quad, numbers::invalid_dof_index); } - dof_handler.mg_faces.reset (new internal::DoFHandler::DoFFaces<2>); + dof_handler.mg_faces = std_cxx14::make_unique> (); dof_handler.mg_faces->lines.dofs = std::vector (tria.n_raw_lines () * fe.dofs_per_line, numbers::invalid_dof_index); const unsigned int &n_vertices = tria.n_vertices (); @@ -498,11 +498,11 @@ namespace internal for (unsigned int i = 0; i < n_levels; ++i) { - dof_handler.mg_levels.emplace_back (new internal::DoFHandler::DoFLevel<3>); + dof_handler.mg_levels.emplace_back (std_cxx14::make_unique> ()); dof_handler.mg_levels.back ()->dof_object.dofs = std::vector (tria.n_raw_hexs (i) * fe.dofs_per_hex, numbers::invalid_dof_index); } - dof_handler.mg_faces.reset (new internal::DoFHandler::DoFFaces<3>); + dof_handler.mg_faces = std_cxx14::make_unique> (); dof_handler.mg_faces->lines.dofs = std::vector (tria.n_raw_lines () * fe.dofs_per_line, numbers::invalid_dof_index); dof_handler.mg_faces->quads.dofs = std::vector (tria.n_raw_quads () * fe.dofs_per_quad, numbers::invalid_dof_index); @@ -661,13 +661,13 @@ DoFHandler::DoFHandler (const Triangulation &tria) if (dynamic_cast*> (&tria) != nullptr) - policy.reset (new internal::DoFHandler::Policy::ParallelShared >(*this)); + policy = std_cxx14::make_unique >> (*this); else if (dynamic_cast*> (&tria) == nullptr) - policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); + policy = std_cxx14::make_unique >> (*this); else - policy.reset (new internal::DoFHandler::Policy::ParallelDistributed >(*this)); + policy = std_cxx14::make_unique >> (*this); } @@ -707,11 +707,11 @@ initialize(const Triangulation &t, // decide whether we need a sequential or a parallel distributed policy if (dynamic_cast*> (&t) != nullptr) - policy.reset (new internal::DoFHandler::Policy::ParallelShared >(*this)); + policy = std_cxx14::make_unique >> (*this); else if (dynamic_cast*> (&t) != nullptr) - policy.reset (new internal::DoFHandler::Policy::ParallelDistributed >(*this)); + policy = std_cxx14::make_unique >> (*this); else - policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); + policy = std_cxx14::make_unique >> (*this); distribute_dofs(fe); } @@ -1308,7 +1308,7 @@ void DoFHandler::MGVertexDoFs::init (const unsigned int cl, const unsigned int n_levels = finest_level - coarsest_level + 1; const unsigned int n_indices = n_levels * dofs_per_vertex; - indices.reset (new types::global_dof_index[n_indices]); + indices = std_cxx14::make_unique (n_indices); std::fill (indices.get(), indices.get()+n_indices, numbers::invalid_dof_index); } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 35132174b8..8b20aa899b 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -40,6 +40,7 @@ #include #endif +#include #include #include #include @@ -160,7 +161,7 @@ namespace internal void ensure_existence_of_dof_identities (const FiniteElement &fe1, const FiniteElement &fe2, - std::shared_ptr &identities) + std::unique_ptr &identities) { // see if we need to fill this entry, or whether it already // exists @@ -170,25 +171,22 @@ namespace internal { case 0: { - identities = - std::shared_ptr - (new DoFIdentities(fe1.hp_vertex_dof_identities(fe2))); + identities = std_cxx14::make_unique + (fe1.hp_vertex_dof_identities(fe2)); break; } case 1: { - identities = - std::shared_ptr - (new DoFIdentities(fe1.hp_line_dof_identities(fe2))); + identities = std_cxx14::make_unique + (fe1.hp_line_dof_identities(fe2)); break; } case 2: { - identities = - std::shared_ptr - (new DoFIdentities(fe1.hp_quad_dof_identities(fe2))); + identities = std_cxx14::make_unique + (fe1.hp_quad_dof_identities(fe2)); break; } @@ -606,7 +604,7 @@ namespace internal // it is not clear whether this is actually necessary for // vertices at all, I can't think of a finite element that // would make that necessary... - dealii::Table<2,std::shared_ptr > + dealii::Table<2,std::unique_ptr > vertex_dof_identities (dof_handler.get_fe_collection().size(), dof_handler.get_fe_collection().size()); @@ -773,7 +771,7 @@ namespace internal // is to first treat all pairs of finite elements that have *identical* dofs, // and then only deal with those that are not identical of which we can // handle at most 2 - dealii::Table<2,std::shared_ptr > + dealii::Table<2,std::unique_ptr > line_dof_identities (dof_handler.finite_elements->size(), dof_handler.finite_elements->size()); @@ -1005,7 +1003,7 @@ namespace internal // trouble. note that this only happens for lines in 3d and // higher, and for quads only in 4d and higher, so this // isn't a particularly frequent case - dealii::Table<2,std::shared_ptr > + dealii::Table<2,std::unique_ptr > quad_dof_identities (dof_handler.finite_elements->size(), dof_handler.finite_elements->size());