]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add tests 12010/head
authorTimo Heister <timo.heister@gmail.com>
Sun, 4 Apr 2021 15:20:20 +0000 (11:20 -0400)
committerTimo Heister <timo.heister@gmail.com>
Mon, 5 Apr 2021 14:50:40 +0000 (10:50 -0400)
tests/distributed_grids/refine_periodic_01.cc [new file with mode: 0644]
tests/distributed_grids/refine_periodic_01.mpirun=1.with_p4est=true.debug.output [new file with mode: 0644]
tests/distributed_grids/refine_periodic_01.mpirun=3.with_p4est=true.debug.output [new file with mode: 0644]
tests/distributed_grids/refine_periodic_02.cc [new file with mode: 0644]
tests/distributed_grids/refine_periodic_02.mpirun=1.with_p4est=true.debug.output [new file with mode: 0644]

diff --git a/tests/distributed_grids/refine_periodic_01.cc b/tests/distributed_grids/refine_periodic_01.cc
new file mode 100644 (file)
index 0000000..4149d48
--- /dev/null
@@ -0,0 +1,83 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Test adaptive refinement with periodic boundary conditions and
+// mesh_reconstruction_after_repartitioning
+
+#include <deal.II/base/tensor.h>
+
+#include <deal.II/distributed/tria.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 <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include "../tests.h"
+
+template <int dim>
+void
+test()
+{
+  parallel::distributed::Triangulation<dim> tr(
+    MPI_COMM_WORLD,
+    dealii::Triangulation<dim>::none,
+    typename parallel::distributed::Triangulation<dim>::Settings(
+      parallel::distributed::Triangulation<
+        dim>::mesh_reconstruction_after_repartitioning |
+      parallel::distributed::Triangulation<
+        dim>::construct_multigrid_hierarchy));
+
+  GridGenerator::subdivided_hyper_cube(tr, 4, -1.0, 3.0, true);
+
+  // make x periodic
+  std::vector<
+    GridTools::PeriodicFacePair<typename Triangulation<dim>::cell_iterator>>
+    periodic_faces;
+  GridTools::collect_periodic_faces(tr, 0, 1, 0, periodic_faces);
+
+  tr.add_periodicity(periodic_faces);
+
+  for (unsigned int i = 0; i < 6; ++i)
+    {
+      deallog << "Checksum: " << tr.get_checksum() << '\n'
+              << "n_active_cells: " << tr.n_active_cells() << '\n'
+              << "n_levels: " << tr.n_levels() << std::endl;
+
+      Point<dim> p(-0.25, 0);
+
+      for (auto &cell : tr.active_cell_iterators())
+        {
+          if (p.distance(cell->center()) < 0.75)
+            cell->set_refine_flag();
+        }
+
+      tr.execute_coarsening_and_refinement();
+    }
+  tr.write_mesh_vtk("mesh");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  mpi_initlog();
+
+  test<2>();
+}
diff --git a/tests/distributed_grids/refine_periodic_01.mpirun=1.with_p4est=true.debug.output b/tests/distributed_grids/refine_periodic_01.mpirun=1.with_p4est=true.debug.output
new file mode 100644 (file)
index 0000000..3d70316
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::Checksum: 12582913
+n_active_cells: 16
+n_levels: 1
+DEAL::Checksum: 3564110089
+n_active_cells: 22
+n_levels: 2
+DEAL::Checksum: 3225224629
+n_active_cells: 46
+n_levels: 3
+DEAL::Checksum: 695868085
+n_active_cells: 139
+n_levels: 4
+DEAL::Checksum: 3093126693
+n_active_cells: 406
+n_levels: 5
+DEAL::Checksum: 2259900735
+n_active_cells: 1357
+n_levels: 6
diff --git a/tests/distributed_grids/refine_periodic_01.mpirun=3.with_p4est=true.debug.output b/tests/distributed_grids/refine_periodic_01.mpirun=3.with_p4est=true.debug.output
new file mode 100644 (file)
index 0000000..72bdd18
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::Checksum: 12582913
+n_active_cells: 16
+n_levels: 1
+DEAL::Checksum: 3564110089
+n_active_cells: 22
+n_levels: 2
+DEAL::Checksum: 3225224629
+n_active_cells: 46
+n_levels: 3
+DEAL::Checksum: 695868085
+n_active_cells: 106
+n_levels: 4
+DEAL::Checksum: 3093126693
+n_active_cells: 250
+n_levels: 5
+DEAL::Checksum: 2259900735
+n_active_cells: 661
+n_levels: 6
diff --git a/tests/distributed_grids/refine_periodic_02.cc b/tests/distributed_grids/refine_periodic_02.cc
new file mode 100644 (file)
index 0000000..f342eea
--- /dev/null
@@ -0,0 +1,221 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Test adaptive refinement with periodic boundary conditions and
+// mesh_reconstruction_after_repartitioning. This is extracted from a periodic
+// box example in ASPECT and triggers an assert with a difference between cell
+// levels of 2 in update_periodic_face_map_recursively() while doing
+// mesh_reconstruction_after_repartitioning when not performing the parallel
+// version of prepare_coarsening_and_refinement.
+
+#include <deal.II/base/tensor.h>
+
+#include <deal.II/distributed/tria.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 <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include "../tests.h"
+
+static std::vector<std::string> refined = {
+  "0_0:",       "0_1:0",      "0_1:1",      "0_1:2",      "0_1:3",
+  "0_2:00",     "0_2:01",     "0_2:02",     "0_2:03",     "0_2:10",
+  "0_2:11",     "0_2:12",     "0_2:13",     "0_2:20",     "0_2:21",
+  "0_2:22",     "0_2:23",     "0_2:30",     "0_2:31",     "0_2:32",
+  "0_2:33",     "0_3:000",    "0_3:001",    "0_3:002",    "0_3:003",
+  "0_3:010",    "0_3:011",    "0_3:012",    "0_3:013",    "0_3:020",
+  "0_3:021",    "0_3:022",    "0_3:023",    "0_3:030",    "0_3:031",
+  "0_3:032",    "0_3:033",    "0_3:100",    "0_3:101",    "0_3:102",
+  "0_3:103",    "0_3:110",    "0_3:111",    "0_3:112",    "0_3:113",
+  "0_3:120",    "0_3:121",    "0_3:122",    "0_3:123",    "0_3:130",
+  "0_3:131",    "0_3:132",    "0_3:133",    "0_3:200",    "0_3:201",
+  "0_3:202",    "0_3:203",    "0_3:210",    "0_3:211",    "0_3:212",
+  "0_3:213",    "0_3:220",    "0_3:221",    "0_3:222",    "0_3:223",
+  "0_3:230",    "0_3:231",    "0_3:232",    "0_3:233",    "0_3:300",
+  "0_3:301",    "0_3:302",    "0_3:303",    "0_3:310",    "0_3:311",
+  "0_3:312",    "0_3:313",    "0_3:320",    "0_3:321",    "0_3:322",
+  "0_3:323",    "0_3:330",    "0_3:331",    "0_3:332",    "0_3:333",
+  "0_4:0000",   "0_4:0001",   "0_4:0002",   "0_4:0003",   "0_4:0010",
+  "0_4:0011",   "0_4:0012",   "0_4:0013",   "0_4:0020",   "0_4:0021",
+  "0_4:0022",   "0_4:0023",   "0_4:0030",   "0_4:0031",   "0_4:0032",
+  "0_4:0033",   "0_4:0100",   "0_4:0101",   "0_4:0102",   "0_4:0103",
+  "0_4:0110",   "0_4:0111",   "0_4:0112",   "0_4:0113",   "0_4:0120",
+  "0_4:0121",   "0_4:0122",   "0_4:0123",   "0_4:0130",   "0_4:0131",
+  "0_4:0132",   "0_4:0133",   "0_4:0200",   "0_4:0201",   "0_4:0202",
+  "0_4:0203",   "0_4:0210",   "0_4:0211",   "0_4:0212",   "0_4:0213",
+  "0_4:0220",   "0_4:0221",   "0_4:0222",   "0_4:0223",   "0_4:0230",
+  "0_4:0231",   "0_4:0232",   "0_4:0233",   "0_4:0300",   "0_4:0301",
+  "0_4:0302",   "0_4:0303",   "0_4:0310",   "0_4:0311",   "0_4:0312",
+  "0_4:0313",   "0_4:0320",   "0_4:0321",   "0_4:0322",   "0_4:0323",
+  "0_4:0330",   "0_4:0331",   "0_4:0332",   "0_4:0333",   "0_4:1000",
+  "0_4:1001",   "0_4:1002",   "0_4:1003",   "0_4:1010",   "0_4:1011",
+  "0_4:1012",   "0_4:1013",   "0_4:1020",   "0_4:1021",   "0_4:1022",
+  "0_4:1023",   "0_4:1030",   "0_4:1031",   "0_4:1032",   "0_4:1033",
+  "0_4:1100",   "0_4:1101",   "0_4:1102",   "0_4:1103",   "0_4:1110",
+  "0_4:1111",   "0_4:1112",   "0_4:1113",   "0_4:1120",   "0_4:1121",
+  "0_4:1122",   "0_4:1123",   "0_4:1130",   "0_4:1131",   "0_4:1132",
+  "0_4:1133",   "0_4:1200",   "0_4:1201",   "0_4:1202",   "0_4:1203",
+  "0_4:1210",   "0_4:1211",   "0_4:1212",   "0_4:1213",   "0_4:1220",
+  "0_4:1221",   "0_4:1222",   "0_4:1223",   "0_4:1230",   "0_4:1231",
+  "0_4:1232",   "0_4:1233",   "0_4:1300",   "0_4:1301",   "0_4:1302",
+  "0_4:1303",   "0_4:1310",   "0_4:1311",   "0_4:1312",   "0_4:1313",
+  "0_4:1320",   "0_4:1321",   "0_4:1322",   "0_4:1323",   "0_4:1330",
+  "0_4:1331",   "0_4:1332",   "0_4:1333",   "0_4:2000",   "0_4:2001",
+  "0_4:2002",   "0_4:2003",   "0_4:2010",   "0_4:2011",   "0_4:2012",
+  "0_4:2013",   "0_4:2020",   "0_4:2021",   "0_4:2022",   "0_4:2023",
+  "0_4:2030",   "0_4:2031",   "0_4:2032",   "0_4:2033",   "0_4:2100",
+  "0_4:2101",   "0_4:2102",   "0_4:2103",   "0_4:2110",   "0_4:2111",
+  "0_4:2112",   "0_4:2113",   "0_4:2120",   "0_4:2121",   "0_4:2122",
+  "0_4:2123",   "0_4:2130",   "0_4:2131",   "0_4:2132",   "0_4:2133",
+  "0_4:2200",   "0_4:2201",   "0_4:2202",   "0_4:2203",   "0_4:2210",
+  "0_4:2211",   "0_4:2212",   "0_4:2213",   "0_4:2220",   "0_4:2221",
+  "0_4:2222",   "0_4:2223",   "0_4:2230",   "0_4:2231",   "0_4:2232",
+  "0_4:2233",   "0_4:2300",   "0_4:2301",   "0_4:2302",   "0_4:2303",
+  "0_4:2310",   "0_4:2311",   "0_4:2312",   "0_4:2313",   "0_4:2320",
+  "0_4:2321",   "0_4:2322",   "0_4:2323",   "0_4:2330",   "0_4:2331",
+  "0_4:2332",   "0_4:2333",   "0_4:3000",   "0_4:3001",   "0_4:3002",
+  "0_4:3003",   "0_4:3010",   "0_4:3011",   "0_4:3012",   "0_4:3013",
+  "0_4:3020",   "0_4:3021",   "0_4:3022",   "0_4:3023",   "0_4:3030",
+  "0_4:3031",   "0_4:3032",   "0_4:3033",   "0_4:3100",   "0_4:3101",
+  "0_4:3102",   "0_4:3103",   "0_4:3110",   "0_4:3111",   "0_4:3112",
+  "0_4:3113",   "0_4:3120",   "0_4:3121",   "0_4:3122",   "0_4:3123",
+  "0_4:3130",   "0_4:3131",   "0_4:3132",   "0_4:3133",   "0_4:3200",
+  "0_4:3201",   "0_4:3202",   "0_4:3203",   "0_4:3210",   "0_4:3211",
+  "0_4:3212",   "0_4:3213",   "0_4:3220",   "0_4:3221",   "0_4:3222",
+  "0_4:3223",   "0_4:3230",   "0_4:3231",   "0_4:3232",   "0_4:3233",
+  "0_4:3300",   "0_4:3301",   "0_4:3302",   "0_4:3303",   "0_4:3310",
+  "0_4:3311",   "0_4:3312",   "0_4:3313",   "0_4:3320",   "0_4:3321",
+  "0_4:3322",   "0_4:3323",   "0_4:3330",   "0_4:3331",   "0_4:3332",
+  "0_4:3333",   "0_5:00333",  "0_5:01202",  "0_5:01203",  "0_5:01212",
+  "0_5:01220",  "0_5:01221",  "0_5:01222",  "0_5:01230",  "0_5:01232",
+  "0_5:01233",  "0_5:02110",  "0_5:02111",  "0_5:02112",  "0_5:02113",
+  "0_5:02130",  "0_5:02132",  "0_5:02310",  "0_5:02312",  "0_5:02330",
+  "0_5:02332",  "0_5:03011",  "0_5:03100",  "0_5:03102",  "0_5:03120",
+  "0_5:03122",  "0_5:03320",  "0_5:03322",  "0_5:20111",  "0_5:20113",
+  "0_5:20131",  "0_5:20133",  "0_5:20212",  "0_5:20213",  "0_5:20230",
+  "0_5:20231",  "0_5:20232",  "0_5:20320",  "0_5:20322",  "0_5:21011",
+  "0_5:21013",  "0_5:21020",  "0_5:21021",  "0_5:21022",  "0_5:21023",
+  "0_5:21030",  "0_5:21031",  "0_5:21032",  "0_5:21100",  "0_5:21102",
+  "0_5:22032",  "0_5:22100",  "0_5:22102",  "0_5:22103",  "0_5:22120",
+  "0_5:22121",  "0_5:22122",  "0_5:22210",  "0_5:22211",  "0_5:22212",
+  "0_5:22213",  "0_5:22300",  "0_6:012201", "0_6:012300", "0_6:021112",
+  "0_6:202301", "0_6:210131", "0_6:210202", "0_6:211002", "0_6:221201",
+  "0_6:222103"};
+static std::vector<std::string> marked_coarsen = {
+  "0_6:003330",  "0_6:003332",  "0_6:012020",  "0_6:012021",  "0_6:012022",
+  "0_6:012023",  "0_6:012030",  "0_6:012031",  "0_6:012032",  "0_6:012033",
+  "0_6:012120",  "0_6:012121",  "0_6:012122",  "0_6:012123",  "0_6:012200",
+  "0_6:012301",  "0_6:012331",  "0_6:021100",  "0_6:021101",  "0_6:021102",
+  "0_6:021103",  "0_6:021120",  "0_6:021122",  "0_6:021133",  "0_6:031000",
+  "0_6:031001",  "0_6:031003",  "0_6:031021",  "0_6:201111",  "0_6:201113",
+  "0_6:201131",  "0_6:201330",  "0_6:201332",  "0_6:202120",  "0_6:202121",
+  "0_6:202122",  "0_6:202123",  "0_6:202130",  "0_6:202131",  "0_6:202132",
+  "0_6:202133",  "0_6:202323",  "0_6:203200",  "0_6:203201",  "0_6:203203",
+  "0_6:210110",  "0_6:210111",  "0_6:210112",  "0_6:210113",  "0_6:210130",
+  "0_6:210132",  "0_6:210200",  "0_6:210201",  "0_6:210210",  "0_6:210211",
+  "0_6:210212",  "0_6:210213",  "0_6:210300",  "0_6:210301",  "0_6:211023",
+  "0_6:220321",  "0_6:220323",  "0_6:221031",  "0_6:221033",  "0_6:221210",
+  "0_6:221211",  "0_6:221212",  "0_6:221213",  "0_6:222122",  "0_6:222133",
+  "0_6:223003",  "0_7:0122010", "0_7:0122011", "0_7:0122012", "0_7:0122013",
+  "0_7:0123000", "0_7:0123001", "0_7:0123002", "0_7:0123003", "0_7:2023010",
+  "0_7:2101310", "0_7:2101312", "0_7:2102021"};
+static std::vector<std::string> marked_refine = {
+  "0_5:01223",  "0_5:03013",  "0_5:03300",  "0_5:03302",  "0_5:20110",
+  "0_5:20112",  "0_5:20223",  "0_5:20233",  "0_5:21033",  "0_5:21201",
+  "0_5:22023",  "0_6:012220", "0_6:012221", "0_6:012320", "0_6:012321",
+  "0_6:012332", "0_6:021111", "0_6:021130", "0_6:201132", "0_6:201313",
+  "0_6:202303", "0_6:202312", "0_6:202320", "0_6:203222", "0_6:210220",
+  "0_6:210232", "0_6:210233", "0_6:210311", "0_6:210321", "0_6:210322",
+  "0_6:210323", "0_6:211020", "0_6:221203", "0_6:222100", "0_6:222102",
+  "0_6:222112", "0_6:222113", "0_6:222121", "0_6:223000"};
+
+
+
+template <int dim>
+void
+test()
+{
+  parallel::distributed::Triangulation<dim> tr(
+    MPI_COMM_WORLD,
+    dealii::Triangulation<dim>::none,
+    typename parallel::distributed::Triangulation<dim>::Settings(
+      parallel::distributed::Triangulation<
+        dim>::mesh_reconstruction_after_repartitioning |
+      parallel::distributed::Triangulation<
+        dim>::construct_multigrid_hierarchy));
+
+  GridGenerator::hyper_cube(tr, 0., 1., true);
+
+  // make x periodic
+  std::vector<
+    GridTools::PeriodicFacePair<typename Triangulation<dim>::cell_iterator>>
+    periodic_faces;
+  GridTools::collect_periodic_faces(tr, 0, 1, 0, periodic_faces);
+
+  tr.add_periodicity(periodic_faces);
+
+  while (true)
+    {
+      bool changes = false;
+
+      for (const auto &cell : tr.active_cell_iterators())
+        if (std::find(std::begin(refined),
+                      std::end(refined),
+                      cell->id().to_string()) != std::end(refined))
+          {
+            cell->set_refine_flag();
+            changes = true;
+          }
+
+      if (!changes)
+        break;
+      tr.execute_coarsening_and_refinement();
+    }
+
+  deallog << "Checksum: " << tr.get_checksum() << '\n'
+          << "n_active_cells: " << tr.n_active_cells() << '\n'
+          << "n_levels: " << tr.n_levels() << std::endl;
+
+  for (const auto &id : marked_coarsen)
+    CellId(id).to_cell(tr)->set_coarsen_flag();
+
+  for (const auto &id : marked_refine)
+    CellId(id).to_cell(tr)->set_refine_flag();
+
+  deallog << "execute_coarsening_and_refinement()..." << std::endl;
+
+  tr.execute_coarsening_and_refinement();
+
+  deallog << "Checksum: " << tr.get_checksum() << '\n'
+          << "n_active_cells: " << tr.n_active_cells() << '\n'
+          << "n_levels: " << tr.n_levels() << std::endl;
+
+  tr.write_mesh_vtk("mesh");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  mpi_initlog();
+
+  test<2>();
+}
diff --git a/tests/distributed_grids/refine_periodic_02.mpirun=1.with_p4est=true.debug.output b/tests/distributed_grids/refine_periodic_02.mpirun=1.with_p4est=true.debug.output
new file mode 100644 (file)
index 0000000..3c2ef90
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL::Checksum: 3787082418
+n_active_cells: 1234
+n_levels: 8
+DEAL::execute_coarsening_and_refinement()...
+DEAL::Checksum: 1951244648
+n_active_cells: 1381
+n_levels: 8

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.