From: Wolfgang Bangerth Date: Tue, 19 Jun 2018 19:13:12 +0000 (-0600) Subject: Allow refine_fraction+coarsen_fraction to be slightly larger than 1.0. X-Git-Tag: v9.1.0-rc1~1015^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832aa41018b53109452c0313672d7f72f8adfa87;p=dealii.git 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. --- 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