]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
continuing on MG
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 1 May 2000 13:31:05 +0000 (13:31 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 1 May 2000 13:31:05 +0000 (13:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@2776 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/multigrid.templates.h
deal.II/deal.II/source/multigrid/mg_base.cc
tests/deal.II/mglocal.cc

index c11731dc35be1023538dd341b7251af75b465bad..51384d716e9c597eb80418dbee8487a38292f4db 100644 (file)
@@ -117,7 +117,8 @@ Multigrid<dim>::copy_to_mg (const Vector<number>& osrc)
                                                   // Delete values on refinement edge,
                                                   // since restriction will add them again.
                  for (unsigned int i=0; i<dofs_per_face; ++i)
-                   defect[level](level_face_indices[i]) = 0.;
+                   defect[level](level_face_indices[i])
+                     = 0.;
                };
            };
        };
@@ -187,19 +188,21 @@ Multigrid<dim>::print_vector (const unsigned int level,
                              const Vector<double>& v,
                              const char* name) const
 {
-  Vector<double> out_vector;
-  
   const DoFHandler<dim>* dof = mg_dof_handler;
   
+  Vector<double> out_vector(dof->n_dofs());
+
+  out_vector = -10000;
+  
   const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell;
 
   vector<unsigned int> global_dof_indices (dofs_per_cell);
   vector<unsigned int> level_dof_indices (dofs_per_cell);
 
-  DoFHandler<dim>::cell_iterator
-    global_cell = dof->begin(level);
-  MGDoFHandler<dim>::cell_iterator
-    level_cell = mg_dof_handler->begin(level);
+  DoFHandler<dim>::active_cell_iterator
+    global_cell = dof->begin_active(level);
+  MGDoFHandler<dim>::active_cell_iterator
+    level_cell = mg_dof_handler->begin_active(level);
   const MGDoFHandler<dim>::cell_iterator
     endc = mg_dof_handler->end(level);
 
index 630e8c3ef1bd1b3c3d0a720f14a514497ca8ce4e..cc3bd3c2549f0bbe34bc3cf4f02a299e8763e95a 100644 (file)
@@ -43,7 +43,7 @@ MGBase::vcycle(const MGSmootherBase     &pre_smooth,
               const MGCoarseGridSolver &coarse_grid_solver)
 {
   level_mgstep (maxlevel, pre_smooth, post_smooth, coarse_grid_solver);
-  abort ();
+//  abort ();
 }
 
 
@@ -63,6 +63,8 @@ MGBase::level_mgstep(const unsigned int        level,
   if (level == minlevel)
     {
       coarse_grid_solver(level, solution[level], defect[level]);
+      sprintf(name, "MG%d-solution",level);
+      print_vector(level, solution[level], name);
       return;
     }
 
@@ -99,13 +101,14 @@ MGBase::level_mgstep(const unsigned int        level,
 
   solution[level] += t;
   
-                                  // smoothing (modify solution again)
-//TODO: what happens here? smooth overwrites the solution[level],
-//TODO: so the previous two statements should have no effect. No?  
+                                  // post-smoothing
+
   post_smooth.smooth(level, solution[level], defect[level]);
 
   sprintf(name, "MG%d-post",level);
   print_vector(level, solution[level], name);
+
+  delete[] name;
 }
 
 
index 35312ffb1d068ba270e14291c2af2f899b095780..e2294b4372fe7e93872d04e54db23ce6da37fbcc 100644 (file)
@@ -104,12 +104,12 @@ int main()
       cell->set_refine_flag();
       tr.execute_coarsening_and_refinement();
 
-      tr.refine_global(1);
+      tr.refine_global(2);
       dof.distribute_dofs(*fe);
       const unsigned int size = dof.n_dofs();
       deallog << "DoFs " << size << endl;
       deallog << "Levels: " << tr.n_levels() << endl;
-      for (unsigned int step=1;step < 5; ++step)
+      for (unsigned int step=14;step < 15; ++step)
        {
          deallog << "smoothing-steps" << step << endl;
          SparsityPattern structure(size, dof.max_couplings_between_dofs());
@@ -130,6 +130,16 @@ int main()
          hanging_nodes.condense(A);
          hanging_nodes.condense(f);
 
+         if (true)
+           {
+             ofstream out_file("MGf");
+             DataOut<2> out;
+             out.attach_dof_handler(dof);
+             out.add_data_vector(f, "v");
+             out.build_patches(5);
+             out.write_gnuplot(out_file);
+           }
+         
          Vector<double> u;
          u.reinit(f);
          PrimitiveVectorMemory<> mem;
@@ -149,7 +159,7 @@ int main()
            }
          equation.build_mgmatrix(mgA, mgdof, quadrature);
          
-         SolverControl cgcontrol(20,0., false, false);
+         SolverControl cgcontrol(2000,1.e-14, false, false);
          PrimitiveVectorMemory<> cgmem;
          SolverCG<> cgsolver(cgcontrol, cgmem);
          PreconditionIdentity cgprec;
@@ -175,11 +185,18 @@ Multigrid<2> multigrid(mgdof, hanging_nodes, mgstruct, mgA, transfer, tr.n_level
          hanging_nodes.distribute(u);
 
          DataOut<2> out;
-         ofstream ofile("out.gnuplot");
+         char* name = new char[100];
+
+         sprintf(name, "MG-Q%d-%d", degree, step);
+         
+         ofstream ofile(name);
          out.attach_dof_handler(dof);
          out.add_data_vector(u,"u");
-         out.build_patches(4);
+         out.add_data_vector(f,"f");
+         out.build_patches(5);
          out.write_gnuplot(ofile);
+
+         delete[] name;
        }
       deallog.pop();
     }
@@ -190,34 +207,9 @@ double
 RHSFunction<dim>::value (const Point<dim>&p,
                         const unsigned int) const
 {
-//  return 1.;
+  return 1.;
   
   return p(0)*p(0)+p(1)*p(1);
   
   return (2.1)*(sin(p(0))* sin(p(1)));
 }
-
-
-void write_gnuplot (const MGDoFHandler<2>& dofs, const Vector<double>& v, unsigned int level,
-                   ostream &out)
-{
-  MGDoFHandler<2>::cell_iterator cell;
-  MGDoFHandler<2>::cell_iterator endc = dofs.end(level);
-
-  Vector<double> values(dofs.get_fe().dofs_per_cell);
-  
-  unsigned int cell_index=0;
-  for (cell=dofs.begin(level); cell!=endc; ++cell, ++cell_index) 
-    {
-      cell->get_mg_dof_values(v, values);
-      
-      out << cell->vertex(0) << "  " << values(0) << endl;
-      out << cell->vertex(1) << "  " << values(1) << endl;
-      out << endl;
-      out << cell->vertex(3) << "  " << values(3) << endl;
-      out << cell->vertex(2) << "  " << values(2) << endl;
-      out << endl;
-      out << endl;
-    }
-  out << endl;
-}

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.