]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
multigrid copy_indices another try
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 May 2013 13:55:05 +0000 (13:55 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 May 2013 13:55:05 +0000 (13:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@29647 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-50/step-50.cc
deal.II/examples/step-6/step-6.cc
deal.II/source/multigrid/mg_transfer_prebuilt.cc

index 8279cf6e41a2130d52ecd1cc204adaa8820b843b..e0113bca7166f5fd2588a079e67b5d36d8bf6c17 100644 (file)
@@ -911,7 +911,7 @@ namespace Step50
                             mg_transfer,
                             mg_smoother,
                             mg_smoother);
-    //mg.set_debug(6);
+    mg.set_debug(6);
     mg.set_edge_matrices(mg_interface_down, mg_interface_up);
 
     PreconditionMG<dim, vector_t, MGTransferPrebuilt<vector_t> >
@@ -925,8 +925,20 @@ namespace Step50
 
     solution = 0;
 
+    try
+    {
     cg.solve (system_matrix, solution, system_rhs,
               preconditioner);
+    }
+    catch (...)
+    {
+        output_results(42);
+        constraints.distribute (solution);
+        output_results(43);
+        MPI_Barrier(MPI_COMM_WORLD);
+        exit(0);
+    }
+
     constraints.distribute (solution);
   }
 
@@ -967,6 +979,7 @@ namespace Step50
     GridRefinement::refine_and_coarsen_fixed_number (triangulation,
                                                      estimated_error_per_cell,
                                                      0.3, 0.03);
+
     triangulation.execute_coarsening_and_refinement ();
   }
 
@@ -987,6 +1000,7 @@ namespace Step50
     TrilinosWrappers::MPI::Vector res_ghosted = temp_solution;
     res_ghosted = temp;
 
+
     data_out.attach_dof_handler (mg_dof_handler);
     data_out.add_data_vector (temp_solution, "solution");
     data_out.add_data_vector (res_ghosted, "res");
@@ -1056,8 +1070,11 @@ namespace Step50
             // static const HyperBallBoundary<dim> boundary;
             // triangulation.set_boundary (0, boundary);
 
+            triangulation.refine_global (2);
           }
         else
+          //triangulation.refine_global (1);
+          refine_grid ();
 
 
         deallog << "   Number of active cells:       "
@@ -1098,6 +1115,7 @@ int main (int argc, char *argv[])
       using namespace dealii;
       using namespace Step50;
 
+      LaplaceProblem<2> laplace_problem(3);
       laplace_problem.run ();
     }
   catch (std::exception &exc)
index 7a5ab147781defae5973482363fff8554c4a2312..535cc44779de7e0e457de22e3dfbd2fabaca27ba 100644 (file)
 #include <deal.II/numerics/matrix_tools.h>
 #include <deal.II/numerics/data_out.h>
 
+#include <deal.II/base/timer.h>
+
+#include <deal.II/lac/sparse_direct.h>
+
 #include <fstream>
 #include <iostream>
 
@@ -109,6 +113,7 @@ private:
   // a list of constraints to hold the hanging nodes and the boundary
   // conditions.
   ConstraintMatrix     constraints;
+    TimerOutput                               computing_timer;
 
   SparsityPattern      sparsity_pattern;
   SparseMatrix<double> system_matrix;
@@ -186,7 +191,10 @@ template <int dim>
 Step6<dim>::Step6 ()
   :
   dof_handler (triangulation),
-  fe (2)
+               computing_timer (std::cout,
+                     TimerOutput::summary,
+                                TimerOutput::wall_times),
+  fe (1)
 {}
 
 
@@ -281,7 +289,9 @@ Step6<dim>::~Step6 ()
 template <int dim>
 void Step6<dim>::setup_system ()
 {
+    computing_timer.enter_section ("distribute");
   dof_handler.distribute_dofs (fe);
+    computing_timer.exit_section ("distribute");
 
   solution.reinit (dof_handler.n_dofs());
   system_rhs.reinit (dof_handler.n_dofs());
@@ -298,8 +308,10 @@ void Step6<dim>::setup_system ()
   // from computations on the previous mesh before the last adaptive
   // refinement):
   constraints.clear ();
+    computing_timer.enter_section ("hanging");
   DoFTools::make_hanging_node_constraints (dof_handler,
                                            constraints);
+    computing_timer.exit_section ("hanging");
 
 
   // Now we are ready to interpolate the ZeroFunction to our boundary with
@@ -338,10 +350,12 @@ void Step6<dim>::setup_system ()
   // instead because then we would first write into these locations only to
   // later set them to zero again during condensation.
   CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
+    computing_timer.enter_section ("makesp");
   DoFTools::make_sparsity_pattern(dof_handler,
                                   c_sparsity,
                                   constraints,
                                   /*keep_constrained_dofs = */ false);
+    computing_timer.exit_section ("makesp");
 
   // Now all non-zero entries of the matrix are known (i.e. those from
   // regularly assembling the matrix and those that were introduced by
@@ -385,7 +399,7 @@ void Step6<dim>::setup_system ()
 template <int dim>
 void Step6<dim>::assemble_system ()
 {
-  const QGauss<dim>  quadrature_formula(3);
+  const QGauss<dim>  quadrature_formula(2);
 
   FEValues<dim> fe_values (fe, quadrature_formula,
                            update_values    |  update_gradients |
@@ -465,14 +479,9 @@ void Step6<dim>::assemble_system ()
 template <int dim>
 void Step6<dim>::solve ()
 {
-  SolverControl           solver_control (1000, 1e-12);
-  SolverCG<>              solver (solver_control);
-
-  PreconditionSSOR<> preconditioner;
-  preconditioner.initialize(system_matrix, 1.2);
-
-  solver.solve (system_matrix, solution, system_rhs,
-                preconditioner);
+    SparseDirectUMFPACK u;
+  u.initialize(system_matrix);
+  u.vmult(solution, system_rhs);
 
   constraints.distribute (solution);
 }
@@ -658,7 +667,7 @@ void Step6<dim>::output_results (const unsigned int cycle) const
 template <int dim>
 void Step6<dim>::run ()
 {
-  for (unsigned int cycle=0; cycle<8; ++cycle)
+  for (unsigned int cycle=0; cycle<17; ++cycle)
     {
       std::cout << "Cycle " << cycle << ':' << std::endl;
 
@@ -678,16 +687,20 @@ void Step6<dim>::run ()
       std::cout << "   Number of active cells:       "
                 << triangulation.n_active_cells()
                 << std::endl;
-
+    computing_timer.enter_section ("setup");
       setup_system ();
+    computing_timer.exit_section ("setup");
 
       std::cout << "   Number of degrees of freedom: "
                 << dof_handler.n_dofs()
                 << std::endl;
 
+    computing_timer.enter_section ("ass");
+
       assemble_system ();
+      computing_timer.exit_section ("ass");
       solve ();
-      output_results (cycle);
+      //output_results (cycle);
     }
 
   // After we have finished computing the solution on the finest mesh, and
@@ -695,6 +708,7 @@ void Step6<dim>::run ()
   // on this final mesh to a file. As already done in one of the previous
   // examples, we use the EPS format for output, and to obtain a reasonable
   // view on the solution, we rescale the z-axis by a factor of four.
+  /*
   DataOutBase::EpsFlags eps_flags;
   eps_flags.z_scaling = 4;
 
@@ -706,7 +720,7 @@ void Step6<dim>::run ()
   data_out.build_patches ();
 
   std::ofstream output ("final-solution.eps");
-  data_out.write_eps (output);
+  data_out.write_eps (output);*/
 }
 
 
index 66dfb218c552143c4d0c00e49765e92237fb290a..025e6c29c2ef0f3d2e9e510d9f54d710e67b28df 100644 (file)
@@ -282,7 +282,6 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
               //skip if we did this global dof already (on this or a coarser level)
               if (dof_touched[global_idx])
                 continue;
-              dof_touched[global_idx] = true;
 
               bool global_mine = mg_dof.locally_owned_dofs().is_element(global_dof_indices[i]);
               bool level_mine = mg_dof.locally_owned_mg_dofs(level).is_element(level_dof_indices[i]);
@@ -296,6 +295,10 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
               else if (global_mine)
                 copy_indices_to_me[level].push_back(
                     std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
+              else
+                continue;
+
+              dof_touched[global_idx] = true;
             }
         }
     }

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.