From: Giovanni Alzetta Date: Mon, 16 Apr 2018 11:43:34 +0000 (+0200) Subject: Changed GridTools::distributed_compute_ptloc to use global description of the mesh... X-Git-Tag: v9.0.0-rc1~170^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41c689bd127157140922d46bc976db46e2ff389a;p=dealii.git Changed GridTools::distributed_compute_ptloc to use global description of the mesh instead of local one --- diff --git a/doc/news/changes/minor/20180416GiovanniAlzetta b/doc/news/changes/minor/20180416GiovanniAlzetta new file mode 100644 index 0000000000..bf2f8801bb --- /dev/null +++ b/doc/news/changes/minor/20180416GiovanniAlzetta @@ -0,0 +1,5 @@ +Changed: GridTools::distributed_compute_point_locations now takes as input the +global description of the manifold using bounding boxes. +
+(Giovanni Alzetta, 2018/04/16) + diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 3c9a3081ba..2ee6f31ed0 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -683,9 +683,14 @@ namespace GridTools * @param[in] local_points the array of points owned by the current process. Every * process can have a different array of points which can be empty and not * contained within the locally owned part of the triangulation - * @param[in] local_bbox the description of the locally owned part of the mesh made - * with bounding boxes. It can be obtained from - * GridTools::compute_mesh_predicate_bounding_box + * @param[in] global_bboxes a vector of vectors of bounding boxes; it describes + * the locally owned part of the mesh for each process. + * The bounding boxes describing which part of the mesh is locally owned by + * process with rank rk are contained in global_bboxes[rk]. + * The local description can be obtained from + * GridTools::compute_mesh_predicate_bounding_box ; then the global one can + * be obtained using either GridTools::exchange_local_bounding_boxes + * or Utilities::MPI::all_gather * @return A tuple containing the quadrature information * * The elements of the output tuple are: @@ -739,9 +744,9 @@ namespace GridTools return_type #endif distributed_compute_point_locations - (const GridTools::Cache &cache, - const std::vector > &local_points, - const std::vector< BoundingBox > &local_bbox); + (const GridTools::Cache &cache, + const std::vector > &local_points, + const std::vector< std::vector< BoundingBox > > &global_bboxes); /** * Return a map of index:Point, containing the used vertices of the diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index be39c27e8b..e63e6de417 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -4213,14 +4213,14 @@ next_cell: std::vector< std::vector< unsigned int > > > distributed_compute_point_locations - (const GridTools::Cache &cache, - const std::vector > &local_points, - const std::vector< BoundingBox > &local_bbox) + (const GridTools::Cache &cache, + const std::vector > &local_points, + const std::vector< std::vector< BoundingBox > > &global_bboxes) { #ifndef DEAL_II_WITH_MPI (void)cache; (void)local_points; - (void)local_bbox; + (void)global_bboxes; Assert(false, ExcMessage("GridTools::distributed_compute_point_locations() requires MPI.")); std::tuple< std::vector< typename Triangulation::active_cell_iterator >, @@ -4257,10 +4257,6 @@ next_cell: internal::distributed_cptloc::cell_hash > temporary_unmap; - // Obtaining the global mesh description through an all to all communication - std::vector< std::vector< BoundingBox > > global_bounding_boxes; - global_bounding_boxes = Utilities::MPI::all_gather(mpi_communicator,local_bbox); - // Step 1 (part 1): Using the bounding boxes to guess the owner of each points // in local_points unsigned int my_rank = Utilities::MPI::this_mpi_process(mpi_communicator); @@ -4269,7 +4265,7 @@ next_cell: std::tuple< std::vector< std::vector< unsigned int > >, std::map< unsigned int, unsigned int >, std::map< unsigned int, std::vector< unsigned int > > > guessed_points; guessed_points = - GridTools::guess_point_owner(global_bounding_boxes, local_points); + GridTools::guess_point_owner(global_bboxes, local_points); // Preparing to call compute point locations on points which are/might be // local diff --git a/source/grid/grid_tools.inst.in b/source/grid/grid_tools.inst.in index 5268a15fd7..3170d290c4 100644 --- a/source/grid/grid_tools.inst.in +++ b/source/grid/grid_tools.inst.in @@ -88,9 +88,9 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS std::vector< std::vector< unsigned int > > > distributed_compute_point_locations - (const Cache< deal_II_dimension, deal_II_space_dimension > &, - const std::vector< Point< deal_II_space_dimension > > &, - const std::vector< BoundingBox< deal_II_space_dimension > > &); + (const Cache< deal_II_dimension, deal_II_space_dimension > &, + const std::vector< Point< deal_II_space_dimension > > &, + const std::vector< std::vector< BoundingBox< deal_II_space_dimension > > > &); \} #endif diff --git a/tests/grid/distributed_compute_point_locations_01.cc b/tests/grid/distributed_compute_point_locations_01.cc index cf65d62a46..ecf0cb195c 100644 --- a/tests/grid/distributed_compute_point_locations_01.cc +++ b/tests/grid/distributed_compute_point_locations_01.cc @@ -55,11 +55,14 @@ void test_compute_pt_loc(unsigned int n_points) std::vector< BoundingBox > local_bbox = GridTools::compute_mesh_predicate_bounding_box (cache.get_triangulation(), std::function::active_cell_iterator &)>(locally_owned_cell_predicate), - 1, true, 4); // These options should be passed - // Using the distributed version of compute point location + 1, true, 4); + + // Obtaining the global mesh description through an all to all communication + std::vector< std::vector< BoundingBox > > global_bboxes; + global_bboxes = Utilities::MPI::all_gather(mpi_communicator,local_bbox); - // Using the distributed version - auto output_tuple = distributed_compute_point_locations(cache,points,local_bbox); + // Using the distributed version of compute point location + auto output_tuple = distributed_compute_point_locations(cache,points,global_bboxes); // Testing in serial against the serial version auto cell_qpoint_map = GridTools::compute_point_locations(cache,points); diff --git a/tests/grid/distributed_compute_point_locations_02.cc b/tests/grid/distributed_compute_point_locations_02.cc index 08208c6eb3..1ead16c1f0 100644 --- a/tests/grid/distributed_compute_point_locations_02.cc +++ b/tests/grid/distributed_compute_point_locations_02.cc @@ -121,9 +121,13 @@ void test_compute_pt_loc(unsigned int ref_cube, unsigned int ref_sphere) (cache.get_triangulation(), locally_owned_cell_predicate, 1, true, 4); + // Obtaining the global mesh description through an all to all communication + std::vector< std::vector< BoundingBox > > global_bboxes; + global_bboxes = Utilities::MPI::all_gather(mpi_communicator,local_bbox); + // Using the distributed version of compute point location auto output_tuple = distributed_compute_point_locations - (cache,loc_owned_points,local_bbox); + (cache,loc_owned_points,global_bboxes); deallog << "Comparing results" << std::endl; const auto &output_cells = std::get<0>(output_tuple); const auto &output_qpoints = std::get<1>(output_tuple);