From 7803d4df371cac0c5dc9c8e958c2b22924d351ab Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 13 Aug 2008 02:46:03 +0000 Subject: [PATCH] Let the preconditioner have its own sparsity pattern. git-svn-id: https://svn.dealii.org/trunk@16531 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-31/step-31.cc | 194 +++++++++++++++++++--------- 1 file changed, 136 insertions(+), 58 deletions(-) diff --git a/deal.II/examples/step-31/step-31.cc b/deal.II/examples/step-31/step-31.cc index a423902798..df879ac0a4 100644 --- a/deal.II/examples/step-31/step-31.cc +++ b/deal.II/examples/step-31/step-31.cc @@ -387,6 +387,8 @@ class BoussinesqFlowProblem BlockSparsityPattern sparsity_pattern; BlockSparseMatrix system_matrix; + + BlockSparsityPattern preconditioner_sparsity_pattern; BlockSparseMatrix preconditioner_matrix; double time_step; @@ -999,81 +1001,157 @@ void BoussinesqFlowProblem::setup_dofs (const bool setup_matrices) // the sparsity pattern. if (setup_matrices == true) { - system_matrix.clear (); - preconditioner_matrix.clear (); + { + system_matrix.clear (); - BlockCompressedSetSparsityPattern csp (3,3); + BlockCompressedSetSparsityPattern csp (3,3); - csp.block(0,0).reinit (n_u, n_u); - csp.block(0,1).reinit (n_u, n_p); - csp.block(0,2).reinit (n_u, n_T); - csp.block(1,0).reinit (n_p, n_u); - csp.block(1,1).reinit (n_p, n_p); - csp.block(1,2).reinit (n_p, n_T); - csp.block(2,0).reinit (n_T, n_u); - csp.block(2,1).reinit (n_T, n_p); - csp.block(2,2).reinit (n_T, n_T); + csp.block(0,0).reinit (n_u, n_u); + csp.block(0,1).reinit (n_u, n_p); + csp.block(0,2).reinit (n_u, n_T); + csp.block(1,0).reinit (n_p, n_u); + csp.block(1,1).reinit (n_p, n_p); + csp.block(1,2).reinit (n_p, n_T); + csp.block(2,0).reinit (n_T, n_u); + csp.block(2,1).reinit (n_T, n_p); + csp.block(2,2).reinit (n_T, n_T); - csp.collect_sizes (); + csp.collect_sizes (); - Table<2,DoFTools::Coupling> coupling (dim+2, dim+2); + Table<2,DoFTools::Coupling> coupling (dim+2, dim+2); - // 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) - { - case 2: + // 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) { - static const bool coupling_matrix[4][4] - = {{ 1, 1, 1, 0 }, - { 1, 1, 1, 0 }, + case 2: + { + static const bool coupling_matrix[4][4] + = {{ 1, 1, 1, 0 }, + { 1, 1, 1, 0 }, - { 1, 1, 1, 0 }, + { 1, 1, 1, 0 }, - { 0, 0, 0, 1 }}; - for (unsigned int c=0; c coupling (dim+2, dim+2); + + // 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) { - static const bool coupling_matrix[5][5] - = {{ 1, 1, 1, 1, 0 }, - { 1, 1, 1, 1, 0 }, - { 1, 1, 1, 1, 0 }, + case 2: + { + static const bool coupling_matrix[4][4] + = {{ 1, 0, 0, 0 }, + { 0, 1, 0, 0 }, - { 1, 1, 1, 0, 0 }, + { 0, 0, 1, 0 }, - { 0, 0, 0, 0, 1 }}; - for (unsigned int c=0; c