From c6ad3bb22c939770be04823d33f44e55ba3548a8 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 11 May 2019 22:02:51 -0400 Subject: [PATCH] Modernize/Fix step-55 --- examples/step-55/doc/results.dox | 19 +++++++++++++++ examples/step-55/step-55.cc | 40 ++------------------------------ 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/examples/step-55/doc/results.dox b/examples/step-55/doc/results.dox index 68d5e64a48..5f2e7a7020 100644 --- a/examples/step-55/doc/results.dox +++ b/examples/step-55/doc/results.dox @@ -234,4 +234,23 @@ You can prescribe the exact flow solution as $b$ in the convective term $b \cdot \nabla u$. This should give the same solution as the original problem, if you set the right hand side to zero. +

Adaptive refinement

+So far, this tutorial program refines the mesh globally in each step. +Replacing the code in StokesProblem::refine_grid() by something like +@code +Vector estimated_error_per_cell(triangulation.n_active_cells()); + +FEValuesExtractors::Vector velocities(0); +KellyErrorEstimator::estimate( + dof_handler, + QGauss(fe.degree + 1), + std::map *>(), + locally_relevant_solution, + estimated_error_per_cell, + fe.component_mask(velocities)); +parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number( + triangulation, estimated_error_per_cell, 0.3, 0.0); +triangulation.execute_coarsening_and_refinement(); +@endcode +makes it simple to explore adaptive mesh refinement. diff --git a/examples/step-55/step-55.cc b/examples/step-55/step-55.cc index 928183d1b2..eedda110cb 100644 --- a/examples/step-55/step-55.cc +++ b/examples/step-55/step-55.cc @@ -515,10 +515,7 @@ namespace Step55 const FEValuesExtractors::Vector velocities(0); const FEValuesExtractors::Scalar pressure(dim); - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.begin_active()) if (cell->is_locally_owned()) { cell_matrix = 0; @@ -595,19 +592,6 @@ namespace Step55 #ifdef USE_PETSC_LA data.symmetric_operator = true; -#else -// data.n_cycles = 1; -// data.higher_order_elements = true; -// data.elliptic = true; -// data.smoother_sweeps = 5; -// data.smoother_overlap = 1; - -// std::vector > constant_modes; -// FEValuesExtractors::Vector velocity_components(0); -// DoFTools::extract_constant_modes (dof_handler, -// fe.component_mask(velocity_components), -// constant_modes); -// data.constant_modes = constant_modes; #endif prec_A.initialize(system_matrix.block(0, 0), data); } @@ -618,7 +602,6 @@ namespace Step55 #ifdef USE_PETSC_LA data.symmetric_operator = true; -#else #endif prec_S.initialize(preconditioner_matrix.block(1, 1), data); } @@ -679,26 +662,7 @@ namespace Step55 { TimerOutput::Scope t(computing_timer, "refine"); - if (true) - { - triangulation.refine_global(); - } - else - { - Vector estimated_error_per_cell(triangulation.n_active_cells()); - - FEValuesExtractors::Vector velocities(0); - KellyErrorEstimator::estimate( - dof_handler, - QGauss(fe.degree + 1), - std::map *>(), - locally_relevant_solution, - estimated_error_per_cell, - fe.component_mask(velocities)); - parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number( - triangulation, estimated_error_per_cell, 0.3, 0.0); - triangulation.execute_coarsening_and_refinement(); - } + triangulation.refine_global(); } -- 2.39.5