From: Bruno Turcksin Date: Thu, 30 Apr 2015 16:14:44 +0000 (-0500) Subject: Throw an exception when one tries to use in parallel tutorials that are serial. Consi... X-Git-Tag: v8.3.0-rc1~196^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65aef870a7b2f11bc6afa864843728da0cb12a95;p=dealii.git Throw an exception when one tries to use in parallel tutorials that are serial. Consistently use MPI_COMM_WORLD with reinit(IndesSet, MPI_Comm) in the tutorials. --- diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index d3ffb8ff99..653d8c31d0 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -413,7 +413,7 @@ namespace Step31 // function. IndexSet tmp_index_set(stokes_matrix->block(1,1).m()); tmp_index_set.add_range(0,stokes_matrix->block(1,1).m()); - tmp.reinit(tmp_index_set); + tmp.reinit(tmp_index_set, MPI_COMM_WORLD); } @@ -1056,15 +1056,15 @@ namespace Step31 // right hand sides to their correct sizes and block structure: IndexSet temperature_partitioning (n_T); temperature_partitioning.add_range(0,n_T); - stokes_solution.reinit (stokes_block_sizes); - old_stokes_solution.reinit (stokes_block_sizes); - stokes_rhs.reinit (stokes_block_sizes); + stokes_solution.reinit (stokes_block_sizes, MPI_COMM_WORLD); + old_stokes_solution.reinit (stokes_block_sizes, MPI_COMM_WORLD); + stokes_rhs.reinit (stokes_block_sizes, MPI_COMM_WORLD); - temperature_solution.reinit (temperature_partitioning); - old_temperature_solution.reinit (temperature_partitioning); - old_old_temperature_solution.reinit (temperature_partitioning); + temperature_solution.reinit (temperature_partitioning, MPI_COMM_WORLD); + old_temperature_solution.reinit (temperature_partitioning, MPI_COMM_WORLD); + old_old_temperature_solution.reinit (temperature_partitioning, MPI_COMM_WORLD); - temperature_rhs.reinit (temperature_partitioning); + temperature_rhs.reinit (temperature_partitioning, MPI_COMM_WORLD); } @@ -2218,6 +2218,12 @@ int main (int argc, char *argv[]) Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, numbers::invalid_unsigned_int); + // This program can only be run in serial. Otherwise, throw an exception. + int size; + MPI_Comm_size(MPI_COMM_WORLD,&size); + AssertThrow(size==1, ExcMessage("This program can only be run in serial," + " use mpirun -np 1 ./step-31")); + BoussinesqFlowProblem<2> flow_problem; flow_problem.run (); } diff --git a/examples/step-36/step-36.cc b/examples/step-36/step-36.cc index 4372c37ee9..6b5a539508 100644 --- a/examples/step-36/step-36.cc +++ b/examples/step-36/step-36.cc @@ -197,10 +197,10 @@ namespace Step36 // The next step is to take care of the eigenspectrum. In this case, the // outputs are eigenvalues and eigenfunctions, so we set the size of the // list of eigenfunctions and eigenvalues to be as large as we asked for - // in the input file. When using a PETScWrappers::MPI::Vector, the Vector + // in the input file. When using a PETScWrappers::MPI::Vector, the Vector // is initialized using an IndexSet. IndexSet is used not only to resize the - // PETScWrappers::MPI::Vector but it also associates an index in the - // PETScWrappers::MPI::Vector with a degree of freedom (see step-40 for a + // PETScWrappers::MPI::Vector but it also associates an index in the + // PETScWrappers::MPI::Vector with a degree of freedom (see step-40 for a // more detailed explanation). This assocation is done by the add_range() // function: IndexSet eigenfunction_index_set(dof_handler.n_dofs ()); @@ -476,6 +476,13 @@ int main (int argc, char **argv) using namespace Step36; Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + // This program can only be run in serial. Otherwise, throw an exception. + int size; + MPI_Comm_size(MPI_COMM_WORLD,&size); + AssertThrow(size==1, ExcMessage("This program can only be run in serial," + " use mpirun -np 1 ./step-36")); + { deallog.depth_console (0); diff --git a/examples/step-41/step-41.cc b/examples/step-41/step-41.cc index 8587e3cff8..279b4c9f0b 100644 --- a/examples/step-41/step-41.cc +++ b/examples/step-41/step-41.cc @@ -258,10 +258,10 @@ namespace Step41 solution_index_set.set_size(dof_handler.n_dofs()); solution_index_set.add_range(0, dof_handler.n_dofs()); - solution.reinit (solution_index_set); - system_rhs.reinit (solution_index_set); - complete_system_rhs.reinit (solution_index_set); - contact_force.reinit (solution_index_set); + solution.reinit (solution_index_set, MPI_COMM_WORLD); + system_rhs.reinit (solution_index_set, MPI_COMM_WORLD); + complete_system_rhs.reinit (solution_index_set, MPI_COMM_WORLD); + contact_force.reinit (solution_index_set, MPI_COMM_WORLD); // The only other thing to do here is to compute the factors in the $B$ // matrix which is used to scale the residual. As discussed in the @@ -674,6 +674,12 @@ int main (int argc, char *argv[]) Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, numbers::invalid_unsigned_int); + // This program can only be run in serial. Otherwise, throw an exception. + int size; + MPI_Comm_size(MPI_COMM_WORLD,&size); + AssertThrow(size==1, ExcMessage("This program can only be run in serial," + " use mpirun -np 1 ./step-41")); + ObstacleProblem<2> obstacle_problem; obstacle_problem.run (); } diff --git a/examples/step-43/step-43.cc b/examples/step-43/step-43.cc index 2f429b1b6e..dbea7124eb 100644 --- a/examples/step-43/step-43.cc +++ b/examples/step-43/step-43.cc @@ -448,8 +448,8 @@ namespace Step43 a_preconditioner (Apreconditioner) { IndexSet tmp_index_set(darcy_matrix->block(1,1).m()); - tmp_index_set.add_range(0,darcy_matrix->block(1,1).m()); - tmp.reinit(tmp_index_set); + tmp_index_set.add_range(0,darcy_matrix->block(1,1).m()); + tmp.reinit(tmp_index_set, MPI_COMM_WORLD); } @@ -814,28 +814,29 @@ namespace Step43 darcy_index_set[1].set_size(n_p); darcy_index_set[0].add_range(0,n_u); darcy_index_set[1].add_range(0,n_p); - darcy_solution.reinit (darcy_index_set); + darcy_solution.reinit (darcy_index_set, MPI_COMM_WORLD); darcy_solution.collect_sizes (); - last_computed_darcy_solution.reinit (darcy_index_set); + last_computed_darcy_solution.reinit (darcy_index_set, MPI_COMM_WORLD); last_computed_darcy_solution.collect_sizes (); - second_last_computed_darcy_solution.reinit (darcy_index_set); + second_last_computed_darcy_solution.reinit (darcy_index_set, MPI_COMM_WORLD); second_last_computed_darcy_solution.collect_sizes (); - darcy_rhs.reinit (darcy_index_set); + darcy_rhs.reinit (darcy_index_set, MPI_COMM_WORLD); darcy_rhs.collect_sizes (); saturation_index_set.clear(); saturation_index_set.set_size(n_s); saturation_index_set.add_range(0,n_s); - saturation_solution.reinit (saturation_index_set); - old_saturation_solution.reinit (saturation_index_set); - old_old_saturation_solution.reinit (saturation_index_set); + saturation_solution.reinit (saturation_index_set, MPI_COMM_WORLD); + old_saturation_solution.reinit (saturation_index_set, MPI_COMM_WORLD); + old_old_saturation_solution.reinit (saturation_index_set, MPI_COMM_WORLD); - saturation_matching_last_computed_darcy_solution.reinit (saturation_index_set); + saturation_matching_last_computed_darcy_solution.reinit (saturation_index_set, + MPI_COMM_WORLD); - saturation_rhs.reinit (saturation_index_set); + saturation_rhs.reinit (saturation_index_set, MPI_COMM_WORLD); } @@ -2260,6 +2261,12 @@ int main (int argc, char *argv[]) Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, numbers::invalid_unsigned_int); + // This program can only be run in serial. Otherwise, throw an exception. + int size; + MPI_Comm_size(MPI_COMM_WORLD,&size); + AssertThrow(size==1, ExcMessage("This program can only be run in serial," + " use mpirun -np 1 ./step-43")); + TwoPhaseFlowProblem<2> two_phase_flow_problem(1); two_phase_flow_problem.run (); }