From 5d62f201122b1c727b739f43e8b6bb62a7fa02fe Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 12 Aug 2008 19:15:57 +0000 Subject: [PATCH] Use a different approach: Build a matrix that contains the vector Laplacian with the no-normal-flux boundary conditions. The boundary conditions do couple the individual components, but only on the boundary. git-svn-id: https://svn.dealii.org/trunk@16523 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-31/step-31.cc | 82 +++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/deal.II/examples/step-31/step-31.cc b/deal.II/examples/step-31/step-31.cc index addc5e237f..65af9ab698 100644 --- a/deal.II/examples/step-31/step-31.cc +++ b/deal.II/examples/step-31/step-31.cc @@ -113,6 +113,7 @@ class BoussinesqFlowProblem private: void setup_dofs (const bool setup_matrices); + void assemble_preconditioner (); void assemble_system (); void assemble_rhs_T (); double get_maximal_velocity () const; @@ -130,6 +131,7 @@ class BoussinesqFlowProblem BlockSparsityPattern sparsity_pattern; BlockSparseMatrix system_matrix; + BlockSparseMatrix preconditioner_matrix; double time_step; unsigned int timestep_number; @@ -733,6 +735,7 @@ void BoussinesqFlowProblem::setup_dofs (const bool setup_matrices) if (setup_matrices == true) { system_matrix.clear (); + preconditioner_matrix.clear (); BlockCompressedSetSparsityPattern csp (3,3); @@ -747,12 +750,15 @@ void BoussinesqFlowProblem::setup_dofs (const bool setup_matrices) csp.block(2,2).reinit (n_T, n_T); csp.collect_sizes (); - + + // TODO: only build entries + // that we really need DoFTools::make_sparsity_pattern (dof_handler, csp); hanging_node_constraints.condense (csp); sparsity_pattern.copy_from (csp); system_matrix.reinit (sparsity_pattern); + preconditioner_matrix.reinit (sparsity_pattern); } // As last action in this function, @@ -785,6 +791,74 @@ void BoussinesqFlowProblem::setup_dofs (const bool setup_matrices) +template +double scalar_product (const Tensor<2,dim> &t1, + const Tensor<2,dim> &t2) +{ + double s = 0; + for (unsigned int i=0; i +void +BoussinesqFlowProblem::assemble_preconditioner () +{ + preconditioner_matrix = 0; + + QGauss quadrature_formula(degree+2); + QGauss face_quadrature_formula(degree+2); + + FEValues fe_values (fe, quadrature_formula, + update_JxW_values | + update_gradients); + const unsigned int dofs_per_cell = fe.dofs_per_cell; + + const unsigned int n_q_points = quadrature_formula.size(); + + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); + std::vector local_dof_indices (dofs_per_cell); + + std::vector > phi_grad_u (dofs_per_cell); + + const FEValuesExtractors::Vector velocities (0); + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell!=endc; ++cell) + { + fe_values.reinit (cell); + local_matrix = 0; + + for (unsigned int q=0; qget_dof_indices (local_dof_indices); + + for (unsigned int i=0; i::assemble_system () std::cout << " Rebuilding preconditioner..." << std::flush; - A_preconditioner + assemble_preconditioner (); + + A_preconditioner = boost::shared_ptr::type> (new typename InnerPreconditioner::type()); - A_preconditioner->initialize (system_matrix.block(0,0), + A_preconditioner->initialize (preconditioner_matrix.block(0,0), typename InnerPreconditioner::type::AdditionalData()); Mp_preconditioner -- 2.39.5