From 28d25d2d658a016db719422af62aaab0d4392ddf Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 17 Oct 2007 21:10:28 +0000 Subject: [PATCH] Prepare for using adaptive meshes. Fix computation of time step size. git-svn-id: https://svn.dealii.org/trunk@15342 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-22/step-22.cc | 48 ++++++++++++++++------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/deal.II/examples/step-22/step-22.cc b/deal.II/examples/step-22/step-22.cc index 5dfb2cbad3..f984931980 100644 --- a/deal.II/examples/step-22/step-22.cc +++ b/deal.II/examples/step-22/step-22.cc @@ -62,7 +62,7 @@ class BoussinesqFlowProblem void run (); private: - void make_grid_and_dofs (); + void setup_dofs (); void assemble_system (); void assemble_rhs_T (); double get_maximal_velocity () const; @@ -75,11 +75,11 @@ class BoussinesqFlowProblem FESystem fe; DoFHandler dof_handler; + ConstraintMatrix hanging_node_constraints; + BlockSparsityPattern sparsity_pattern; BlockSparseMatrix system_matrix; - const unsigned int n_refinement_steps; - double time_step; unsigned int timestep_number; @@ -368,7 +368,6 @@ BoussinesqFlowProblem::BoussinesqFlowProblem (const unsigned int degree) FE_Q(degree), 1, FE_DGQ(degree-1), 1), dof_handler (triangulation), - n_refinement_steps (5), time_step (0), rebuild_preconditioner (true) {} @@ -377,18 +376,13 @@ BoussinesqFlowProblem::BoussinesqFlowProblem (const unsigned int degree) template -void BoussinesqFlowProblem::make_grid_and_dofs () -{ - GridGenerator::half_hyper_shell (triangulation, Point(), 0.5, 1.0); - - static HalfHyperShellBoundary boundary; - triangulation.set_boundary (0, boundary); - - triangulation.refine_global (n_refinement_steps); - +void BoussinesqFlowProblem::setup_dofs () +{ dof_handler.distribute_dofs (fe); DoFRenumbering::component_wise (dof_handler); - + DoFTools::make_hanging_node_constraints (dof_handler, hanging_node_constraints); + hanging_node_constraints.close (); + std::vector dofs_per_component (dim+2); DoFTools::count_dofs_per_component (dof_handler, dofs_per_component); const unsigned int n_u = dofs_per_component[0] * dim, @@ -418,11 +412,12 @@ void BoussinesqFlowProblem::make_grid_and_dofs () sparsity_pattern.block(1,2).reinit (n_p, n_T, n_couplings); sparsity_pattern.block(2,2).reinit (n_T, n_T, n_couplings); - sparsity_pattern.collect_sizes(); + sparsity_pattern.collect_sizes(); + DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); + hanging_node_constraints.condense (sparsity_pattern); sparsity_pattern.compress(); - system_matrix.reinit (sparsity_pattern); @@ -578,6 +573,9 @@ void BoussinesqFlowProblem::assemble_system () for (unsigned int i=0; i component_mask (dim+2, true); @@ -789,7 +787,7 @@ void BoussinesqFlowProblem::solve () } time_step = GridTools::minimal_cell_diameter(triangulation) / - std::max(get_maximal_velocity(),1.); + get_maximal_velocity() / 10; assemble_rhs_T (); { @@ -892,6 +890,8 @@ BoussinesqFlowProblem::get_maximal_velocity () const } } + std::cout << "Maximal velocity=" << max_velocity << std::endl; + return max_velocity; } @@ -900,14 +900,18 @@ BoussinesqFlowProblem::get_maximal_velocity () const template void BoussinesqFlowProblem::run () { - make_grid_and_dofs(); + GridGenerator::half_hyper_shell (triangulation, Point(), 0.5, 1.0); + + static HalfHyperShellBoundary boundary; + triangulation.set_boundary (0, boundary); + + triangulation.refine_global (5); + + setup_dofs(); { - ConstraintMatrix constraints; - constraints.close(); - VectorTools::project (dof_handler, - constraints, + hanging_node_constraints, QGauss(degree+2), InitialValues(), old_solution); -- 2.39.5