]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use `TestGrids::hyper_line` to avoid code duplication.
authorMarc Fehling <marc.fehling@gmx.net>
Fri, 27 Aug 2021 21:02:08 +0000 (15:02 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Sat, 28 Aug 2021 01:17:11 +0000 (19:17 -0600)
tests/mpi/hp_unify_dof_indices_01.cc
tests/mpi/hp_unify_dof_indices_07.cc
tests/mpi/hp_unify_dof_indices_11.cc
tests/test_grids.h

index 004545ff5c00570fa8e2f0dd34f2fd3611da5749..60a0c6ab808d7fadff69dee7207268ea100dac2d 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "../tests.h"
 
+#include "../test_grids.h"
 #include "hp_unify_dof_indices.h"
 
 
@@ -50,17 +51,7 @@ test()
 {
   parallel::distributed::Triangulation<dim> triangulation(
     MPI_COMM_WORLD, Triangulation<dim>::limit_level_difference_at_vertices);
-
-  std::vector<unsigned int> reps(dim, 1U);
-  reps[0] = 2;
-  Point<dim> top_right;
-  for (unsigned int d = 0; d < dim; ++d)
-    top_right[d] = (d == 0 ? 2 : 1);
-  GridGenerator::subdivided_hyper_rectangle(triangulation,
-                                            reps,
-                                            Point<dim>(),
-                                            top_right);
-  Assert(triangulation.n_global_active_cells() == 2, ExcInternalError());
+  TestGrids::hyper_line(triangulation, 2);
   Assert(triangulation.n_active_cells() == 2, ExcInternalError());
 
   hp::FECollection<dim> fe;
index eff1c01b856161df0ebba798e2033431dd9bbd24..febfc6c9fff1fcc7a86d609585df7923996a5d27 100644 (file)
@@ -50,6 +50,8 @@
 
 #include "../tests.h"
 
+#include "../test_grids.h"
+
 
 template <int dim>
 void
@@ -57,17 +59,7 @@ test()
 {
   parallel::distributed::Triangulation<dim> triangulation(
     MPI_COMM_WORLD, Triangulation<dim>::limit_level_difference_at_vertices);
-
-  std::vector<unsigned int> reps(dim, 1U);
-  reps[0] = 2;
-  Point<dim> top_right;
-  for (unsigned int d = 0; d < dim; ++d)
-    top_right[d] = (d == 0 ? 2 : 1);
-  GridGenerator::subdivided_hyper_rectangle(triangulation,
-                                            reps,
-                                            Point<dim>(),
-                                            top_right);
-  Assert(triangulation.n_global_active_cells() == 2, ExcInternalError());
+  TestGrids::hyper_line(triangulation, 2);
   Assert(triangulation.n_active_cells() == 2, ExcInternalError());
 
   hp::FECollection<dim> fe(FE_Q<dim>(2), FE_Q<dim>(2));
index ba4c6828fc9d5e475c134860d4509e6689d22294..56067b74515832ee580a0940db73cd459d691623 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "../tests.h"
 
+#include "../test_grids.h"
 #include "hp_unify_dof_indices.h"
 
 
@@ -45,17 +46,7 @@ test()
 {
   parallel::distributed::Triangulation<dim> triangulation(
     MPI_COMM_WORLD, Triangulation<dim>::limit_level_difference_at_vertices);
-
-  std::vector<unsigned int> reps(dim, 1U);
-  reps[0] = 2;
-  Point<dim> top_right;
-  for (unsigned int d = 0; d < dim; ++d)
-    top_right[d] = (d == 0 ? 2 : 1);
-  GridGenerator::subdivided_hyper_rectangle(triangulation,
-                                            reps,
-                                            Point<dim>(),
-                                            top_right);
-  Assert(triangulation.n_global_active_cells() == 2, ExcInternalError());
+  TestGrids::hyper_line(triangulation, 2);
   Assert(triangulation.n_active_cells() == 2, ExcInternalError());
 
   hp::FECollection<dim> fe;
index d47a081439fae37877c48136f0fc9669b874ae1b..24e8d09872e96edafb398b8cb6f4e09f01497d54 100644 (file)
@@ -144,7 +144,7 @@ namespace TestGrids
    */
   template <int dim, int spacedim>
   void
-  hyper_line(Triangulation<dim, spacedim> &tr, const int n_cells)
+  hyper_line(Triangulation<dim, spacedim> &tr, const unsigned int n_cells)
   {
     std::vector<unsigned int> repetitions(dim, 1);
     repetitions[0] = n_cells;
@@ -155,5 +155,6 @@ namespace TestGrids
         p2[d] = (d == 0) ? n_cells : 1;
       }
     GridGenerator::subdivided_hyper_rectangle(tr, repetitions, p1, p2);
+    Assert(tr.n_global_active_cells() == n_cells, ExcInternalError());
   }
 } // namespace TestGrids

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.