From e0f492ea12d17157fb3361580c0232dd262be4fb Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Tue, 2 Jun 2020 11:01:35 -0700 Subject: [PATCH] Add test --- tests/particles/data_out_05.cc | 114 ++++++++++++++++++ ...ata_out_05.with_p4est=true.mpirun=2.output | 31 +++++ 2 files changed, 145 insertions(+) create mode 100644 tests/particles/data_out_05.cc create mode 100644 tests/particles/data_out_05.with_p4est=true.mpirun=2.output diff --git a/tests/particles/data_out_05.cc b/tests/particles/data_out_05.cc new file mode 100644 index 0000000000..49c9553f20 --- /dev/null +++ b/tests/particles/data_out_05.cc @@ -0,0 +1,114 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2019 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. +// +// --------------------------------------------------------------------- + + + +// Create a particle handler then generate an output +// Tests that output can be written even if no particles are on the local +// process. See https://github.com/dealii/dealii/issues/10443. + +#include + +#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(2); + MappingQ mapping(1); + + // Create a particle handler using one manually created particle + Particles::ParticleHandler particle_handler(tr, + mapping, + spacedim); + std::vector> position(1); + std::vector> reference_position(1); + std::vector properties(spacedim); + + for (unsigned int i = 0; i < dim; ++i) + { + position[0](i) = 0.125; + } + + for (unsigned int i = 0; i < spacedim; ++i) + { + properties[i] = 0.125; + } + + Particles::Particle particle1(position[0], + reference_position[0], + 0); + + typename Triangulation::active_cell_iterator cell1(&tr, + 2, + 0); + + auto particle_it = particle_handler.insert_particle(particle1, cell1); + particle_it->set_properties(properties); + + std::vector data_names; + std::vector + data_interpretations; + + for (unsigned int i = 0; i < spacedim; ++i) + { + data_names.emplace_back("property_coord_" + std::to_string(i)); + data_interpretations.emplace_back( + DataComponentInterpretation::component_is_scalar); + } + + Particles::DataOut particle_output; + particle_output.build_patches(particle_handler, + data_names, + data_interpretations); + particle_output.write_gnuplot(deallog.get_file_stream()); + } + + 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/data_out_05.with_p4est=true.mpirun=2.output b/tests/particles/data_out_05.with_p4est=true.mpirun=2.output new file mode 100644 index 0000000000..99cd389080 --- /dev/null +++ b/tests/particles/data_out_05.with_p4est=true.mpirun=2.output @@ -0,0 +1,31 @@ + +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +0.125000 0.125000 0.00000 0.125000 0.125000 + +DEAL:2d/2d::OK +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +0.125000 0.125000 0.00000 0.00000 0.125000 0.125000 0.125000 + +DEAL:2d/3d::OK +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +0.125000 0.125000 0.125000 0.00000 0.125000 0.125000 0.125000 + +DEAL:3d/3d::OK -- 2.39.5