]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use a more explicit description of the sparsity pattern.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Aug 2008 01:19:26 +0000 (01:19 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Aug 2008 01:19:26 +0000 (01:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@16530 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 97deffcca18c300101e608d8ee5c79f07d8e8714..a4239027980dba63e03a8bbf620ba2bb429a90f1 100644 (file)
@@ -1017,16 +1017,56 @@ void BoussinesqFlowProblem<dim>::setup_dofs (const bool setup_matrices)
       csp.collect_sizes ();
 
       Table<2,DoFTools::Coupling> coupling (dim+2, dim+2);
-      
-      for (unsigned int component = 0; component<dim+2; ++component)
-       for (unsigned int component2 = 0; component2<dim+2; ++component2)
-         coupling[component][component2] = DoFTools::always;
-      
-      for (unsigned int component = 0; component<dim+1; ++component)
+
+                                      // build the sparsity pattern. note
+                                      // that all dim velocities couple with
+                                      // each other and with the pressures,
+                                      // but that not all of the other
+                                      // components couple:
+      switch (dim)
        {
-         coupling[dim+1][component] = DoFTools::none;
-         coupling[component][dim+1] = DoFTools::none;
-       }
+         case 2:
+         {
+           static const bool coupling_matrix[4][4]
+             = {{ 1, 1,   1,  0 },
+                { 1, 1,   1,  0 },
+                
+                { 1, 1,   1,  0 },
+
+                { 0, 0,   0,  1 }};
+           for (unsigned int c=0; c<dim+2; ++c)
+             for (unsigned int d=0; d<dim+2; ++d)
+               if (coupling_matrix[c][d] == true)
+                 coupling[c][d] = DoFTools::always;
+               else
+                 coupling[c][d] = DoFTools::none;
+
+           break;
+         }
+
+         case 3:
+         {
+           static const bool coupling_matrix[5][5]
+             = {{ 1, 1, 1,   1,  0 },
+                { 1, 1, 1,   1,  0 },
+                { 1, 1, 1,   1,  0 },
+                
+                { 1, 1, 1,   0,  0 },
+
+                { 0, 0, 0,   0,  1 }};
+           for (unsigned int c=0; c<dim+2; ++c)
+             for (unsigned int d=0; d<dim+2; ++d)
+               if (coupling_matrix[c][d] == true)
+                 coupling[c][d] = DoFTools::always;
+               else
+                 coupling[c][d] = DoFTools::none;
+
+           break;
+         }
+
+         default:
+               Assert (false, ExcNotImplemented());
+       } 
       
       DoFTools::make_sparsity_pattern (dof_handler, coupling, csp);
       hanging_node_constraints.condense (csp);

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.