const auto parallel_triangulation =
dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
&*triangulation);
- if (parallel_triangulation != nullptr)
+ if (parallel_triangulation == nullptr ||
+ dealii::Utilities::MPI::n_mpi_processes(
+ parallel_triangulation->get_communicator()) == 1)
{
- if (dealii::Utilities::MPI::n_mpi_processes(
- parallel_triangulation->get_communicator()) == 1)
- return;
+ return;
}
- else
- return;
#ifdef DEAL_II_WITH_MPI
// First clear the current ghost_particle information
switch (status)
{
- case parallel::distributed::Triangulation<dim,
- spacedim>::CELL_PERSIST: {
+ case parallel::distributed::Triangulation<dim, spacedim>::CELL_PERSIST:
+ {
auto position_hint = particles.end();
for (const auto &particle : loaded_particles_on_cell)
{
}
break;
- case parallel::distributed::Triangulation<dim,
- spacedim>::CELL_COARSEN: {
+ case parallel::distributed::Triangulation<dim, spacedim>::CELL_COARSEN:
+ {
typename std::multimap<internal::LevelInd,
Particle<dim, spacedim>>::iterator
position_hint = particles.end();
}
break;
- case parallel::distributed::Triangulation<dim,
- spacedim>::CELL_REFINE: {
+ case parallel::distributed::Triangulation<dim, spacedim>::CELL_REFINE:
+ {
std::vector<
typename std::multimap<internal::LevelInd,
Particle<dim, spacedim>>::iterator>
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// like particle_handler_06, but after exchanging the ghost particles
+// modifies the location of the particles and updates them through
+// the update_ghosts mechanism. This test also adds a single property
+// to the particles. This property is also modified and then updated
+// through the update_ghosts mechanism.
+
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/fe/mapping_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <deal.II/particles/particle_handler.h>
+
+#include "../tests.h"
+
+template <int dim, int spacedim>
+void
+test()
+{
+ {
+ parallel::distributed::Triangulation<dim, spacedim> tr(MPI_COMM_WORLD);
+
+ GridGenerator::hyper_cube(tr);
+ tr.refine_global(2);
+ MappingQ<dim, spacedim> mapping(1);
+
+ Particles::ParticleHandler<dim, spacedim> particle_handler(tr, mapping, 1);
+
+ Point<spacedim> position;
+ Point<dim> reference_position;
+
+ if (Utilities::MPI::this_mpi_process(tr.get_communicator()) == 0)
+ for (unsigned int i = 0; i < dim; ++i)
+ position(i) = 0.475;
+ else
+ for (unsigned int i = 0; i < dim; ++i)
+ position(i) = 0.525;
+
+ Particles::Particle<dim, spacedim> particle(
+ position,
+ reference_position,
+ Utilities::MPI::this_mpi_process(tr.get_communicator()));
+ typename Triangulation<dim, spacedim>::active_cell_iterator cell =
+ tr.begin_active();
+ particle_handler.insert_particle(particle, cell);
+
+ particle_handler.sort_particles_into_subdomains_and_cells();
+
+ // Set the properties of the particle to be a unique number
+ for (auto particle = particle_handler.begin();
+ particle != particle_handler.end();
+ ++particle)
+ {
+ particle->get_properties()[0] =
+ 10 + Utilities::MPI::this_mpi_process(tr.get_communicator());
+ }
+
+
+ particle_handler.exchange_ghost_particles();
+
+ for (auto particle = particle_handler.begin();
+ particle != particle_handler.end();
+ ++particle)
+ deallog << "Particle id : " << particle->get_id()
+ << " location : " << particle->get_location()
+ << " property : " << particle->get_properties()[0]
+ << " is local on process : "
+ << Utilities::MPI::this_mpi_process(tr.get_communicator())
+ << std::endl;
+
+ for (auto particle = particle_handler.begin_ghost();
+ particle != particle_handler.end_ghost();
+ ++particle)
+ deallog << "Particle id : " << particle->get_id()
+ << " location : " << particle->get_location()
+ << " property : " << particle->get_properties()[0]
+ << " is ghost on process : "
+ << Utilities::MPI::this_mpi_process(tr.get_communicator())
+ << std::endl;
+
+ deallog << "Modifying particles positions and properties" << std::endl;
+
+ // Modify the location of a single particle on processor 0 and update the
+ // ghosts
+ for (auto particle = particle_handler.begin();
+ particle != particle_handler.end();
+ ++particle)
+ {
+ auto location = particle->get_location();
+ location[0] += 0.1;
+ particle->get_properties()[0] += 10;
+ particle->set_location(location);
+ }
+ particle_handler.update_ghost_particles();
+
+ for (auto particle = particle_handler.begin();
+ particle != particle_handler.end();
+ ++particle)
+ deallog << "Particle id : " << particle->get_id()
+ << " location : " << particle->get_location()
+ << " property : " << particle->get_properties()[0]
+ << " is local on process : "
+ << Utilities::MPI::this_mpi_process(tr.get_communicator())
+ << std::endl;
+
+ for (auto particle = particle_handler.begin_ghost();
+ particle != particle_handler.end_ghost();
+ ++particle)
+ deallog << "Particle id : " << particle->get_id()
+ << " location : " << particle->get_location()
+ << " property : " << particle->get_properties()[0]
+ << " is ghost on process : "
+ << Utilities::MPI::this_mpi_process(tr.get_communicator())
+ << std::endl;
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char *argv[])
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+
+ MPILogInitAll all;
+
+ 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();
+}
--- /dev/null
+
+DEAL:0:2d/2d::Particle id : 0 location : 0.475000 0.475000 property : 10.0000 is local on process : 0
+DEAL:0:2d/2d::Particle id : 1 location : 0.525000 0.525000 property : 11.0000 is ghost on process : 0
+DEAL:0:2d/2d::Modifying particles positions and properties
+DEAL:0:2d/2d::Particle id : 0 location : 0.575000 0.475000 property : 20.0000 is local on process : 0
+DEAL:0:2d/2d::Particle id : 1 location : 0.625000 0.525000 property : 21.0000 is ghost on process : 0
+DEAL:0:2d/2d::OK
+DEAL:0:2d/3d::Particle id : 0 location : 0.475000 0.475000 0.00000 property : 10.0000 is local on process : 0
+DEAL:0:2d/3d::Particle id : 1 location : 0.525000 0.525000 0.00000 property : 11.0000 is ghost on process : 0
+DEAL:0:2d/3d::Modifying particles positions and properties
+DEAL:0:2d/3d::Particle id : 0 location : 0.575000 0.475000 0.00000 property : 20.0000 is local on process : 0
+DEAL:0:2d/3d::Particle id : 1 location : 0.625000 0.525000 0.00000 property : 21.0000 is ghost on process : 0
+DEAL:0:2d/3d::OK
+DEAL:0:3d/3d::Particle id : 0 location : 0.475000 0.475000 0.475000 property : 10.0000 is local on process : 0
+DEAL:0:3d/3d::Particle id : 1 location : 0.525000 0.525000 0.525000 property : 11.0000 is ghost on process : 0
+DEAL:0:3d/3d::Modifying particles positions and properties
+DEAL:0:3d/3d::Particle id : 0 location : 0.575000 0.475000 0.475000 property : 20.0000 is local on process : 0
+DEAL:0:3d/3d::Particle id : 1 location : 0.625000 0.525000 0.525000 property : 21.0000 is ghost on process : 0
+DEAL:0:3d/3d::OK
+
+DEAL:1:2d/2d::Particle id : 1 location : 0.525000 0.525000 property : 11.0000 is local on process : 1
+DEAL:1:2d/2d::Particle id : 0 location : 0.475000 0.475000 property : 10.0000 is ghost on process : 1
+DEAL:1:2d/2d::Modifying particles positions and properties
+DEAL:1:2d/2d::Particle id : 1 location : 0.625000 0.525000 property : 21.0000 is local on process : 1
+DEAL:1:2d/2d::Particle id : 0 location : 0.575000 0.475000 property : 20.0000 is ghost on process : 1
+DEAL:1:2d/2d::OK
+DEAL:1:2d/3d::Particle id : 1 location : 0.525000 0.525000 0.00000 property : 11.0000 is local on process : 1
+DEAL:1:2d/3d::Particle id : 0 location : 0.475000 0.475000 0.00000 property : 10.0000 is ghost on process : 1
+DEAL:1:2d/3d::Modifying particles positions and properties
+DEAL:1:2d/3d::Particle id : 1 location : 0.625000 0.525000 0.00000 property : 21.0000 is local on process : 1
+DEAL:1:2d/3d::Particle id : 0 location : 0.575000 0.475000 0.00000 property : 20.0000 is ghost on process : 1
+DEAL:1:2d/3d::OK
+DEAL:1:3d/3d::Particle id : 1 location : 0.525000 0.525000 0.525000 property : 11.0000 is local on process : 1
+DEAL:1:3d/3d::Particle id : 0 location : 0.475000 0.475000 0.475000 property : 10.0000 is ghost on process : 1
+DEAL:1:3d/3d::Modifying particles positions and properties
+DEAL:1:3d/3d::Particle id : 1 location : 0.625000 0.525000 0.525000 property : 21.0000 is local on process : 1
+DEAL:1:3d/3d::Particle id : 0 location : 0.575000 0.475000 0.475000 property : 20.0000 is ghost on process : 1
+DEAL:1:3d/3d::OK
+