From b5195523decd37f678213e4dc487fd91d6ef430c Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Wed, 14 Aug 2019 14:55:33 -0700 Subject: [PATCH] Test generation in a refined mesh. --- tests/particles/particle_generator_02.cc | 87 +++++++++++++++++++ ...rticle_generator_02.with_p4est=true.output | 39 +++++++++ 2 files changed, 126 insertions(+) create mode 100644 tests/particles/particle_generator_02.cc create mode 100644 tests/particles/particle_generator_02.with_p4est=true.output diff --git a/tests/particles/particle_generator_02.cc b/tests/particles/particle_generator_02.cc new file mode 100644 index 0000000000..540c46b39a --- /dev/null +++ b/tests/particles/particle_generator_02.cc @@ -0,0 +1,87 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 the particle generation using the +// Particles::Generator::regular_reference_locations function. + +#include + +#include + +#include +#include + +#include +#include + +#include "../tests.h" + +template +void +test() +{ + { + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + tr.refine_global(1); + MappingQ mapping(1); + + Particles::ParticleHandler particle_handler(tr, mapping); + + std::vector> particle_reference_locations(1, Point()); + + for (unsigned int i = 0; i < dim; ++i) + particle_reference_locations[0](i) = 0.5; + + Particles::Generator::regular_reference_locations( + tr, particle_reference_locations, particle_handler); + + deallog << "Particle number: " << particle_handler.n_global_particles() + << std::endl; + + for (const auto &particle : particle_handler) + { + deallog << "Particle location: " << particle.get_location() + << std::endl; + deallog << "Particle reference location: " + << particle.get_reference_location() << std::endl; + } + } + + deallog << "OK" << std::endl; +} + + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + initlog(); + + deallog.push("2d/2d"); + test<2, 2>(); + deallog.pop(); + deallog.push("2d/3d"); + test<2, 3>(); + deallog.pop(); + deallog.push("3d/3d"); + test<3, 3>(); + deallog.pop(); +} diff --git a/tests/particles/particle_generator_02.with_p4est=true.output b/tests/particles/particle_generator_02.with_p4est=true.output new file mode 100644 index 0000000000..96cc5e83d4 --- /dev/null +++ b/tests/particles/particle_generator_02.with_p4est=true.output @@ -0,0 +1,39 @@ + +DEAL:2d/2d::Particle number: 4 +DEAL:2d/2d::Particle location: 0.250000 0.250000 +DEAL:2d/2d::Particle reference location: 0.500000 0.500000 +DEAL:2d/2d::Particle location: 0.750000 0.250000 +DEAL:2d/2d::Particle reference location: 0.500000 0.500000 +DEAL:2d/2d::Particle location: 0.250000 0.750000 +DEAL:2d/2d::Particle reference location: 0.500000 0.500000 +DEAL:2d/2d::Particle location: 0.750000 0.750000 +DEAL:2d/2d::Particle reference location: 0.500000 0.500000 +DEAL:2d/2d::OK +DEAL:2d/3d::Particle number: 4 +DEAL:2d/3d::Particle location: 0.250000 0.250000 0.00000 +DEAL:2d/3d::Particle reference location: 0.500000 0.500000 +DEAL:2d/3d::Particle location: 0.750000 0.250000 0.00000 +DEAL:2d/3d::Particle reference location: 0.500000 0.500000 +DEAL:2d/3d::Particle location: 0.250000 0.750000 0.00000 +DEAL:2d/3d::Particle reference location: 0.500000 0.500000 +DEAL:2d/3d::Particle location: 0.750000 0.750000 0.00000 +DEAL:2d/3d::Particle reference location: 0.500000 0.500000 +DEAL:2d/3d::OK +DEAL:3d/3d::Particle number: 8 +DEAL:3d/3d::Particle location: 0.250000 0.250000 0.250000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.750000 0.250000 0.250000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.250000 0.750000 0.250000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.750000 0.750000 0.250000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.250000 0.250000 0.750000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.750000 0.250000 0.750000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.250000 0.750000 0.750000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::Particle location: 0.750000 0.750000 0.750000 +DEAL:3d/3d::Particle reference location: 0.500000 0.500000 0.500000 +DEAL:3d/3d::OK -- 2.39.5