From 832aa41018b53109452c0313672d7f72f8adfa87 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 19 Jun 2018 13:13:12 -0600 Subject: [PATCH] Allow refine_fraction+coarsen_fraction to be slightly larger than 1.0. This allows using 0.6 and 0.4, for example, when refining and coarsening meshes. --- source/grid/grid_refinement.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/grid/grid_refinement.cc b/source/grid/grid_refinement.cc index 8ee45e6cf1..7856799553 100644 --- a/source/grid/grid_refinement.cc +++ b/source/grid/grid_refinement.cc @@ -105,6 +105,8 @@ GridRefinement::coarsen(Triangulation &tria, cell->set_coarsen_flag(); } + + template std::pair GridRefinement::adjust_refine_and_coarsen_number_fraction( @@ -117,7 +119,9 @@ GridRefinement::adjust_refine_and_coarsen_number_fraction( Assert(top_fraction <= 1, ExcInvalidParameterValue()); Assert(bottom_fraction >= 0, ExcInvalidParameterValue()); Assert(bottom_fraction <= 1, ExcInvalidParameterValue()); - Assert(top_fraction + bottom_fraction <= 1, ExcInvalidParameterValue()); + Assert(top_fraction + bottom_fraction <= + 1 + 10 * std::numeric_limits::epsilon(), + ExcInvalidParameterValue()); double refine_cells = current_n_cells * top_fraction; double coarsen_cells = current_n_cells * bottom_fraction; @@ -184,6 +188,8 @@ GridRefinement::adjust_refine_and_coarsen_number_fraction( return (adjusted_fractions); } + + template void GridRefinement::refine_and_coarsen_fixed_number( @@ -199,7 +205,9 @@ GridRefinement::refine_and_coarsen_fixed_number( ExcInvalidParameterValue()); Assert((bottom_fraction >= 0) && (bottom_fraction <= 1), ExcInvalidParameterValue()); - Assert(top_fraction + bottom_fraction <= 1, ExcInvalidParameterValue()); + Assert(top_fraction + bottom_fraction <= + 1 + 10 * std::numeric_limits::epsilon(), + ExcInvalidParameterValue()); Assert(criteria.is_non_negative(), ExcNegativeCriteria()); const std::pair adjusted_fractions = @@ -265,7 +273,9 @@ GridRefinement::refine_and_coarsen_fixed_fraction( ExcInvalidParameterValue()); Assert((bottom_fraction >= 0) && (bottom_fraction <= 1), ExcInvalidParameterValue()); - Assert(top_fraction + bottom_fraction <= 1, ExcInvalidParameterValue()); + Assert(top_fraction + bottom_fraction <= + 1 + 10 * std::numeric_limits::epsilon(), + ExcInvalidParameterValue()); Assert(criteria.is_non_negative(), ExcNegativeCriteria()); // let tmp be the cellwise square of the -- 2.39.5