]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Simplify test
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Apr 2014 12:30:52 +0000 (12:30 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Apr 2014 12:30:52 +0000 (12:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@32792 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/parallel_vector.templates.h
tests/matrix_free/step-48b.cc
tests/matrix_free/step-48b.output [new file with mode: 0644]
tests/matrix_free/step-48b.with_mpi=true.mpirun=4.output [deleted file]

index 8f37885dd2a1c27d84c1fbdce8eef5cb0d2589d3..1301658d916928a5082b762202a82c912d6f758a 100644 (file)
@@ -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);
index 11cb3c2edbb353653bb2b3c0f0066434cb145065..4b28f2366ba0a5c3183dd5c2c49eabbe8fd2fcaf 100644 (file)
 #include <deal.II/dofs/dof_tools.h>
 #include <deal.II/dofs/dof_handler.h>
 #include <deal.II/lac/constraint_matrix.h>
-#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
-#include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_values.h>
 #include <deal.II/numerics/vector_tools.h>
-#include <deal.II/distributed/tria.h>
 
 #include <deal.II/lac/parallel_vector.h>
 #include <deal.II/matrix_free/matrix_free.h>
@@ -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<dim>::value (const Point<dim> &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<dim; ++d)
-      result *= -4. * std::atan (factor / std::cosh(m*p[d]+c1));
-    return result;
+    return 4.*std::exp(-p.square()*10);
   }
 
 
@@ -207,13 +192,9 @@ namespace Step48
 
   private:
     void make_grid_and_dofs ();
-    void output_results (const unsigned int timestep_number);
+    void output_norm ();
 
-#ifdef DEAL_II_WITH_P4EST
-    parallel::distributed::Triangulation<dim>   triangulation;
-#else
     Triangulation<dim>   triangulation;
-#endif
     FE_Q<dim>            fe;
     DoFHandler<dim>      dof_handler;
     ConstraintMatrix     constraints;
@@ -235,16 +216,13 @@ namespace Step48
   template <int dim>
   SineGordonProblem<dim>::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<dim>::AdditionalData additional_data;
-    additional_data.mpi_communicator = MPI_COMM_WORLD;
     additional_data.tasks_parallel_scheme =
       MatrixFree<dim>::AdditionalData::partition_partition;
 
@@ -292,7 +265,7 @@ namespace Step48
 
   template <int dim>
   void
-  SineGordonProblem<dim>::output_results (const unsigned int timestep_number)
+  SineGordonProblem<dim>::output_norm ()
   {
     constraints.distribute (solution);
     solution.update_ghost_values();
@@ -304,13 +277,12 @@ namespace Step48
                                        norm_per_cell,
                                        QGauss<dim>(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<dim> (1, time-time_step),
                               old_solution);
-    output_results (0);
+    output_norm ();
 
     std::vector<parallel::distributed::Vector<double>*> 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 (file)
index 0000000..600934f
--- /dev/null
@@ -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 (file)
index 5cf259b..0000000
+++ /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::

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.