]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tests to ensure that the order of pft and be the base triangulations are the same 9362/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 17 Jan 2020 04:43:22 +0000 (05:43 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 26 Jan 2020 20:16:11 +0000 (21:16 +0100)
tests/fullydistributed_grids/copy_distributed_tria_03.cc [new file with mode: 0644]
tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=1.output [new file with mode: 0644]
tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=5.output [new file with mode: 0644]
tests/fullydistributed_grids/copy_serial_tria_08.cc [new file with mode: 0644]
tests/fullydistributed_grids/copy_serial_tria_08.mpirun=1.output [new file with mode: 0644]
tests/fullydistributed_grids/copy_serial_tria_08.mpirun=5.output [new file with mode: 0644]

diff --git a/tests/fullydistributed_grids/copy_distributed_tria_03.cc b/tests/fullydistributed_grids/copy_distributed_tria_03.cc
new file mode 100644 (file)
index 0000000..5faddbf
--- /dev/null
@@ -0,0 +1,94 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 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 distributed triangulation with multigrid levels, copy it,
+// and show that the CellIds have not changed.
+
+#include <deal.II/base/mpi.h>
+
+#include <deal.II/distributed/fully_distributed_tria.h>
+#include <deal.II/distributed/fully_distributed_tria_util.h>
+#include <deal.II/distributed/shared_tria.h>
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria.h>
+
+#include "./tests.h"
+
+using namespace dealii;
+
+template <int dim>
+void
+test(int n_refinements, const int n_subdivisions, MPI_Comm comm)
+{
+  // create pdt
+  parallel::distributed::Triangulation<dim> tria_pdt(
+    comm,
+    dealii::Triangulation<dim>::none,
+    parallel::distributed::Triangulation<dim>::construct_multigrid_hierarchy);
+  GridGenerator::subdivided_hyper_cube(tria_pdt, n_subdivisions);
+  tria_pdt.refine_global(n_refinements);
+
+  // create instance of pft
+  parallel::fullydistributed::Triangulation<dim> tria_pft(comm);
+
+  // extract relevant information form pdt
+  auto construction_data = parallel::fullydistributed::Utilities::
+    create_construction_data_from_triangulation(tria_pdt, comm, true);
+
+  // actually create triangulation
+  tria_pft.create_triangulation(construction_data);
+
+  // copare centers of cells
+  for (auto &cell : tria_pft.active_cell_iterators())
+    {
+      CellId id        = cell->id();
+      auto   cell_base = id.to_cell(tria_pdt);
+      for (unsigned int d = 0; d < dim; d++)
+        Assert(std::abs(cell->center()[d] - cell_base->center()[d]) < 1e-9,
+               ExcMessage("Cells do not match"));
+    }
+}
+
+int
+main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  mpi_initlog();
+
+  const int      dim  = 2;
+  const MPI_Comm comm = MPI_COMM_WORLD;
+
+  {
+    deallog.push("2d");
+    const int n_refinements  = 3;
+    const int n_subdivisions = 5;
+    test<2>(n_refinements, n_subdivisions, comm);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d");
+    const int n_refinements  = 3;
+    const int n_subdivisions = 4;
+    test<3>(n_refinements, n_subdivisions, comm);
+    deallog.pop();
+  }
+}
diff --git a/tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=1.output b/tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=1.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=5.output b/tests/fullydistributed_grids/copy_distributed_tria_03.with_p4est=true.mpirun=5.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/fullydistributed_grids/copy_serial_tria_08.cc b/tests/fullydistributed_grids/copy_serial_tria_08.cc
new file mode 100644 (file)
index 0000000..ffa7614
--- /dev/null
@@ -0,0 +1,94 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 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 serial triangulation with multigrid level, copy it, and
+// show that the CellIds have not changed.
+
+#include <deal.II/base/mpi.h>
+
+#include <deal.II/distributed/fully_distributed_tria.h>
+#include <deal.II/distributed/fully_distributed_tria_util.h>
+#include <deal.II/distributed/shared_tria.h>
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria.h>
+
+#include "./tests.h"
+
+using namespace dealii;
+
+template <int dim>
+void
+test(int n_refinements, MPI_Comm comm)
+{
+  // create serial triangulation
+  Triangulation<dim> basetria(
+    Triangulation<dim>::limit_level_difference_at_vertices);
+  GridGenerator::hyper_L(basetria);
+  basetria.refine_global(n_refinements);
+
+  GridTools::partition_triangulation_zorder(
+    Utilities::MPI::n_mpi_processes(comm), basetria);
+  GridTools::partition_multigrid_levels(basetria);
+
+  // create instance of pft
+  parallel::fullydistributed::Triangulation<dim> tria_pft(comm);
+
+  // extract relevant information form serial triangulation
+  auto construction_data = parallel::fullydistributed::Utilities::
+    create_construction_data_from_triangulation(basetria, comm, true);
+
+  // actually create triangulation
+  tria_pft.create_triangulation(construction_data);
+
+
+  for (auto &cell : tria_pft.active_cell_iterators())
+    {
+      CellId id        = cell->id();
+      auto   cell_base = id.to_cell(basetria);
+      // Assert(cell->center() == cell_base->center(),
+      //       ExcMessage("Cells do not match"));
+      for (unsigned int d = 0; d < dim; d++)
+        Assert(std::abs(cell->center()[d] - cell_base->center()[d]) < 1e-9,
+               ExcMessage("Cells do not match"));
+    }
+}
+
+int
+main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  mpi_initlog();
+
+  const int      n_refinements = 3;
+  const MPI_Comm comm          = MPI_COMM_WORLD;
+
+  {
+    deallog.push("2d");
+    test<2>(n_refinements, comm);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d");
+    test<3>(n_refinements, comm);
+    deallog.pop();
+  }
+}
diff --git a/tests/fullydistributed_grids/copy_serial_tria_08.mpirun=1.output b/tests/fullydistributed_grids/copy_serial_tria_08.mpirun=1.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/fullydistributed_grids/copy_serial_tria_08.mpirun=5.output b/tests/fullydistributed_grids/copy_serial_tria_08.mpirun=5.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

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.