]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test generation in a refined mesh.
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Wed, 14 Aug 2019 21:55:33 +0000 (14:55 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Wed, 14 Aug 2019 21:56:21 +0000 (14:56 -0700)
tests/particles/particle_generator_02.cc [new file with mode: 0644]
tests/particles/particle_generator_02.with_p4est=true.output [new file with mode: 0644]

diff --git a/tests/particles/particle_generator_02.cc b/tests/particles/particle_generator_02.cc
new file mode 100644 (file)
index 0000000..540c46b
--- /dev/null
@@ -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 <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_generator.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(1);
+    MappingQ<dim, spacedim> mapping(1);
+
+    Particles::ParticleHandler<dim, spacedim> particle_handler(tr, mapping);
+
+    std::vector<Point<dim>> particle_reference_locations(1, Point<dim>());
+
+    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 (file)
index 0000000..96cc5e8
--- /dev/null
@@ -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

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.