From fe46fbdf723d6d13952f955d780576a1a06a8792 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 9 Jan 2016 14:18:17 -0500 Subject: [PATCH] Improve the refine_mesh function. --- cdr/solver/cdr.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cdr/solver/cdr.cc b/cdr/solver/cdr.cc index 3c37619..0be13d4 100644 --- a/cdr/solver/cdr.cc +++ b/cdr/solver/cdr.cc @@ -231,15 +231,15 @@ void CDRProblem::time_iterate() template void CDRProblem::refine_mesh() { - parallel::distributed::SolutionTransfer - solution_transfer(dof_handler); - Vector estimated_error_per_cell(triangulation.n_active_cells()); KellyErrorEstimator::estimate (dof_handler, QGauss(fe.degree + 1), typename FunctionMap::type(), locally_relevant_solution, estimated_error_per_cell); - // Poor man's version of refine and coarsen + // This solver uses a crude refinement strategy where cells with relatively + // high errors are refined and cells with relatively low errors are + // coarsened. The maximum refinement level is capped to prevent run-away + // refinement. for (const auto &cell : triangulation.active_cell_iterators()) { if (std::abs(estimated_error_per_cell[cell->active_cell_index()]) >= 1e-3) @@ -261,9 +261,14 @@ void CDRProblem::refine_mesh() } } + // Transferring the solution between different grids is ultimately just a + // few function calls but they must be made in exactly the right order. + parallel::distributed::SolutionTransfer + solution_transfer(dof_handler); + triangulation.prepare_coarsening_and_refinement(); solution_transfer.prepare_for_coarsening_and_refinement - (locally_relevant_solution); + (locally_relevant_solution); triangulation.execute_coarsening_and_refinement(); setup_dofs(); -- 2.39.5