From: Marc Fehling Date: Tue, 28 Apr 2020 13:41:32 +0000 (+0200) Subject: Revisited adjust_interesting_range for parallel::distributed::GridRefinement. X-Git-Tag: v9.2.0-rc2~6^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=422b5ea593c67b2c5d997af778264562307944d6;p=dealii.git Revisited adjust_interesting_range for parallel::distributed::GridRefinement. --- diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index 3ed69a4ed5..2332c92d9d 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -134,18 +134,30 @@ namespace { Assert(interesting_range[0] <= interesting_range[1], ExcInternalError()); - Assert(interesting_range[0] >= 0, ExcInternalError()); - - // adjust the lower bound only if the end point is not equal to zero, - // otherwise it could happen, that the result becomes negative if (interesting_range[0] > 0) - interesting_range[0] *= 0.99; - - if (interesting_range[1] > 0) - interesting_range[1] *= 1.01; + { + // In this case, we calculate the first interval split point `m` in the + // `compute_threshold` functions in the optimized way: We exploit that + // the logarithms of all criteria are more uniformly distributed than + // their actual values, i.e. m=sqrt(b*e). + // + // Both factors will modify the split point only slightly by a factor of + // sqrt(1.01*0.99) = sqrt(0.9999) ~ 0.9950. + interesting_range[0] *= 0.99; + interesting_range[1] *= 1.01; + } else - interesting_range[1] += - 0.01 * (interesting_range[1] - interesting_range[0]); + { + // In all other cases, we begin with an the arithmetic mean as the + // standard interval split point, i.e. m=(b+e)/2. + // + // Both increments will add up to zero when calculating the initial + // split point in the `compute_threshold` functions. + const double difference = + std::abs(interesting_range[1] - interesting_range[0]); + interesting_range[0] -= 0.01 * difference; + interesting_range[1] += 0.01 * difference; + } } @@ -468,8 +480,8 @@ namespace parallel tria.n_global_active_cells()), mpi_communicator); - // compute bottom threshold only if necessary. otherwise use a threshold - // lower than the smallest value we have locally + // compute bottom threshold only if necessary. otherwise use the lowest + // threshold possible if (adjusted_fractions.second > 0) bottom_threshold = dealii::internal::parallel::distributed:: GridRefinement::RefineAndCoarsenFixedNumber::compute_threshold( @@ -480,11 +492,7 @@ namespace parallel tria.n_global_active_cells())), mpi_communicator); else - { - bottom_threshold = - *std::min_element(criteria.begin(), criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } + bottom_threshold = std::numeric_limits::lowest(); // now refine the mesh mark_cells(tria, criteria, top_threshold, bottom_threshold); @@ -535,8 +543,9 @@ namespace parallel global_min_and_max, top_fraction_of_error * total_error, mpi_communicator); - // compute bottom threshold only if necessary. otherwise use a threshold - // lower than the smallest value we have locally + + // compute bottom threshold only if necessary. otherwise use the lowest + // threshold possible if (bottom_fraction_of_error > 0) bottom_threshold = dealii::internal::parallel::distributed:: GridRefinement::RefineAndCoarsenFixedFraction::compute_threshold( @@ -545,11 +554,7 @@ namespace parallel (1. - bottom_fraction_of_error) * total_error, mpi_communicator); else - { - bottom_threshold = - *std::min_element(criteria.begin(), criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } + bottom_threshold = std::numeric_limits::lowest(); // now refine the mesh mark_cells(tria, criteria, top_threshold, bottom_threshold); diff --git a/tests/mpi/tria_ghost_owners_01.mpirun=7.with_p4est=true.output b/tests/mpi/tria_ghost_owners_01.mpirun=7.with_p4est=true.output index 30c981bfb6..7c9238b44b 100644 --- a/tests/mpi/tria_ghost_owners_01.mpirun=7.with_p4est=true.output +++ b/tests/mpi/tria_ghost_owners_01.mpirun=7.with_p4est=true.output @@ -31,7 +31,7 @@ DEAL:0:3d::total active cells = 11702 DEAL:0:3d::* cycle 3 DEAL:0:3d::ghost owners: 1 2 DEAL:0:3d::level ghost owners: 1 2 -DEAL:0:3d::total active cells = 37868 +DEAL:0:3d::total active cells = 37833 DEAL:0:3d::OK DEAL:1:2d::* cycle 0 diff --git a/tests/mpi/tria_ghost_owners_02.mpirun=11.with_p4est=true.output b/tests/mpi/tria_ghost_owners_02.mpirun=11.with_p4est=true.output index 59ffd4cb17..bd14c173a8 100644 --- a/tests/mpi/tria_ghost_owners_02.mpirun=11.with_p4est=true.output +++ b/tests/mpi/tria_ghost_owners_02.mpirun=11.with_p4est=true.output @@ -6,15 +6,15 @@ DEAL:0:2d::total active cells = 124 DEAL:0:2d::* cycle 1 DEAL:0:2d::ghost owners: 1 2 3 5 6 DEAL:0:2d::level ghost owners: 1 2 3 5 6 8 -DEAL:0:2d::total active cells = 169 +DEAL:0:2d::total active cells = 496 DEAL:0:2d::* cycle 2 -DEAL:0:2d::ghost owners: 1 2 -DEAL:0:2d::level ghost owners: 1 2 5 7 -DEAL:0:2d::total active cells = 190 +DEAL:0:2d::ghost owners: 1 2 3 5 +DEAL:0:2d::level ghost owners: 1 2 3 5 6 8 +DEAL:0:2d::total active cells = 733 DEAL:0:2d::* cycle 3 -DEAL:0:2d::ghost owners: 1 -DEAL:0:2d::level ghost owners: 1 2 3 6 9 -DEAL:0:2d::total active cells = 304 +DEAL:0:2d::ghost owners: 1 2 +DEAL:0:2d::level ghost owners: 1 2 3 5 8 +DEAL:0:2d::total active cells = 1288 DEAL:0:2d::OK DEAL:0:3d::* cycle 0 DEAL:0:3d::ghost owners: 2 3 4 6 7 8 10 @@ -41,11 +41,11 @@ DEAL:1:2d::* cycle 1 DEAL:1:2d::ghost owners: 0 2 3 5 6 8 DEAL:1:2d::level ghost owners: 0 2 3 5 6 8 DEAL:1:2d::* cycle 2 -DEAL:1:2d::ghost owners: 0 2 4 -DEAL:1:2d::level ghost owners: 0 2 4 5 +DEAL:1:2d::ghost owners: 0 2 3 5 6 8 +DEAL:1:2d::level ghost owners: 0 2 3 5 6 8 DEAL:1:2d::* cycle 3 -DEAL:1:2d::ghost owners: 0 2 3 5 -DEAL:1:2d::level ghost owners: 0 2 3 5 +DEAL:1:2d::ghost owners: 0 2 3 +DEAL:1:2d::level ghost owners: 0 2 3 5 6 DEAL:1:2d::OK DEAL:1:3d::* cycle 0 DEAL:1:3d::ghost owners: @@ -69,11 +69,11 @@ DEAL:2:2d::* cycle 1 DEAL:2:2d::ghost owners: 0 1 3 DEAL:2:2d::level ghost owners: 0 1 3 5 8 DEAL:2:2d::* cycle 2 -DEAL:2:2d::ghost owners: 0 1 3 4 5 7 -DEAL:2:2d::level ghost owners: 0 1 3 4 5 7 +DEAL:2:2d::ghost owners: 0 1 3 +DEAL:2:2d::level ghost owners: 0 1 3 DEAL:2:2d::* cycle 3 -DEAL:2:2d::ghost owners: 1 3 6 7 -DEAL:2:2d::level ghost owners: 0 1 3 5 6 7 9 +DEAL:2:2d::ghost owners: 0 1 3 4 5 6 8 +DEAL:2:2d::level ghost owners: 0 1 3 4 5 6 8 DEAL:2:2d::OK DEAL:2:3d::* cycle 0 DEAL:2:3d::ghost owners: 0 3 4 6 7 8 10 @@ -97,11 +97,11 @@ DEAL:3:2d::* cycle 1 DEAL:3:2d::ghost owners: 0 1 2 4 5 6 8 9 DEAL:3:2d::level ghost owners: 0 1 2 4 5 6 8 9 DEAL:3:2d::* cycle 2 -DEAL:3:2d::ghost owners: 2 4 -DEAL:3:2d::level ghost owners: 2 4 +DEAL:3:2d::ghost owners: 0 1 2 4 6 8 9 +DEAL:3:2d::level ghost owners: 0 1 2 4 6 8 9 DEAL:3:2d::* cycle 3 -DEAL:3:2d::ghost owners: 1 2 4 5 7 9 -DEAL:3:2d::level ghost owners: 0 1 2 4 5 6 7 9 +DEAL:3:2d::ghost owners: 1 2 4 5 +DEAL:3:2d::level ghost owners: 0 1 2 4 5 6 8 9 DEAL:3:2d::OK DEAL:3:3d::* cycle 0 DEAL:3:3d::ghost owners: 0 2 4 6 7 8 10 @@ -125,11 +125,11 @@ DEAL:4:2d::* cycle 1 DEAL:4:2d::ghost owners: 3 5 8 9 DEAL:4:2d::level ghost owners: 3 5 8 9 DEAL:4:2d::* cycle 2 -DEAL:4:2d::ghost owners: 1 2 3 5 7 8 -DEAL:4:2d::level ghost owners: 1 2 3 5 7 8 +DEAL:4:2d::ghost owners: 3 5 8 9 +DEAL:4:2d::level ghost owners: 3 5 8 9 DEAL:4:2d::* cycle 3 -DEAL:4:2d::ghost owners: 3 5 6 -DEAL:4:2d::level ghost owners: 3 5 6 +DEAL:4:2d::ghost owners: 2 3 5 6 8 9 +DEAL:4:2d::level ghost owners: 2 3 5 6 8 9 DEAL:4:2d::OK DEAL:4:3d::* cycle 0 DEAL:4:3d::ghost owners: 0 2 3 6 7 8 10 @@ -153,11 +153,11 @@ DEAL:5:2d::* cycle 1 DEAL:5:2d::ghost owners: 0 1 3 4 6 7 9 DEAL:5:2d::level ghost owners: 0 1 2 3 4 6 7 8 9 DEAL:5:2d::* cycle 2 -DEAL:5:2d::ghost owners: 2 4 6 7 8 -DEAL:5:2d::level ghost owners: 0 1 2 4 6 7 8 9 +DEAL:5:2d::ghost owners: 0 1 4 6 7 9 +DEAL:5:2d::level ghost owners: 0 1 4 6 7 8 9 DEAL:5:2d::* cycle 3 -DEAL:5:2d::ghost owners: 1 3 4 6 7 9 -DEAL:5:2d::level ghost owners: 1 2 3 4 6 7 9 10 +DEAL:5:2d::ghost owners: 2 3 4 6 8 9 +DEAL:5:2d::level ghost owners: 0 1 2 3 4 6 7 8 9 DEAL:5:2d::OK DEAL:5:3d::* cycle 0 DEAL:5:3d::ghost owners: @@ -181,11 +181,11 @@ DEAL:6:2d::* cycle 1 DEAL:6:2d::ghost owners: 0 1 3 5 7 8 DEAL:6:2d::level ghost owners: 0 1 3 5 7 8 10 DEAL:6:2d::* cycle 2 -DEAL:6:2d::ghost owners: 5 7 8 9 -DEAL:6:2d::level ghost owners: 5 7 8 9 +DEAL:6:2d::ghost owners: 1 3 5 7 8 10 +DEAL:6:2d::level ghost owners: 0 1 3 5 7 8 10 DEAL:6:2d::* cycle 3 -DEAL:6:2d::ghost owners: 2 4 5 7 9 10 -DEAL:6:2d::level ghost owners: 0 2 3 4 5 7 8 9 10 +DEAL:6:2d::ghost owners: 2 4 5 7 8 9 +DEAL:6:2d::level ghost owners: 1 2 3 4 5 7 8 9 DEAL:6:2d::OK DEAL:6:3d::* cycle 0 DEAL:6:3d::ghost owners: 0 2 3 4 7 8 10 @@ -209,11 +209,11 @@ DEAL:7:2d::* cycle 1 DEAL:7:2d::ghost owners: 5 6 8 10 DEAL:7:2d::level ghost owners: 5 6 8 10 DEAL:7:2d::* cycle 2 -DEAL:7:2d::ghost owners: 2 4 5 6 8 9 -DEAL:7:2d::level ghost owners: 0 2 4 5 6 8 9 10 +DEAL:7:2d::ghost owners: 5 6 8 +DEAL:7:2d::level ghost owners: 5 6 8 10 DEAL:7:2d::* cycle 3 -DEAL:7:2d::ghost owners: 2 3 5 6 8 9 -DEAL:7:2d::level ghost owners: 2 3 5 6 8 9 10 +DEAL:7:2d::ghost owners: 6 8 9 +DEAL:7:2d::level ghost owners: 5 6 8 9 DEAL:7:2d::OK DEAL:7:3d::* cycle 0 DEAL:7:3d::ghost owners: 0 2 3 4 6 8 10 @@ -237,11 +237,11 @@ DEAL:8:2d::* cycle 1 DEAL:8:2d::ghost owners: 1 3 4 6 7 9 10 DEAL:8:2d::level ghost owners: 0 1 2 3 4 5 6 7 9 10 DEAL:8:2d::* cycle 2 -DEAL:8:2d::ghost owners: 4 5 6 7 9 10 -DEAL:8:2d::level ghost owners: 4 5 6 7 9 10 +DEAL:8:2d::ghost owners: 1 3 4 6 7 9 10 +DEAL:8:2d::level ghost owners: 0 1 3 4 5 6 7 9 10 DEAL:8:2d::* cycle 3 -DEAL:8:2d::ghost owners: 7 9 10 -DEAL:8:2d::level ghost owners: 6 7 9 10 +DEAL:8:2d::ghost owners: 2 4 5 6 7 9 10 +DEAL:8:2d::level ghost owners: 0 2 3 4 5 6 7 9 10 DEAL:8:2d::OK DEAL:8:3d::* cycle 0 DEAL:8:3d::ghost owners: 0 2 3 4 6 7 10 @@ -265,11 +265,11 @@ DEAL:9:2d::* cycle 1 DEAL:9:2d::ghost owners: 3 4 5 8 10 DEAL:9:2d::level ghost owners: 3 4 5 8 10 DEAL:9:2d::* cycle 2 -DEAL:9:2d::ghost owners: 6 7 8 10 -DEAL:9:2d::level ghost owners: 5 6 7 8 10 +DEAL:9:2d::ghost owners: 3 4 5 8 10 +DEAL:9:2d::level ghost owners: 3 4 5 8 10 DEAL:9:2d::* cycle 3 -DEAL:9:2d::ghost owners: 3 5 6 7 8 10 -DEAL:9:2d::level ghost owners: 0 2 3 5 6 7 8 10 +DEAL:9:2d::ghost owners: 4 5 6 7 8 10 +DEAL:9:2d::level ghost owners: 3 4 5 6 7 8 10 DEAL:9:2d::OK DEAL:9:3d::* cycle 0 DEAL:9:3d::ghost owners: @@ -293,11 +293,11 @@ DEAL:10:2d::* cycle 1 DEAL:10:2d::ghost owners: 7 8 9 DEAL:10:2d::level ghost owners: 6 7 8 9 DEAL:10:2d::* cycle 2 -DEAL:10:2d::ghost owners: 8 9 -DEAL:10:2d::level ghost owners: 7 8 9 -DEAL:10:2d::* cycle 3 DEAL:10:2d::ghost owners: 6 8 9 -DEAL:10:2d::level ghost owners: 5 6 7 8 9 +DEAL:10:2d::level ghost owners: 6 7 8 9 +DEAL:10:2d::* cycle 3 +DEAL:10:2d::ghost owners: 8 9 +DEAL:10:2d::level ghost owners: 8 9 DEAL:10:2d::OK DEAL:10:3d::* cycle 0 DEAL:10:3d::ghost owners: 0 2 3 4 6 7 8