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);