From 80b24437feadd1d737b5efff67327508ff222c81 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 7 Apr 2023 13:39:29 -0600 Subject: [PATCH] Return objects by value, rather than via a reference. We now have move operators that apply to return objects, along with mandatory return value optimization. There is no readon not to use this. This patch applies this to some internal functions. I will write a separate patch to make this the case for the public interfaces that call these functions. --- source/dofs/dof_tools.cc | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 6a676b6bb4..93470a2bff 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -2143,13 +2143,14 @@ namespace DoFTools namespace { template - void + std::map> map_dofs_to_support_points( - const hp::MappingCollection & mapping, - const DoFHandler & dof_handler, - std::map> &support_points, - const ComponentMask & in_mask) + const hp::MappingCollection &mapping, + const DoFHandler & dof_handler, + const ComponentMask & in_mask) { + std::map> support_points; + const hp::FECollection &fe_collection = dof_handler.get_fe_collection(); hp::QCollection q_coll_dummy; @@ -2208,23 +2209,24 @@ namespace DoFTools support_points[local_dof_indices[i]] = points[i]; } } + + return support_points; } template - void - map_dofs_to_support_points( + std::vector> + map_dofs_to_support_points_vector( const hp::MappingCollection &mapping, const DoFHandler & dof_handler, - std::vector> & support_points, const ComponentMask & mask) { + std::vector> support_points(dof_handler.n_dofs()); + // get the data in the form of the map as above - std::map> x_support_points; - map_dofs_to_support_points(mapping, - dof_handler, - x_support_points, - mask); + const std::map> + x_support_points = + map_dofs_to_support_points(mapping, dof_handler, mask); // now convert from the map to the linear vector. make sure every // entry really appeared in the map @@ -2233,12 +2235,15 @@ namespace DoFTools Assert(x_support_points.find(i) != x_support_points.end(), ExcInternalError()); - support_points[i] = x_support_points[i]; + support_points[i] = x_support_points.find(i)->second; } + + return support_points; } } // namespace } // namespace internal + template void map_dofs_to_support_points(const Mapping & mapping, @@ -2258,10 +2263,10 @@ namespace DoFTools // gets a MappingCollection const hp::MappingCollection mapping_collection(mapping); - internal::map_dofs_to_support_points(mapping_collection, - dof_handler, - support_points, - mask); + support_points = + internal::map_dofs_to_support_points_vector(mapping_collection, + dof_handler, + mask); } @@ -2283,10 +2288,8 @@ namespace DoFTools // Let the internal function do all the work, just make sure that it // gets a MappingCollection - internal::map_dofs_to_support_points(mapping, - dof_handler, - support_points, - mask); + support_points = + internal::map_dofs_to_support_points_vector(mapping, dof_handler, mask); } @@ -2304,10 +2307,9 @@ namespace DoFTools // gets a MappingCollection const hp::MappingCollection mapping_collection(mapping); - internal::map_dofs_to_support_points(mapping_collection, - dof_handler, - support_points, - mask); + support_points = internal::map_dofs_to_support_points(mapping_collection, + dof_handler, + mask); } @@ -2323,10 +2325,8 @@ namespace DoFTools // Let the internal function do all the work, just make sure that it // gets a MappingCollection - internal::map_dofs_to_support_points(mapping, - dof_handler, - support_points, - mask); + support_points = + internal::map_dofs_to_support_points(mapping, dof_handler, mask); } template -- 2.39.5