From 2032ce3abc141fd23cf6fc04ca9190f4f789f2d8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 27 Mar 2020 09:37:49 -0600 Subject: [PATCH] Use std::unique_ptr instead of std::shared_ptr. --- examples/step-67/step-67.cc | 41 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/examples/step-67/step-67.cc b/examples/step-67/step-67.cc index d2fb016927..70dfba1b5c 100644 --- a/examples/step-67/step-67.cc +++ b/examples/step-67/step-67.cc @@ -710,17 +710,16 @@ namespace Euler_DG void reinit(const Mapping & mapping, const DoFHandler &dof_handler); - void - set_inflow_boundary(const types::boundary_id boundary_id, - const std::shared_ptr> &inflow_function); + void set_inflow_boundary(const types::boundary_id boundary_id, + std::unique_ptr> inflow_function); void set_subsonic_outflow_boundary( - const types::boundary_id boundary_id, - const std::shared_ptr> &outflow_energy); + const types::boundary_id boundary_id, + std::unique_ptr> outflow_energy); void set_wall_boundary(const types::boundary_id boundary_id); - void set_body_force(const std::shared_ptr> &body_force); + void set_body_force(std::unique_ptr> body_force); void apply(const double current_time, const LinearAlgebra::distributed::Vector &src, @@ -753,12 +752,12 @@ namespace Euler_DG TimerOutput &timer; - std::map>> + std::map>> inflow_boundaries; - std::map>> + std::map>> subsonic_outflow_boundaries; std::set wall_boundaries; - std::shared_ptr> body_force; + std::unique_ptr> body_force; void local_apply_inverse_mass_matrix( const MatrixFree & data, @@ -873,8 +872,8 @@ namespace Euler_DG // boundary to both an inflow and say a subsonic outflow. template void EulerOperator::set_inflow_boundary( - const types::boundary_id boundary_id, - const std::shared_ptr> &inflow_function) + const types::boundary_id boundary_id, + std::unique_ptr> inflow_function) { AssertThrow(subsonic_outflow_boundaries.find(boundary_id) == subsonic_outflow_boundaries.end() && @@ -885,13 +884,13 @@ namespace Euler_DG "it as inflow")); AssertThrow(inflow_function->n_components == dim + 2, ExcMessage("Expected function with dim+2 components")); - inflow_boundaries[boundary_id] = inflow_function; + inflow_boundaries[boundary_id] = std::move(inflow_function); } template void EulerOperator::set_subsonic_outflow_boundary( - const types::boundary_id boundary_id, - const std::shared_ptr> &outflow_function) + const types::boundary_id boundary_id, + std::unique_ptr> outflow_function) { AssertThrow(inflow_boundaries.find(boundary_id) == inflow_boundaries.end() && @@ -902,7 +901,7 @@ namespace Euler_DG "it as subsonic outflow")); AssertThrow(outflow_function->n_components == dim + 2, ExcMessage("Expected function with dim+2 components")); - subsonic_outflow_boundaries[boundary_id] = outflow_function; + subsonic_outflow_boundaries[boundary_id] = std::move(outflow_function); } template @@ -922,10 +921,10 @@ namespace Euler_DG template void EulerOperator::set_body_force( - const std::shared_ptr> &body_force) + std::unique_ptr> body_force) { AssertDimension(body_force->n_components, dim); - this->body_force = body_force; + this->body_force = std::move(body_force); } @@ -1950,20 +1949,20 @@ namespace Euler_DG triangulation.refine_global(2); euler_operator.set_inflow_boundary( - 0, std::make_shared>(0)); + 0, std_cxx14::make_unique>(0)); } else if (testcase == 1) { GridGenerator::channel_with_cylinder(triangulation, 0.03, 1, 0, true); euler_operator.set_inflow_boundary( - 0, std::make_shared>(0)); + 0, std_cxx14::make_unique>(0)); euler_operator.set_subsonic_outflow_boundary( - 1, std::make_shared>(0)); + 1, std_cxx14::make_unique>(0)); euler_operator.set_wall_boundary(2); euler_operator.set_wall_boundary(3); if (dim == 3) euler_operator.set_body_force( - std::make_shared>( + std_cxx14::make_unique>( std::vector({0., 0., -0.2}))); } -- 2.39.5