From: Daniel Arndt Date: Sat, 10 Feb 2018 14:22:44 +0000 (+0100) Subject: Use make_unique/shared in fe X-Git-Tag: v9.0.0-rc1~425^2~10 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b15febd0c263da5fdf2a12913652c220e9ab8416;p=dealii.git Use make_unique/shared in fe --- diff --git a/include/deal.II/fe/fe_tools_interpolate.templates.h b/include/deal.II/fe/fe_tools_interpolate.templates.h index 744b39d12b..afd472b2e7 100644 --- a/include/deal.II/fe/fe_tools_interpolate.templates.h +++ b/include/deal.II/fe/fe_tools_interpolate.templates.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -110,12 +111,12 @@ namespace FETools Vector u1_local(DoFTools::max_dofs_per_cell(dof1)); Vector u2_local(DoFTools::max_dofs_per_cell(dof2)); - // have a map for interpolation - // matrices. shared_ptr make sure - // that memory is released again + // have a map for interpolation matrices. + // Using a unique_ptr makes sure that the + // memory is released again automatically. std::map *, std::map *, - std::shared_ptr > > > + std::unique_ptr > > > interpolation_matrices; typename DoFHandlerType1::active_cell_iterator cell1 = dof1.begin_active(), @@ -176,15 +177,15 @@ namespace FETools // there if (interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()].get() == nullptr) { - std::shared_ptr > - interpolation_matrix (new FullMatrix (dofs_per_cell2, - dofs_per_cell1)); - interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()] - = interpolation_matrix; + auto interpolation_matrix = std_cxx14::make_unique > + (dofs_per_cell2, dofs_per_cell1); get_interpolation_matrix(cell1->get_fe(), cell2->get_fe(), *interpolation_matrix); + + interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()] + = std::move(interpolation_matrix); } cell1->get_dof_values(u1, u1_local); @@ -291,7 +292,7 @@ namespace FETools // dof1 to the back_interpolation // matrices std::map *, - std::shared_ptr > > interpolation_matrices; + std::unique_ptr > > interpolation_matrices; for (; cell!=endc; ++cell) if ((cell->subdomain_id() == subdomain_id) @@ -320,9 +321,8 @@ namespace FETools // matrix is available if (interpolation_matrices[&cell->get_fe()] == nullptr) { - interpolation_matrices[&cell->get_fe()] = - std::shared_ptr > - (new FullMatrix(dofs_per_cell1, dofs_per_cell1)); + interpolation_matrices[&cell->get_fe()] = std_cxx14::make_unique > + (dofs_per_cell1, dofs_per_cell1); get_back_interpolation_matrix(cell->get_fe(), fe2, *interpolation_matrices[&cell->get_fe()]); } diff --git a/source/fe/fe_q_bubbles.cc b/source/fe/fe_q_bubbles.cc index e57b3731a5..e070b7cbec 100644 --- a/source/fe/fe_q_bubbles.cc +++ b/source/fe/fe_q_bubbles.cc @@ -61,20 +61,20 @@ namespace internal { case 1: if (spacedim==1) - q_fine.reset(new QGauss (degree+1)); + q_fine = std_cxx14::make_unique>(degree+1); else if (spacedim==2) - q_fine.reset(new QAnisotropic(QGauss<1>(degree+1), q_dummy)); + q_fine = std_cxx14::make_unique>(QGauss<1>(degree+1), q_dummy); else - q_fine.reset(new QAnisotropic(QGauss<1>(degree+1), q_dummy, q_dummy)); + q_fine = std_cxx14::make_unique>(QGauss<1>(degree+1), q_dummy, q_dummy); break; case 2: if (spacedim==2) - q_fine.reset(new QGauss (degree+1)); + q_fine = std_cxx14::make_unique>(degree+1); else - q_fine.reset(new QAnisotropic(QGauss<1>(degree+1), QGauss<1>(degree+1), q_dummy)); + q_fine = std_cxx14::make_unique>(QGauss<1>(degree+1), QGauss<1>(degree+1), q_dummy); break; case 3: - q_fine.reset(new QGauss (degree+1)); + q_fine = std_cxx14::make_unique>(degree+1); break; default: Assert(false, ExcInternalError()); diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index 130916c333..0810a05d1c 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,6 @@ #include #include -#include #include @@ -3979,7 +3979,7 @@ FEValues::initialize (const UpdateFlags update_flags) if (flags & update_mapping) this->mapping_data.reset (mapping_get_data.return_value()); else - this->mapping_data.reset (new typename Mapping::InternalDataBase()); + this->mapping_data = std_cxx14::make_unique::InternalDataBase> (); } @@ -4010,7 +4010,7 @@ namespace } else // if the types don't match, there is nothing we can do here - present_cell.reset (new Type(new_cell)); + present_cell = std_cxx14::make_unique (new_cell); } } @@ -4229,7 +4229,7 @@ FEFaceValues::initialize (const UpdateFlags update_flags) if (flags & update_mapping) this->mapping_data.reset (mapping_get_data.return_value()); else - this->mapping_data.reset (new typename Mapping::InternalDataBase()); + this->mapping_data = std_cxx14::make_unique::InternalDataBase> (); } @@ -4397,7 +4397,7 @@ FESubfaceValues::initialize (const UpdateFlags update_flags) if (flags & update_mapping) this->mapping_data.reset (mapping_get_data.return_value()); else - this->mapping_data.reset (new typename Mapping::InternalDataBase()); + this->mapping_data = std_cxx14::make_unique::InternalDataBase> (); } diff --git a/source/fe/mapping_c1.cc b/source/fe/mapping_c1.cc index 0532e863af..a2a6266328 100644 --- a/source/fe/mapping_c1.cc +++ b/source/fe/mapping_c1.cc @@ -47,7 +47,7 @@ MappingC1::MappingC1 () // // we only need to replace the Qp mapping because that's the one that's // used on boundary cells where it matters - this->qp_mapping.reset (new MappingC1::MappingC1Generic()); + this->qp_mapping = std::make_shared::MappingC1Generic>(); } diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index 25f641e662..122916c5d2 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -72,13 +72,13 @@ MappingQ::MappingQ (const unsigned int degree, (dim != spacedim)), // create a Q1 mapping for use on interior cells (if necessary) // or to create a good initial guess in transform_real_to_unit_cell() - q1_mapping (new MappingQGeneric(1)), + q1_mapping (std::make_shared >(1)), // create a Q_p mapping; if p=1, simply share the Q_1 mapping already // created via the shared_ptr objects qp_mapping (this->polynomial_degree>1 ? - std::make_shared>(degree) + std::make_shared >(degree) : q1_mapping) {} diff --git a/source/fe/mapping_q_eulerian.cc b/source/fe/mapping_q_eulerian.cc index f7ccc78f4a..a1b315f17f 100644 --- a/source/fe/mapping_q_eulerian.cc +++ b/source/fe/mapping_q_eulerian.cc @@ -70,11 +70,11 @@ MappingQEulerian (const unsigned int degree, // reset the q1 mapping we use for interior cells (and previously // set by the MappingQ constructor) to a MappingQ1Eulerian with the // current vector - this->q1_mapping.reset (new MappingQ1Eulerian(euler_dof_handler, - euler_vector)); + this->q1_mapping = std::make_shared> + (euler_dof_handler, euler_vector); // also reset the qp mapping pointer with our own class - this->qp_mapping.reset (new MappingQEulerianGeneric(degree,*this)); + this->qp_mapping = std::make_shared(degree,*this); }