From a08b9529019ef000e3d79a9d5556946e06b5d5b7 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 18 Apr 2014 12:30:52 +0000 Subject: [PATCH] Simplify test git-svn-id: https://svn.dealii.org/trunk@32792 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/parallel_vector.templates.h | 33 +++--- tests/matrix_free/step-48b.cc | 108 ++++-------------- tests/matrix_free/step-48b.output | 11 ++ .../step-48b.with_mpi=true.mpirun=4.output | 19 --- 4 files changed, 52 insertions(+), 119 deletions(-) create mode 100644 tests/matrix_free/step-48b.output delete mode 100644 tests/matrix_free/step-48b.with_mpi=true.mpirun=4.output diff --git a/deal.II/include/deal.II/lac/parallel_vector.templates.h b/deal.II/include/deal.II/lac/parallel_vector.templates.h index 8f37885dd2..1301658d91 100644 --- a/deal.II/include/deal.II/lac/parallel_vector.templates.h +++ b/deal.II/include/deal.II/lac/parallel_vector.templates.h @@ -598,22 +598,25 @@ namespace parallel #ifdef DEAL_II_WITH_MPI #ifdef DEBUG - // make sure that there are not outstanding requests from updating ghost - // values or compress - int flag = 1; - int ierr = MPI_Testall (update_ghost_values_requests.size(), - &update_ghost_values_requests[0], + if (Utilities::System::job_supports_mpi()) + { + // make sure that there are not outstanding requests from updating + // ghost values or compress + int flag = 1; + int ierr = MPI_Testall (update_ghost_values_requests.size(), + &update_ghost_values_requests[0], + &flag, MPI_STATUSES_IGNORE); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished update_ghost_values() requests" + "when calling swap, which is not allowed")); + ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished update_ghost_values() requests" - "when calling swap, which is not allowed")); - ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], - &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished compress() requests " - "when calling swap, which is not allowed")); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished compress() requests " + "when calling swap, which is not allowed")); + } #endif std::swap (compress_requests, v.compress_requests); diff --git a/tests/matrix_free/step-48b.cc b/tests/matrix_free/step-48b.cc index 11cb3c2edb..4b28f2366b 100644 --- a/tests/matrix_free/step-48b.cc +++ b/tests/matrix_free/step-48b.cc @@ -30,13 +30,9 @@ #include #include #include -#include -#include -#include #include #include #include -#include #include #include @@ -51,7 +47,6 @@ namespace Step48 { using namespace dealii; - const unsigned int dimension = 2; const unsigned int fe_degree = 4; @@ -182,17 +177,7 @@ namespace Step48 double ExactSolution::value (const Point &p, const unsigned int /* component */) const { - double t = this->get_time (); - - const double m = 0.5; - const double c1 = 0.; - const double c2 = 0.; - const double factor = (m / std::sqrt(1.-m*m) * - std::sin(std::sqrt(1.-m*m)*t+c2)); - double result = 1.; - for (unsigned int d=0; d triangulation; -#else Triangulation triangulation; -#endif FE_Q fe; DoFHandler dof_handler; ConstraintMatrix constraints; @@ -235,16 +216,13 @@ namespace Step48 template SineGordonProblem::SineGordonProblem () : -#ifdef DEAL_II_WITH_P4EST - triangulation (MPI_COMM_WORLD), -#endif fe (QGaussLobatto<1>(fe_degree+1)), dof_handler (triangulation), - n_global_refinements (8-2*dim), + n_global_refinements (2), time (-10), - final_time (-9), + final_time (-9.5), cfl_number (.1/fe_degree), - output_timestep_skip (200) + output_timestep_skip (1) {} @@ -255,11 +233,7 @@ namespace Step48 triangulation.refine_global (n_global_refinements); deallog << " Number of global active cells: " -#ifdef DEAL_II_WITH_P4EST - << triangulation.n_global_active_cells() -#else << triangulation.n_active_cells() -#endif << std::endl; dof_handler.distribute_dofs (fe); @@ -275,7 +249,6 @@ namespace Step48 QGaussLobatto<1> quadrature (fe_degree+1); typename MatrixFree::AdditionalData additional_data; - additional_data.mpi_communicator = MPI_COMM_WORLD; additional_data.tasks_parallel_scheme = MatrixFree::AdditionalData::partition_partition; @@ -292,7 +265,7 @@ namespace Step48 template void - SineGordonProblem::output_results (const unsigned int timestep_number) + SineGordonProblem::output_norm () { constraints.distribute (solution); solution.update_ghost_values(); @@ -304,13 +277,12 @@ namespace Step48 norm_per_cell, QGauss(fe_degree+1), VectorTools::L2_norm); - const double solution_norm = - std::sqrt(Utilities::MPI::sum (norm_per_cell.norm_sqr(), MPI_COMM_WORLD)); + const double solution_norm = norm_per_cell.norm_sqr(); - deallog << " Time:" - << std::setw(8) << std::setprecision(3) << time + deallog << " Time: " + << std::setw(6) << std::setprecision(3) << time << ", solution norm: " - << std::setprecision(5) << std::setw(7) << solution_norm + << std::setprecision(9) << std::setw(13) << solution_norm << std::endl; } @@ -322,14 +294,12 @@ namespace Step48 { make_grid_and_dofs(); - const double local_min_cell_diameter = + const double min_cell_diameter = triangulation.last()->diameter()/std::sqrt(dim); - const double global_min_cell_diameter - = -Utilities::MPI::max(-local_min_cell_diameter, MPI_COMM_WORLD); - time_step = cfl_number * global_min_cell_diameter; + time_step = cfl_number * min_cell_diameter; time_step = (final_time-time)/(int((final_time-time)/time_step)); deallog << " Time step size: " << time_step << ", finest cell: " - << global_min_cell_diameter << std::endl << std::endl; + << min_cell_diameter << std::endl << std::endl; VectorTools::interpolate (dof_handler, @@ -338,7 +308,7 @@ namespace Step48 VectorTools::interpolate (dof_handler, ExactSolution (1, time-time_step), old_solution); - output_results (0); + output_norm (); std::vector*> previous_solutions; previous_solutions.push_back(&old_solution); @@ -355,10 +325,8 @@ namespace Step48 old_solution.swap (solution); sine_gordon_op.apply (solution, previous_solutions); - if (timestep_number % output_timestep_skip == 0) - output_results(timestep_number / output_timestep_skip); + output_norm(); } - output_results(timestep_number / output_timestep_skip + 1); deallog << std::endl << " Performed " << timestep_number << " time steps." @@ -370,43 +338,13 @@ namespace Step48 int main (int argc, char **argv) { - Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv); - - unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); - deallog.push(Utilities::int_to_string(myid)); - - if (myid == 0) - { - std::ofstream logfile("output"); - deallog.attach(logfile); - deallog << std::setprecision(4); - deallog.depth_console(0); - deallog.threshold_double(1.e-10); - - { - deallog.push("2d"); - Step48::SineGordonProblem<2> sg_problem; - sg_problem.run (); - deallog.pop(); - } - { - deallog.push("3d"); - Step48::SineGordonProblem<3> sg_problem; - sg_problem.run (); - deallog.pop(); - } - } - else - { - deallog.depth_console(0); - { - Step48::SineGordonProblem<2> sg_problem; - sg_problem.run (); - } - { - Step48::SineGordonProblem<3> sg_problem; - sg_problem.run (); - } - } + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog << std::setprecision(4); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + Step48::SineGordonProblem<2> sg_problem; + sg_problem.run (); } diff --git a/tests/matrix_free/step-48b.output b/tests/matrix_free/step-48b.output new file mode 100644 index 0000000000..600934fc3d --- /dev/null +++ b/tests/matrix_free/step-48b.output @@ -0,0 +1,11 @@ + +DEAL:: Number of global active cells: 16 +DEAL:: Number of degrees of freedom: 289 +DEAL:: Time step size: 0.2500, finest cell: 7.500 +DEAL:: +DEAL:: Time: -10.0 , solution norm: 7.11111164 +DEAL:: Time: -9.75 , solution norm: 3.78861141 +DEAL:: Time: -9.50 , solution norm: 0.869590104 +DEAL:: +DEAL:: Performed 3 time steps. +DEAL:: diff --git a/tests/matrix_free/step-48b.with_mpi=true.mpirun=4.output b/tests/matrix_free/step-48b.with_mpi=true.mpirun=4.output deleted file mode 100644 index 5cf259b9be..0000000000 --- a/tests/matrix_free/step-48b.with_mpi=true.mpirun=4.output +++ /dev/null @@ -1,19 +0,0 @@ - -DEAL:0:2d:: Number of global active cells: 256 -DEAL:0:2d:: Number of degrees of freedom: 4225 -DEAL:0:2d:: Time step size: 0.04762, finest cell: 1.875 -DEAL:0:2d:: -DEAL:0:2d:: Time:-10.0 , solution norm: 9.5599 -DEAL:0:2d:: Time:-8.95 , solution norm: 21.848 -DEAL:0:2d:: -DEAL:0:2d:: Performed 22 time steps. -DEAL:0:2d:: -DEAL:0:3d:: Number of global active cells: 64 -DEAL:0:3d:: Number of degrees of freedom: 4913 -DEAL:0:3d:: Time step size: 0.20000, finest cell: 7.5000 -DEAL:0:3d:: -DEAL:0:3d:: Time:-10.0 , solution norm: 29.779 -DEAL:0:3d:: Time:-8.80 , solution norm: 84.725 -DEAL:0:3d:: -DEAL:0:3d:: Performed 6 time steps. -DEAL:0:3d:: -- 2.39.5