From d7606172dcaf191f32f6d150b2d052e9bb1e5a44 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 30 Mar 2020 12:29:40 -0400 Subject: [PATCH] Update tests --- tests/mpi/multigrid_adaptive.cc | 36 ++++++ tests/mpi/multigrid_uniform.cc | 36 ++++++ tests/multigrid/cycles.cc | 198 ++++++++++++++++++++++++++++-- tests/multigrid/cycles.output | 210 ++++++++++++++++---------------- 4 files changed, 367 insertions(+), 113 deletions(-) diff --git a/tests/mpi/multigrid_adaptive.cc b/tests/mpi/multigrid_adaptive.cc index 264d6f54bd..c59943bd3d 100644 --- a/tests/mpi/multigrid_adaptive.cc +++ b/tests/mpi/multigrid_adaptive.cc @@ -420,6 +420,37 @@ namespace Step50 mg::Matrix mg_interface_up(mg_interface_matrices); mg::Matrix mg_interface_down(mg_interface_matrices); + auto print_coarse_solve = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "Coarse level " << level << std::endl; + } + }; + + auto print_restriction = [](const bool start, const unsigned int level) { + if (start) + deallog << "Residual on level " << level << std::endl; + }; + + auto print_pre_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "Smoothing on level " << level << std::endl; + } + }; + + auto print_post_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "Smoothing on level " << level << std::endl; + deallog << "V-cycle leaving level " << level << std::endl; + } + }; + // Now, we are ready to set up the // V-cycle operator and the // multilevel preconditioner. @@ -427,6 +458,11 @@ namespace Step50 mg_matrix, coarse_grid_solver, mg_transfer, mg_smoother, mg_smoother); mg.set_edge_matrices(mg_interface_down, mg_interface_up); + mg.connect_coarse_solve(print_coarse_solve); + mg.connect_restriction(print_restriction); + mg.connect_pre_smoother_step(print_pre_smoother_step); + mg.connect_post_smoother_step(print_post_smoother_step); + PreconditionMG> preconditioner( mg_dof_handler, mg, mg_transfer); diff --git a/tests/mpi/multigrid_uniform.cc b/tests/mpi/multigrid_uniform.cc index 5b871d5718..27d5897ec7 100644 --- a/tests/mpi/multigrid_uniform.cc +++ b/tests/mpi/multigrid_uniform.cc @@ -407,6 +407,37 @@ namespace Step50 mg::Matrix mg_interface_up(mg_interface_matrices); mg::Matrix mg_interface_down(mg_interface_matrices); + auto print_coarse_solve = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "Coarse level " << level << std::endl; + } + }; + + auto print_restriction = [](const bool start, const unsigned int level) { + if (start) + deallog << "Residual on level " << level << std::endl; + }; + + auto print_pre_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "Smoothing on level " << level << std::endl; + } + }; + + auto print_post_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "Smoothing on level " << level << std::endl; + deallog << "V-cycle leaving level " << level << std::endl; + } + }; + // Now, we are ready to set up the // V-cycle operator and the // multilevel preconditioner. @@ -414,6 +445,11 @@ namespace Step50 mg_matrix, coarse_grid_solver, mg_transfer, mg_smoother, mg_smoother); mg.set_edge_matrices(mg_interface_down, mg_interface_up); + mg.connect_coarse_solve(print_coarse_solve); + mg.connect_restriction(print_restriction); + mg.connect_pre_smoother_step(print_pre_smoother_step); + mg.connect_post_smoother_step(print_post_smoother_step); + PreconditionMG> preconditioner( mg_dof_handler, mg, mg_transfer); diff --git a/tests/multigrid/cycles.cc b/tests/multigrid/cycles.cc index 54ea6772be..75ae2a1d37 100644 --- a/tests/multigrid/cycles.cc +++ b/tests/multigrid/cycles.cc @@ -81,18 +81,200 @@ test_cycles(unsigned int minlevel, unsigned int maxlevel) minlevel, maxlevel, Multigrid::v_cycle); - mg1.set_debug(3); + for (unsigned int i = minlevel; i <= maxlevel; ++i) mg1.defect[i].reinit(N); - mg1.cycle(); - deallog << std::endl; - mg1.set_cycle(Multigrid::w_cycle); - mg1.cycle(); - deallog << std::endl; + { + auto print_coarse_solve = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "V-cycle Defect norm 0" << std::endl; + deallog << "Coarse level " << level << std::endl; + } + }; + + auto print_restriction = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "Residual on level " << level << std::endl; + deallog << "Residual norm 0" << std::endl; + } + }; + + auto print_prolongation = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "Prolongate norm 0" << std::endl; + deallog << "V-cycle Defect norm 0" << std::endl; + } + }; + + auto print_pre_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "V-cycle entering level " << level << std::endl; + deallog << "V-cycle Defect norm 0" << std::endl; + deallog << "Smoothing on level " << level << std::endl; + deallog << "Solution norm 0" << std::endl; + } + }; + + auto print_post_smoother_step = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "Smoothing on level " << level << std::endl; + deallog << "Solution norm 0" << std::endl; + deallog << "V-cycle leaving level " << level << std::endl; + } + }; + + const auto coarse_connection = mg1.connect_coarse_solve(print_coarse_solve); + const auto restriction_connection = + mg1.connect_restriction(print_restriction); + const auto prolongation_connection = + mg1.connect_prolongation(print_prolongation); + const auto pre_smoother_connection = + mg1.connect_pre_smoother_step(print_pre_smoother_step); + const auto post_smoother_connection = + mg1.connect_post_smoother_step(print_post_smoother_step); + + mg1.cycle(); + deallog << std::endl; + + coarse_connection.disconnect(); + restriction_connection.disconnect(); + prolongation_connection.disconnect(); + pre_smoother_connection.disconnect(); + post_smoother_connection.disconnect(); + } + + { + auto print_coarse_solve_w = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "W-cycle entering level " << level << std::endl; + deallog << "W-cycle defect norm 0" << std::endl; + deallog << "W-cycle coarse level " << level << std::endl; + } + }; + + auto print_restriction_w = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "W-cycle residual level " << level << std::endl; + deallog << "W-cycle residual norm 0" << std::endl; + } + }; + + auto print_prolongation_w = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "W-cycle Defect norm 0" << std::endl; + } + }; + + auto print_pre_smoother_step_w = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "W-cycle entering level " << level << std::endl; + deallog << "W-cycle defect norm 0" << std::endl; + deallog << "W-cycle smoothing level " << level << std::endl; + deallog << "W-cycle solution norm 0" << std::endl; + } + }; + + auto print_post_smoother_step_w = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "W-cycle smoothing level " << level << std::endl; + deallog << "W-cycle solution norm 0" << std::endl; + deallog << "W-cycle leaving level " << level << std::endl; + } + }; + + const auto coarse_connection = + mg1.connect_coarse_solve(print_coarse_solve_w); + const auto restriction_connection = + mg1.connect_restriction(print_restriction_w); + const auto prolongation_connection = + mg1.connect_prolongation(print_prolongation_w); + const auto pre_smoother_connection = + mg1.connect_pre_smoother_step(print_pre_smoother_step_w); + const auto post_smoother_connection = + mg1.connect_post_smoother_step(print_post_smoother_step_w); + + mg1.set_cycle(Multigrid::w_cycle); + mg1.cycle(); + deallog << std::endl; + + coarse_connection.disconnect(); + restriction_connection.disconnect(); + prolongation_connection.disconnect(); + pre_smoother_connection.disconnect(); + post_smoother_connection.disconnect(); + } + + { + auto print_coarse_solve_f = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "F-cycle entering level " << level << std::endl; + deallog << "F-cycle defect norm 0" << std::endl; + deallog << "F-cycle coarse level " << level << std::endl; + } + }; + + auto print_restriction_f = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "F-cycle residual level " << level << std::endl; + deallog << "F-cycle residual norm 0" << std::endl; + } + }; + + auto print_prolongation_f = [](const bool start, const unsigned int level) { + if (start) + { + deallog << "F-cycle Defect norm 0" << std::endl; + } + }; + + auto print_pre_smoother_step_f = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "F-cycle entering level " << level << std::endl; + deallog << "F-cycle defect norm 0" << std::endl; + deallog << "F-cycle smoothing level " << level << std::endl; + deallog << "F-cycle solution norm 0" << std::endl; + } + }; + + auto print_post_smoother_step_f = [](const bool start, + const unsigned int level) { + if (start) + { + deallog << "F-cycle smoothing level " << level << std::endl; + deallog << "F-cycle solution norm 0" << std::endl; + deallog << "F-cycle leaving level " << level << std::endl; + } + }; + + mg1.connect_coarse_solve(print_coarse_solve_f); + mg1.connect_restriction(print_restriction_f); + mg1.connect_prolongation(print_prolongation_f); + mg1.connect_pre_smoother_step(print_pre_smoother_step_f); + mg1.connect_post_smoother_step(print_post_smoother_step_f); - mg1.set_cycle(Multigrid::f_cycle); - mg1.cycle(); + mg1.set_cycle(Multigrid::f_cycle); + mg1.cycle(); + } } int diff --git a/tests/multigrid/cycles.output b/tests/multigrid/cycles.output index fa9dab6bb5..12b14e07bc 100644 --- a/tests/multigrid/cycles.output +++ b/tests/multigrid/cycles.output @@ -253,83 +253,83 @@ DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 1 DEAL::F-cycle solution norm 0 DEAL::F-cycle leaving level 1 -DEAL::V-cycle entering level 1 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 1 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 0 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle coarse level 0 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 1 +DEAL::F-cycle entering level 1 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 1 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 0 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle coarse level 0 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 1 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 2 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 2 +DEAL::F-cycle entering level 2 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 2 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 2 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 1 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 1 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 0 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle coarse level 0 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 1 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 2 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 2 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 3 +DEAL::F-cycle entering level 3 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 3 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 2 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 2 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 2 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 1 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 1 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 0 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle coarse level 0 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 1 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 1 DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 2 DEAL::F-cycle solution norm 0 DEAL::F-cycle leaving level 2 -DEAL::V-cycle entering level 2 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 2 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 2 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 1 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 1 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 0 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle coarse level 0 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 1 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 2 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 2 DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 3 DEAL::F-cycle solution norm 0 DEAL::F-cycle leaving level 3 -DEAL::V-cycle entering level 3 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 3 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 2 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 2 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 2 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 1 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 1 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 0 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle coarse level 0 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 1 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 1 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 2 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 2 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 3 DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 4 DEAL::F-cycle solution norm 0 @@ -479,46 +479,46 @@ DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 3 DEAL::F-cycle solution norm 0 DEAL::F-cycle leaving level 3 -DEAL::V-cycle entering level 3 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 3 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 2 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle coarse level 2 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 3 +DEAL::F-cycle entering level 3 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 3 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 2 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle coarse level 2 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 3 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 4 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 4 +DEAL::F-cycle entering level 4 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 4 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 4 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 3 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle residual level 3 +DEAL::F-cycle residual norm 0 +DEAL::F-cycle entering level 2 +DEAL::F-cycle defect norm 0 +DEAL::F-cycle coarse level 2 +DEAL::F-cycle Defect norm 0 +DEAL::F-cycle smoothing level 3 +DEAL::F-cycle solution norm 0 +DEAL::F-cycle leaving level 3 DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 4 DEAL::F-cycle solution norm 0 DEAL::F-cycle leaving level 4 -DEAL::V-cycle entering level 4 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 4 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 4 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 3 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle residual level 3 -DEAL::V-cycle residual norm 0 -DEAL::V-cycle entering level 2 -DEAL::V-cycle defect norm 0 -DEAL::V-cycle coarse level 2 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 3 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 3 -DEAL::V-cycle Defect norm 0 -DEAL::V-cycle smoothing level 4 -DEAL::V-cycle solution norm 0 -DEAL::V-cycle leaving level 4 DEAL::F-cycle Defect norm 0 DEAL::F-cycle smoothing level 5 DEAL::F-cycle solution norm 0 -- 2.39.5