]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Move slightly forward.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 16 May 2013 12:44:16 +0000 (12:44 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 16 May 2013 12:44:16 +0000 (12:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@29519 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-26/step-26.cc

index a4528ae9633cd4e8ab23e6233064029993d7e3bb..0d4da01968f0f3377000964b28a2f5cb24d30c21 100644 (file)
@@ -15,6 +15,7 @@
 #include <deal.II/base/logstream.h>
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
 #include <deal.II/lac/sparse_matrix.h>
 #include <deal.II/lac/solver_cg.h>
 #include <deal.II/lac/precondition.h>
@@ -172,8 +173,6 @@ namespace Step26
   template<int dim>
   void HeatEquation<dim>::setup_system()
   {
-//TODO: we need to take care of constraints here! :-)
-
     dof_handler.distribute_dofs(fe);
 
     std::cout << std::endl
@@ -185,12 +184,17 @@ namespace Step26
               << std::endl
              << std::endl;
 
-    sparsity_pattern.reinit(dof_handler.n_dofs(),
-                            dof_handler.n_dofs(),
-                            dof_handler.max_couplings_between_dofs());
+    constraints.clear ();
+    DoFTools::make_hanging_node_constraints (dof_handler,
+                                             constraints);
+    constraints.close();
+
+    CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
     DoFTools::make_sparsity_pattern(dof_handler,
-                                    sparsity_pattern);
-    sparsity_pattern.compress();
+                                    c_sparsity,
+                                    constraints,
+                                    /*keep_constrained_dofs = */ true);
+    sparsity_pattern.copy_from(c_sparsity);
 
     mass_matrix.reinit(sparsity_pattern);
     laplace_matrix.reinit(sparsity_pattern);
@@ -198,16 +202,18 @@ namespace Step26
 
     MatrixCreator::create_mass_matrix(dof_handler,
                                       QGauss<dim>(fe.degree+1),
-                                      mass_matrix);
+                                      mass_matrix,
+                                      (const Function<dim>*)0,
+                                      constraints);
     MatrixCreator::create_laplace_matrix(dof_handler,
                                          QGauss<dim>(fe.degree+1),
-                                         laplace_matrix);
+                                         laplace_matrix,
+                                         (const Function<dim>*)0,
+                                         constraints);
 
     solution.reinit(dof_handler.n_dofs());
     old_solution.reinit(dof_handler.n_dofs());
     system_rhs.reinit(dof_handler.n_dofs());
-
-    constraints.close();
   }
 
 
@@ -223,6 +229,8 @@ namespace Step26
 
     cg.solve(system_matrix, solution, system_rhs, preconditioner);
 
+    constraints.distribute(solution);
+
     std::cout << "     " << solver_control.last_step()
               << " CG iterations." << std::endl;
   }
@@ -362,8 +370,8 @@ namespace Step26
   template<int dim>
   void HeatEquation<dim>::run()
   {
-    const unsigned int initial_global_refinement = (dim == 2 ? 4 : 2);
-    const unsigned int n_adaptive_pre_refinement_steps = 3;
+    const unsigned int initial_global_refinement = (dim == 2 ? 1 : 2);
+    const unsigned int n_adaptive_pre_refinement_steps = 1;
 
     GridGenerator::hyper_L (triangulation);
     triangulation.refine_global (initial_global_refinement);
@@ -440,6 +448,8 @@ start_time_iteration:
                                              system_rhs);
         }
 
+        constraints.condense (system_rhs);
+
         solve_time_step();
 
         output_results();

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.