From 58aa255712ddbc114f2a881a9e02a258477c1788 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 18 Jul 2017 17:16:11 -0600 Subject: [PATCH] Let a function return its product, rather than use a reference argument. While there, also make the function 'const', which requires a bit of surgery in a variety of places where we did not accurately propagate constness. --- include/deal.II/distributed/p4est_wrappers.h | 6 +++--- include/deal.II/distributed/tria.h | 14 +++++--------- source/distributed/p4est_wrappers.cc | 12 ++++++------ source/distributed/tria.cc | 18 +++++++++--------- source/dofs/dof_handler_policy.cc | 14 ++++++-------- 5 files changed, 29 insertions(+), 35 deletions(-) diff --git a/include/deal.II/distributed/p4est_wrappers.h b/include/deal.II/distributed/p4est_wrappers.h index 01c8749a7d..42d9e0f27e 100644 --- a/include/deal.II/distributed/p4est_wrappers.h +++ b/include/deal.II/distributed/p4est_wrappers.h @@ -572,9 +572,9 @@ namespace internal template struct FindGhosts { - typename dealii::parallel::distributed::Triangulation *triangulation; - sc_array_t *subids; - std::map > *vertices_with_ghost_neighbors; + const typename dealii::parallel::distributed::Triangulation *triangulation; + sc_array_t *subids; + std::map > *vertices_with_ghost_neighbors; }; diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h index 3586348ae1..893c5747e1 100644 --- a/include/deal.II/distributed/tria.h +++ b/include/deal.II/distributed/tria.h @@ -858,14 +858,12 @@ namespace parallel get_cell_weights(); /** - * Fills a map that, for each vertex, lists all the processors whose + * Return a map that, for each vertex, lists all the processors whose * subdomains are adjacent to that vertex. Used by * DoFHandler::Policy::ParallelDistributed. */ - void - fill_vertices_with_ghost_neighbors - (std::map > - &vertices_with_ghost_neighbors); + std::map > + compute_vertices_with_ghost_neighbors () const; /** * Fills a map that, for each vertex, lists all the processors whose @@ -989,10 +987,8 @@ namespace parallel * Like above, this method, which is only implemented for dim = 2 or 3, * needs a stub because it is used in dof_handler_policy.cc */ - void - fill_vertices_with_ghost_neighbors - (std::map > - &vertices_with_ghost_neighbors); + std::map > + compute_vertices_with_ghost_neighbors () const; /** * Like above, this method, which is only implemented for dim = 2 or 3, diff --git a/source/distributed/p4est_wrappers.cc b/source/distributed/p4est_wrappers.cc index a0cef5fe5d..41cb8266aa 100644 --- a/source/distributed/p4est_wrappers.cc +++ b/source/distributed/p4est_wrappers.cc @@ -14,9 +14,9 @@ namespace internal template typename dealii::Triangulation::cell_iterator cell_from_quad - (typename dealii::parallel::distributed::Triangulation *triangulation, - typename dealii::internal::p4est::types::topidx treeidx, - typename dealii::internal::p4est::types::quadrant &quad) + (const dealii::parallel::distributed::Triangulation *triangulation, + const typename dealii::internal::p4est::types::topidx treeidx, + const typename dealii::internal::p4est::types::quadrant &quad) { int i, l = quad.level; dealii::types::global_dof_index dealii_index = @@ -54,7 +54,7 @@ namespace internal (info->sides.array); FindGhosts *fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; - typename dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; + const dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; int nsubs; dealii::types::subdomain_id *subdomain_ids; std::map > @@ -116,7 +116,7 @@ namespace internal (info->sides.array); FindGhosts *fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; - typename dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; + const dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; int nsubs; dealii::types::subdomain_id *subdomain_ids; std::map > @@ -187,7 +187,7 @@ namespace internal (info->sides.array); FindGhosts *fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; - typename dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; + const dealii::parallel::distributed::Triangulation *triangulation = fg->triangulation; int nsubs; dealii::types::subdomain_id *subdomain_ids; std::map > diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index f67891a4a0..a1488d4365 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -3382,14 +3382,13 @@ namespace parallel * This is achieved via the p4est_iterate/p8est_iterate tool */ template - void - Triangulation:: - fill_vertices_with_ghost_neighbors - (std::map > - &vertices_with_ghost_neighbors) + std::map > + Triangulation::compute_vertices_with_ghost_neighbors () const { Assert (dim>1, ExcNotImplemented()); + std::map > vertices_with_ghost_neighbors; + dealii::internal::p4est::FindGhosts fg; fg.subids = sc_array_new (sizeof (dealii::types::subdomain_id)); fg.triangulation = this; @@ -3400,6 +3399,8 @@ namespace parallel static_cast(&fg)); sc_array_destroy (fg.subids); + + return vertices_with_ghost_neighbors; } @@ -3900,13 +3901,12 @@ namespace parallel } template - void + std::map > Triangulation<1,spacedim>:: - fill_vertices_with_ghost_neighbors - (std::map > - &/*vertices_with_ghost_neighbors*/) + compute_vertices_with_ghost_neighbors () const { Assert (false, ExcNotImplemented()); + return std::map >(); } template diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 43fe9d76ac..057d4a883c 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -3637,10 +3637,9 @@ namespace internal // add each ghostcell's subdomain to the vertex and keep track // of interesting neighbors - std::map > - vertices_with_ghost_neighbors; - - triangulation->fill_vertices_with_ghost_neighbors (vertices_with_ghost_neighbors); + const std::map > + vertices_with_ghost_neighbors + = triangulation->compute_vertices_with_ghost_neighbors (); // Send and receive cells. After this, only the local cells @@ -4112,10 +4111,9 @@ namespace internal // add each ghostcells' subdomain to the vertex and keep track of // interesting neighbors - std::map > - vertices_with_ghost_neighbors; - - tr->fill_vertices_with_ghost_neighbors (vertices_with_ghost_neighbors); + const std::map > + vertices_with_ghost_neighbors + = tr->compute_vertices_with_ghost_neighbors (); // Send and receive cells. After this, only the local cells are // marked, that received new data. This has to be communicated in a -- 2.39.5