From bd58f4aa5df2ee16456d4b3ac7c7f8b1a9956eee Mon Sep 17 00:00:00 2001 From: Bruno Blais Date: Sat, 1 Jul 2023 11:58:53 -0400 Subject: [PATCH] Update test --- source/particles/particle_handler.cc | 3 +- tests/serialization/particle_handler_04.cc | 39 +++++++++++++++---- ...ut => particle_handler_04.mpirun=1.output} | 0 3 files changed, 33 insertions(+), 9 deletions(-) rename tests/serialization/{particle_handler_04.with_p4est=true.mpirun=1.output => particle_handler_04.mpirun=1.output} (100%) diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 3a31e770d9..dbb13dd41a 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -2194,7 +2194,6 @@ namespace Particles "by the ParticleHandler class. Either insert particles after mesh " "creation and do not refine afterwards, or use a distributed triangulation.")); -#ifdef DEAL_II_WITH_P4EST const auto callback_function = [this]( const typename Triangulation::cell_iterator @@ -2205,7 +2204,7 @@ namespace Particles handle = distributed_triangulation->register_data_attach( callback_function, /*returns_variable_size_data=*/true); -#endif + } diff --git a/tests/serialization/particle_handler_04.cc b/tests/serialization/particle_handler_04.cc index 0c35d033cb..6ec77fa87b 100644 --- a/tests/serialization/particle_handler_04.cc +++ b/tests/serialization/particle_handler_04.cc @@ -100,8 +100,32 @@ test() MappingQ mapping(1); Particles::ParticleHandler particle_handler(tr, mapping); + std::vector> position(2); + std::vector> reference_position(2); - create_regular_particle_distribution(particle_handler, tr); + for (unsigned int i = 0; i < dim; ++i) + { + position[0](i) = 0.125; + position[1](i) = 0.525; + } + + Particles::Particle particle1(position[0], + reference_position[0], + 0); + Particles::Particle particle2(position[1], + reference_position[1], + 1); + + typename Triangulation::active_cell_iterator cell1(&tr, + 2, + 0); + typename Triangulation::active_cell_iterator cell2(&tr, + 2, + 0); + particle_handler.insert_particle(particle1, cell1); + particle_handler.insert_particle(particle2, cell2); + + //create_regular_particle_distribution(particle_handler, tr); particle_handler.sort_particles_into_subdomains_and_cells(); for (auto particle = particle_handler.begin(); @@ -114,9 +138,9 @@ test() // save data to archive std::ostringstream oss; { - boost::archive::text_oarchive oa(oss, boost::archive::no_header); + //boost::archive::text_oarchive oa(oss, boost::archive::no_header); - oa << particle_handler; + //oa << particle_handler; particle_handler.prepare_for_serialization(); tr.save("checkpoint"); @@ -128,7 +152,7 @@ test() // Now remove all information in tr and particle_handler, // this is like creating new objects after a restart tr.clear(); - GridGenerator::hyper_cube(tr); + //GridGenerator::hyper_cube(tr); particle_handler.clear(); particle_handler.initialize(tr, mapping); @@ -145,14 +169,15 @@ test() // does not know if something was stored in the user data of the // triangulation). { - std::istringstream iss(oss.str()); - boost::archive::text_iarchive ia(iss, boost::archive::no_header); + // std::istringstream iss(oss.str()); + // boost::archive::text_iarchive ia(iss, boost::archive::no_header); - ia >> particle_handler; + // ia >> particle_handler; tr.load("checkpoint"); particle_handler.deserialize(); } + deallog << "After deserialization global number of particles is: " << particle_handler.n_global_particles() << std::endl; for (auto particle = particle_handler.begin(); particle != particle_handler.end(); ++particle) diff --git a/tests/serialization/particle_handler_04.with_p4est=true.mpirun=1.output b/tests/serialization/particle_handler_04.mpirun=1.output similarity index 100% rename from tests/serialization/particle_handler_04.with_p4est=true.mpirun=1.output rename to tests/serialization/particle_handler_04.mpirun=1.output -- 2.39.5