]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow refine_fraction+coarsen_fraction to be slightly larger than 1.0.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 19 Jun 2018 19:13:12 +0000 (13:13 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 19 Jun 2018 21:37:40 +0000 (15:37 -0600)
This allows using 0.6 and 0.4, for example, when refining and coarsening meshes.

source/grid/grid_refinement.cc

index 8ee45e6cf1587333b4645c12ab446c2f6f442960..785679955304fbe87ba73a078db8d5621f9d07ac 100644 (file)
@@ -105,6 +105,8 @@ GridRefinement::coarsen(Triangulation<dim, spacedim> &tria,
         cell->set_coarsen_flag();
 }
 
+
+
 template <int dim>
 std::pair<double, double>
 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<double>::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 <int dim, typename Number, int spacedim>
 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<double>::epsilon(),
+         ExcInvalidParameterValue());
   Assert(criteria.is_non_negative(), ExcNegativeCriteria());
 
   const std::pair<double, double> 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<double>::epsilon(),
+         ExcInvalidParameterValue());
   Assert(criteria.is_non_negative(), ExcNegativeCriteria());
 
   // let tmp be the cellwise square of the

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.