// <code>DynamicSparsityPattern</code>. This block sparsity pattern has
// four blocks in a $2 \times 2$ pattern. The blocks' sizes depend on
// <code>n_u</code> and <code>n_p</code>, which hold the number of velocity
- // and pressure variables. In the second step we have to instruct the block
- // system to update its knowledge about the sizes of the blocks it manages;
- // this happens with the <code>dsp.collect_sizes ()</code> call.
- BlockDynamicSparsityPattern dsp(2, 2);
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 1).reinit(n_p, n_p);
- dsp.collect_sizes();
+ // and pressure variables.
+ const std::vector<types::global_dof_index> block_sizes = {n_u, n_p};
+ BlockDynamicSparsityPattern dsp(block_sizes, block_sizes);
DoFTools::make_sparsity_pattern(dof_handler, dsp);
// We use the compressed block sparsity pattern in the same way as the
// Then we have to resize the solution and right hand side vectors in
// exactly the same way as the block compressed sparsity pattern:
- solution.reinit(2);
- solution.block(0).reinit(n_u);
- solution.block(1).reinit(n_p);
- solution.collect_sizes();
-
- system_rhs.reinit(2);
- system_rhs.block(0).reinit(n_u);
- system_rhs.block(1).reinit(n_p);
- system_rhs.collect_sizes();
+ solution.reinit(block_sizes);
+ system_rhs.reinit(block_sizes);
}