Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for GridTools::Cache::get_covering_rtree(). #15005

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 95 additions & 0 deletions tests/grid/grid_tools_cache_08.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// ---------------------------------------------------------------------
//
// Copyright (C) 2001 - 2021 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------

// Validate grid_tools_cache for the creation of build global rtree


#include <deal.II/distributed/grid_refinement.h>
#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>

#include <deal.II/grid/filtered_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_tools_cache.h>
#include <deal.II/grid/tria.h>

#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/signals2.hpp>

#include "../tests.h"


namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;


template <int dim>
void
test()
{
deallog << "Testing for dim = " << dim << std::endl;

// Creating a grid in the square [0,1]x[0,1]
parallel::shared::Triangulation<dim> tria(
MPI_COMM_WORLD,
Triangulation<dim>::none,
false,
parallel::shared::Triangulation<dim>::Settings::partition_zoltan);
GridGenerator::hyper_cube(tria);
tria.refine_global(std::max(8 - dim, 3));


GridTools::Cache<dim> cache(tria);

const auto &global_description = cache.get_covering_rtree();

// Extract from the cache a list of all bounding boxes with process owners:
std::vector<std::pair<BoundingBox<dim>, unsigned int>> test_results;
global_description.query(bgi::satisfies([](const auto &) { return true; }),
std::back_inserter(test_results));

// Loop over all bounding boxes and output them. We expect this list
// to be identical on all processes, but do not actually check this
// (other than by the fact that the output file records this).
for (const auto &bb_and_owner : test_results)
{
const auto &bd_points = bb_and_owner.first.get_boundary_points();
deallog << " Bounding box: p1 " << bd_points.first << " p2 "
<< bd_points.second << " rank owner: " << bb_and_owner.second
<< std::endl;
}
}



int
main(int argc, char **argv)
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
#ifdef DEAL_II_WITH_MPI
MPILogInitAll log;
#else
initlog();
deallog.push("0");
#endif

test<1>();
test<2>();
test<3>();

return 0;
}
36 changes: 36 additions & 0 deletions tests/grid/grid_tools_cache_08.mpirun=1.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

DEAL:0::Testing for dim = 1
DEAL:0:: Bounding box: p1 0.00000 p2 0.125000 rank owner: 0
DEAL:0:: Bounding box: p1 0.125000 p2 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 p2 0.375000 rank owner: 0
DEAL:0:: Bounding box: p1 0.375000 p2 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 p2 0.625000 rank owner: 0
DEAL:0:: Bounding box: p1 0.625000 p2 0.750000 rank owner: 0
DEAL:0:: Bounding box: p1 0.750000 p2 0.875000 rank owner: 0
DEAL:0:: Bounding box: p1 0.875000 p2 1.00000 rank owner: 0
DEAL:0::Testing for dim = 2
DEAL:0:: Bounding box: p1 0.00000 0.00000 p2 0.250000 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.250000 p2 0.250000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 0.00000 p2 0.500000 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 0.250000 p2 0.500000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.500000 p2 0.250000 0.750000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.750000 p2 0.250000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 0.500000 p2 0.500000 0.750000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 0.750000 p2 0.500000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.00000 p2 0.750000 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.250000 p2 0.750000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.750000 0.00000 p2 1.00000 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.750000 0.250000 p2 1.00000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.500000 p2 0.750000 0.750000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.750000 p2 0.750000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.750000 0.500000 p2 1.00000 0.750000 rank owner: 0
DEAL:0:: Bounding box: p1 0.750000 0.750000 p2 1.00000 1.00000 rank owner: 0
DEAL:0::Testing for dim = 3
DEAL:0:: Bounding box: p1 0.00000 0.00000 0.00000 p2 0.500000 0.500000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.00000 0.500000 p2 0.500000 0.500000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.500000 0.00000 p2 0.500000 1.00000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.500000 0.500000 p2 0.500000 1.00000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.00000 0.00000 p2 1.00000 0.500000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.00000 0.500000 p2 1.00000 0.500000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.500000 0.00000 p2 1.00000 1.00000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 0.500000 0.500000 p2 1.00000 1.00000 1.00000 rank owner: 0
79 changes: 79 additions & 0 deletions tests/grid/grid_tools_cache_08.mpirun=2.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

DEAL:0::Testing for dim = 1
DEAL:0:: Bounding box: p1 0.00000 p2 0.125000 rank owner: 0
DEAL:0:: Bounding box: p1 0.125000 p2 0.250000 rank owner: 0
DEAL:0:: Bounding box: p1 0.250000 p2 0.375000 rank owner: 0
DEAL:0:: Bounding box: p1 0.375000 p2 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.500000 p2 0.546875 rank owner: 0
DEAL:0:: Bounding box: p1 0.546875 p2 0.671875 rank owner: 1
DEAL:0:: Bounding box: p1 0.671875 p2 0.796875 rank owner: 1
DEAL:0:: Bounding box: p1 0.796875 p2 0.921875 rank owner: 1
DEAL:0:: Bounding box: p1 0.921875 p2 1.00000 rank owner: 1
DEAL:0::Testing for dim = 2
DEAL:0:: Bounding box: p1 0.406250 0.656250 p2 0.562500 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.218750 p2 0.281250 0.468750 rank owner: 0
DEAL:0:: Bounding box: p1 0.265625 0.00000 p2 0.546875 0.234375 rank owner: 0
DEAL:0:: Bounding box: p1 0.265625 0.234375 p2 0.546875 0.468750 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.453125 p2 0.234375 0.734375 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.718750 p2 0.234375 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.234375 0.453125 p2 0.562500 0.671875 rank owner: 0
DEAL:0:: Bounding box: p1 0.218750 0.656250 p2 0.421875 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.00000 p2 0.281250 0.234375 rank owner: 0
DEAL:0:: Bounding box: p1 0.546875 0.531250 p2 0.781250 0.828125 rank owner: 1
DEAL:0:: Bounding box: p1 0.531250 0.00000 p2 0.781250 0.281250 rank owner: 1
DEAL:0:: Bounding box: p1 0.546875 0.265625 p2 0.781250 0.546875 rank owner: 1
DEAL:0:: Bounding box: p1 0.562500 0.828125 p2 0.921875 1.00000 rank owner: 1
DEAL:0:: Bounding box: p1 0.765625 0.00000 p2 1.00000 0.281250 rank owner: 1
DEAL:0:: Bounding box: p1 0.765625 0.531250 p2 1.00000 0.828125 rank owner: 1
DEAL:0:: Bounding box: p1 0.765625 0.265625 p2 1.00000 0.546875 rank owner: 1
DEAL:0:: Bounding box: p1 0.906250 0.828125 p2 1.00000 1.00000 rank owner: 1
DEAL:0::Testing for dim = 3
DEAL:0:: Bounding box: p1 0.00000 0.00000 0.00000 p2 0.531250 0.500000 0.500000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.00000 0.468750 p2 0.531250 0.500000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.468750 0.00000 p2 0.531250 1.00000 0.468750 rank owner: 0
DEAL:0:: Bounding box: p1 0.00000 0.468750 0.437500 p2 0.437500 1.00000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.406250 0.468750 0.437500 p2 0.531250 1.00000 1.00000 rank owner: 0
DEAL:0:: Bounding box: p1 0.531250 0.00000 0.00000 p2 1.00000 0.562500 0.531250 rank owner: 1
DEAL:0:: Bounding box: p1 0.531250 0.00000 0.500000 p2 1.00000 0.562500 1.00000 rank owner: 1
DEAL:0:: Bounding box: p1 0.531250 0.531250 0.00000 p2 1.00000 1.00000 0.593750 rank owner: 1
DEAL:0:: Bounding box: p1 0.531250 0.531250 0.562500 p2 1.00000 1.00000 1.00000 rank owner: 1

DEAL:1::Testing for dim = 1
DEAL:1:: Bounding box: p1 0.00000 p2 0.125000 rank owner: 0
DEAL:1:: Bounding box: p1 0.125000 p2 0.250000 rank owner: 0
DEAL:1:: Bounding box: p1 0.250000 p2 0.375000 rank owner: 0
DEAL:1:: Bounding box: p1 0.375000 p2 0.500000 rank owner: 0
DEAL:1:: Bounding box: p1 0.500000 p2 0.546875 rank owner: 0
DEAL:1:: Bounding box: p1 0.546875 p2 0.671875 rank owner: 1
DEAL:1:: Bounding box: p1 0.671875 p2 0.796875 rank owner: 1
DEAL:1:: Bounding box: p1 0.796875 p2 0.921875 rank owner: 1
DEAL:1:: Bounding box: p1 0.921875 p2 1.00000 rank owner: 1
DEAL:1::Testing for dim = 2
DEAL:1:: Bounding box: p1 0.406250 0.656250 p2 0.562500 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.218750 p2 0.281250 0.468750 rank owner: 0
DEAL:1:: Bounding box: p1 0.265625 0.00000 p2 0.546875 0.234375 rank owner: 0
DEAL:1:: Bounding box: p1 0.265625 0.234375 p2 0.546875 0.468750 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.453125 p2 0.234375 0.734375 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.718750 p2 0.234375 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.234375 0.453125 p2 0.562500 0.671875 rank owner: 0
DEAL:1:: Bounding box: p1 0.218750 0.656250 p2 0.421875 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.00000 p2 0.281250 0.234375 rank owner: 0
DEAL:1:: Bounding box: p1 0.546875 0.531250 p2 0.781250 0.828125 rank owner: 1
DEAL:1:: Bounding box: p1 0.531250 0.00000 p2 0.781250 0.281250 rank owner: 1
DEAL:1:: Bounding box: p1 0.546875 0.265625 p2 0.781250 0.546875 rank owner: 1
DEAL:1:: Bounding box: p1 0.562500 0.828125 p2 0.921875 1.00000 rank owner: 1
DEAL:1:: Bounding box: p1 0.765625 0.00000 p2 1.00000 0.281250 rank owner: 1
DEAL:1:: Bounding box: p1 0.765625 0.531250 p2 1.00000 0.828125 rank owner: 1
DEAL:1:: Bounding box: p1 0.765625 0.265625 p2 1.00000 0.546875 rank owner: 1
DEAL:1:: Bounding box: p1 0.906250 0.828125 p2 1.00000 1.00000 rank owner: 1
DEAL:1::Testing for dim = 3
DEAL:1:: Bounding box: p1 0.00000 0.00000 0.00000 p2 0.531250 0.500000 0.500000 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.00000 0.468750 p2 0.531250 0.500000 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.468750 0.00000 p2 0.531250 1.00000 0.468750 rank owner: 0
DEAL:1:: Bounding box: p1 0.00000 0.468750 0.437500 p2 0.437500 1.00000 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.406250 0.468750 0.437500 p2 0.531250 1.00000 1.00000 rank owner: 0
DEAL:1:: Bounding box: p1 0.531250 0.00000 0.00000 p2 1.00000 0.562500 0.531250 rank owner: 1
DEAL:1:: Bounding box: p1 0.531250 0.00000 0.500000 p2 1.00000 0.562500 1.00000 rank owner: 1
DEAL:1:: Bounding box: p1 0.531250 0.531250 0.00000 p2 1.00000 1.00000 0.593750 rank owner: 1
DEAL:1:: Bounding box: p1 0.531250 0.531250 0.562500 p2 1.00000 1.00000 1.00000 rank owner: 1