From: Daniel Arndt Date: Sun, 12 May 2019 02:02:51 +0000 (-0400) Subject: Modernize/Fix step-55 X-Git-Tag: v9.1.0-rc1~54^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8105%2Fhead;p=dealii.git Modernize/Fix step-55 --- 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(); }