]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test with 3 mpi processes and 3 particles.
authorMenno Fraters <menno.fraters@outlook.com>
Sat, 25 Jan 2020 08:24:32 +0000 (00:24 -0800)
committerMenno Fraters <menno.fraters@outlook.com>
Sat, 25 Jan 2020 08:24:32 +0000 (00:24 -0800)
tests/particles/generators_11.cc [new file with mode: 0644]
tests/particles/generators_11.with_p4est=true.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/particles/generators_11.cc b/tests/particles/generators_11.cc
new file mode 100644 (file)
index 0000000..a0d6ef9
--- /dev/null
@@ -0,0 +1,136 @@
+// ---------------------------------------------------------------------
+//
+// 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::probabilistic_locations function
+// using different probability distributions. In particular
+// check that for a non-random cell selection the domain
+// has the expected number of particles according when there
+// are more mpi ranks than particles.
+
+#include <deal.II/base/function_lib.h>
+
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_nothing.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/generators.h>
+#include <deal.II/particles/particle_handler.h>
+
+#include "../tests.h"
+
+template <int dim, int spacedim>
+void
+test(Function<spacedim> &probability_density_function)
+{
+  {
+    parallel::distributed::Triangulation<dim, spacedim> tr(MPI_COMM_WORLD);
+
+    GridGenerator::hyper_cube(tr);
+    tr.refine_global(1);
+
+    MappingQ<dim, spacedim> mapping(1);
+
+    Particles::ParticleHandler<dim, spacedim> particle_handler(tr, mapping);
+
+    Particles::Generators::probabilistic_locations(
+      tr, probability_density_function, false, 3, particle_handler, mapping);
+
+    if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+      {
+        deallog << "Locally owned active cells: "
+                << tr.n_locally_owned_active_cells() << std::endl;
+
+        deallog << "Global particles: " << particle_handler.n_global_particles()
+                << std::endl;
+
+        for (const auto &cell : tr.active_cell_iterators())
+          {
+            if (cell->is_locally_owned())
+              {
+                deallog << "Cell " << cell << " has "
+                        << particle_handler.n_particles_in_cell(cell)
+                        << " particles." << std::endl;
+              }
+          }
+
+        for (const auto &particle : particle_handler)
+          {
+            deallog << "Particle index " << particle.get_id() << " is in cell "
+                    << particle.get_surrounding_cell(tr) << std::endl;
+            deallog << "Particle location: " << particle.get_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");
+    Functions::ConstantFunction<2> probability_density_function(1.0);
+    test<2, 2>(probability_density_function);
+    deallog.pop();
+  }
+  {
+    deallog.push("2d/3d");
+    Functions::ConstantFunction<3> probability_density_function(1.0);
+    test<2, 3>(probability_density_function);
+  }
+  {
+    deallog.pop();
+    deallog.push("3d/3d");
+    Functions::ConstantFunction<3> probability_density_function(1.0);
+    test<3, 3>(probability_density_function);
+    deallog.pop();
+  }
+
+  {
+    deallog.push("2d/2d");
+    Functions::Q1WedgeFunction<2> probability_density_function;
+    test<2, 2>(probability_density_function);
+    deallog.pop();
+  }
+  {
+    deallog.push("2d/3d");
+    Functions::Q1WedgeFunction<3> probability_density_function;
+    test<2, 3>(probability_density_function);
+  }
+  {
+    deallog.pop();
+    deallog.push("3d/3d");
+    Functions::Q1WedgeFunction<3> probability_density_function;
+    test<3, 3>(probability_density_function);
+    deallog.pop();
+  }
+}
diff --git a/tests/particles/generators_11.with_p4est=true.mpirun=3.output b/tests/particles/generators_11.with_p4est=true.mpirun=3.output
new file mode 100644 (file)
index 0000000..d296d53
--- /dev/null
@@ -0,0 +1,22 @@
+
+DEAL:2d/2d::OK
+DEAL:2d/3d::OK
+DEAL:3d/3d::OK
+DEAL:2d/2d::OK
+DEAL:2d/3d::OK
+DEAL:3d/3d::OK
+EAL:2d/3d::Locally owned active cells: 0
+DEAL:2d/3d::Global particles: 3
+DEAL:2d/3d::OK
+DEAL:3d/3d::Locally owned active cells: 0
+DEAL:3d/3d::Global particles: 3
+DEAL:3d/3d::OK
+DEAL:2d/2d::Locally owned active cells: 0
+DEAL:2d/2d::Global particles: 3
+DEAL:2d/2d::OK
+DEAL:2d/3d::Locally owned active cells: 0
+DEAL:2d/3d::Global particles: 3
+DEAL:2d/3d::OK
+DEAL:3d/3d::Locally owned active cells: 0
+DEAL:3d/3d::Global particles: 3
+DEAL:3d/3d::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.