From: Peter Munch Date: Sun, 14 Feb 2021 11:35:29 +0000 (+0100) Subject: Test p global coarsening for locally refined meshes X-Git-Tag: v9.3.0-rc1~448^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11745%2Fhead;p=dealii.git Test p global coarsening for locally refined meshes --- diff --git a/tests/multigrid-global-coarsening/multigrid_p_01.cc b/tests/multigrid-global-coarsening/multigrid_p_01.cc index 6f4227b04d..bcd3e39ba1 100644 --- a/tests/multigrid-global-coarsening/multigrid_p_01.cc +++ b/tests/multigrid-global-coarsening/multigrid_p_01.cc @@ -15,8 +15,8 @@ /** - * Test p-multigrid for a uniformly refined mesh both for simplex and - * hypercube mesh. + * Test p-multigrid for a uniformly and locally refined meshes both for + * simplex and hypercube mesh. */ #include "multigrid_util.h" @@ -25,7 +25,8 @@ template void test(const unsigned int n_refinements, const unsigned int fe_degree_fine, - const bool do_simplex_mesh) + const bool do_simplex_mesh, + const unsigned int mesh_type) { using VectorType = LinearAlgebra::distributed::Vector; @@ -34,7 +35,30 @@ test(const unsigned int n_refinements, GridGenerator::subdivided_hyper_cube_with_simplices(tria, 2); else GridGenerator::subdivided_hyper_cube(tria, 2); - tria.refine_global(n_refinements); + + if (mesh_type == 0) + { + tria.refine_global(n_refinements); + } + else if (mesh_type == 1) + { + for (unsigned int i = 1; i < n_refinements; i++) + { + for (auto cell : tria.active_cell_iterators()) + if (cell->is_locally_owned()) + { + bool flag = true; + for (int d = 0; d < dim; d++) + if (cell->center()[d] > 0.5) + flag = false; + if (flag) + cell->set_refine_flag(); + } + tria.execute_coarsening_and_refinement(); + } + } + else + AssertThrow(false, ExcNotImplemented()); const auto level_degrees = MGTransferGlobalCoarseningTools::create_polynomial_coarsening_sequence( @@ -90,6 +114,7 @@ test(const unsigned int n_refinements, constraint.reinit(locally_relevant_dofs); VectorTools::interpolate_boundary_values( *mapping, dof_handler, 0, Functions::ZeroFunction(), constraint); + DoFTools::make_hanging_node_constraints(dof_handler, constraint); constraint.close(); // set up operator @@ -127,6 +152,8 @@ test(const unsigned int n_refinements, operators, transfer); + constraints[max_level].distribute(dst); + deallog << dim << " " << fe_degree_fine << " " << n_refinements << " " << (do_simplex_mesh ? "tri " : "quad") << " " << solver_control.last_step() << std::endl; @@ -151,11 +178,14 @@ main(int argc, char **argv) deallog.precision(8); - for (unsigned int n_refinements = 2; n_refinements <= 4; ++n_refinements) - for (unsigned int degree = 2; degree <= 4; ++degree) - test<2>(n_refinements, degree, false /*quadrilateral*/); + for (unsigned int mesh_type = 0; mesh_type < 2; ++mesh_type) + { + for (unsigned int n_refinements = 2; n_refinements <= 4; ++n_refinements) + for (unsigned int degree = 2; degree <= 4; ++degree) + test<2>(n_refinements, degree, false /*quadrilateral*/, mesh_type); - for (unsigned int n_refinements = 2; n_refinements <= 4; ++n_refinements) - for (unsigned int degree = 2; degree <= 2; ++degree) - test<2>(n_refinements, degree, true /*triangle*/); + for (unsigned int n_refinements = 2; n_refinements <= 4; ++n_refinements) + for (unsigned int degree = 2; degree <= 2; ++degree) + test<2>(n_refinements, degree, true /*triangle*/, mesh_type); + } } diff --git a/tests/multigrid-global-coarsening/multigrid_p_01.mpirun=1.with_trilinos=true.with_simplex_support=on.output b/tests/multigrid-global-coarsening/multigrid_p_01.mpirun=1.with_trilinos=true.with_simplex_support=on.output index 2dd1841f72..b8fc47e0d2 100644 --- a/tests/multigrid-global-coarsening/multigrid_p_01.mpirun=1.with_trilinos=true.with_simplex_support=on.output +++ b/tests/multigrid-global-coarsening/multigrid_p_01.mpirun=1.with_trilinos=true.with_simplex_support=on.output @@ -11,3 +11,15 @@ DEAL:0::2 4 4 quad 3 DEAL:0::2 2 2 tri 3 DEAL:0::2 2 3 tri 3 DEAL:0::2 2 4 tri 3 +DEAL:0::2 2 2 quad 2 +DEAL:0::2 3 2 quad 3 +DEAL:0::2 4 2 quad 3 +DEAL:0::2 2 3 quad 3 +DEAL:0::2 3 3 quad 3 +DEAL:0::2 4 3 quad 3 +DEAL:0::2 2 4 quad 3 +DEAL:0::2 3 4 quad 3 +DEAL:0::2 4 4 quad 3 +DEAL:0::2 2 2 tri 3 +DEAL:0::2 2 3 tri 3 +DEAL:0::2 2 4 tri 4