From: Sebastian Fuchs Date: Fri, 3 Sep 2021 09:28:07 +0000 (+0200) Subject: Add test checking insert particle method X-Git-Tag: v9.4.0-rc1~1002^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12739%2Fhead;p=dealii.git Add test checking insert particle method follows #12724, #12727 --- diff --git a/tests/particles/insert_particle.cc b/tests/particles/insert_particle.cc new file mode 100644 index 0000000000..7e4e62283d --- /dev/null +++ b/tests/particles/insert_particle.cc @@ -0,0 +1,85 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 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. +// +// --------------------------------------------------------------------- + + + +// check that inserting particles works: +// - in parallel when one processor is not inserting any particles +// - and when all cells are locally owned on one processor + +#include + +#include + +#include +#include + +#include +#include + +#include "../tests.h" + +template +void +test(const unsigned int refinement) +{ + { + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + tr.refine_global(refinement); + MappingQ mapping(1); + + deallog << "Refinement: " << refinement << std::endl; + + deallog << "Global active cells: " << tr.n_global_active_cells() + << std::endl; + deallog << "Locally owned active cells: " + << tr.n_locally_owned_active_cells() << std::endl; + + Particles::ParticleHandler particle_handler(tr, mapping); + + std::vector> positions(1, Point()); + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 1) + positions.clear(); + + particle_handler.insert_particles(positions); + + deallog << "Global particles: " << particle_handler.n_global_particles() + << std::endl; + deallog << "Locally owned particles: " + << particle_handler.n_locally_owned_particles() << std::endl; + } + + deallog << "OK" << std::endl; +} + + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + MPILogInitAll log; + + deallog.push("2d/2d"); + test<2, 2>(1); + deallog.pop(); + deallog << "---" << std::endl; + deallog.push("2d/2d"); + test<2, 2>(2); + deallog.pop(); +} diff --git a/tests/particles/insert_particle.with_p4est=true.mpirun=2.output b/tests/particles/insert_particle.with_p4est=true.mpirun=2.output new file mode 100644 index 0000000000..8bf9398c11 --- /dev/null +++ b/tests/particles/insert_particle.with_p4est=true.mpirun=2.output @@ -0,0 +1,29 @@ + +DEAL:0:2d/2d::Refinement: 1 +DEAL:0:2d/2d::Global active cells: 4 +DEAL:0:2d/2d::Locally owned active cells: 4 +DEAL:0:2d/2d::Global particles: 1 +DEAL:0:2d/2d::Locally owned particles: 1 +DEAL:0:2d/2d::OK +DEAL:0:--- +DEAL:0:2d/2d::Refinement: 2 +DEAL:0:2d/2d::Global active cells: 16 +DEAL:0:2d/2d::Locally owned active cells: 8 +DEAL:0:2d/2d::Global particles: 1 +DEAL:0:2d/2d::Locally owned particles: 1 +DEAL:0:2d/2d::OK + +DEAL:1:2d/2d::Refinement: 1 +DEAL:1:2d/2d::Global active cells: 4 +DEAL:1:2d/2d::Locally owned active cells: 0 +DEAL:1:2d/2d::Global particles: 1 +DEAL:1:2d/2d::Locally owned particles: 0 +DEAL:1:2d/2d::OK +DEAL:1:--- +DEAL:1:2d/2d::Refinement: 2 +DEAL:1:2d/2d::Global active cells: 16 +DEAL:1:2d/2d::Locally owned active cells: 8 +DEAL:1:2d/2d::Global particles: 1 +DEAL:1:2d/2d::Locally owned particles: 0 +DEAL:1:2d/2d::OK +