From: Marc Fehling Date: Fri, 27 Aug 2021 21:02:08 +0000 (-0600) Subject: Use `TestGrids::hyper_line` to avoid code duplication. X-Git-Tag: v9.4.0-rc1~1026^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f9ebdcb4cc5c2b1b2e06f0897df3a6124d50286;p=dealii.git Use `TestGrids::hyper_line` to avoid code duplication. --- diff --git a/tests/mpi/hp_unify_dof_indices_01.cc b/tests/mpi/hp_unify_dof_indices_01.cc index 004545ff5c..60a0c6ab80 100644 --- a/tests/mpi/hp_unify_dof_indices_01.cc +++ b/tests/mpi/hp_unify_dof_indices_01.cc @@ -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 triangulation( MPI_COMM_WORLD, Triangulation::limit_level_difference_at_vertices); - - std::vector reps(dim, 1U); - reps[0] = 2; - Point top_right; - for (unsigned int d = 0; d < dim; ++d) - top_right[d] = (d == 0 ? 2 : 1); - GridGenerator::subdivided_hyper_rectangle(triangulation, - reps, - Point(), - top_right); - Assert(triangulation.n_global_active_cells() == 2, ExcInternalError()); + TestGrids::hyper_line(triangulation, 2); Assert(triangulation.n_active_cells() == 2, ExcInternalError()); hp::FECollection fe; diff --git a/tests/mpi/hp_unify_dof_indices_07.cc b/tests/mpi/hp_unify_dof_indices_07.cc index eff1c01b85..febfc6c9ff 100644 --- a/tests/mpi/hp_unify_dof_indices_07.cc +++ b/tests/mpi/hp_unify_dof_indices_07.cc @@ -50,6 +50,8 @@ #include "../tests.h" +#include "../test_grids.h" + template void @@ -57,17 +59,7 @@ test() { parallel::distributed::Triangulation triangulation( MPI_COMM_WORLD, Triangulation::limit_level_difference_at_vertices); - - std::vector reps(dim, 1U); - reps[0] = 2; - Point top_right; - for (unsigned int d = 0; d < dim; ++d) - top_right[d] = (d == 0 ? 2 : 1); - GridGenerator::subdivided_hyper_rectangle(triangulation, - reps, - Point(), - top_right); - Assert(triangulation.n_global_active_cells() == 2, ExcInternalError()); + TestGrids::hyper_line(triangulation, 2); Assert(triangulation.n_active_cells() == 2, ExcInternalError()); hp::FECollection fe(FE_Q(2), FE_Q(2)); diff --git a/tests/mpi/hp_unify_dof_indices_11.cc b/tests/mpi/hp_unify_dof_indices_11.cc index ba4c6828fc..56067b7451 100644 --- a/tests/mpi/hp_unify_dof_indices_11.cc +++ b/tests/mpi/hp_unify_dof_indices_11.cc @@ -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 triangulation( MPI_COMM_WORLD, Triangulation::limit_level_difference_at_vertices); - - std::vector reps(dim, 1U); - reps[0] = 2; - Point top_right; - for (unsigned int d = 0; d < dim; ++d) - top_right[d] = (d == 0 ? 2 : 1); - GridGenerator::subdivided_hyper_rectangle(triangulation, - reps, - Point(), - top_right); - Assert(triangulation.n_global_active_cells() == 2, ExcInternalError()); + TestGrids::hyper_line(triangulation, 2); Assert(triangulation.n_active_cells() == 2, ExcInternalError()); hp::FECollection fe; diff --git a/tests/test_grids.h b/tests/test_grids.h index d47a081439..24e8d09872 100644 --- a/tests/test_grids.h +++ b/tests/test_grids.h @@ -144,7 +144,7 @@ namespace TestGrids */ template void - hyper_line(Triangulation &tr, const int n_cells) + hyper_line(Triangulation &tr, const unsigned int n_cells) { std::vector 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