From f3ee0dc99eb67ac94d0d009c0b9235b904c267b1 Mon Sep 17 00:00:00 2001 From: "Alberto F. Martin" Date: Sat, 23 Sep 2023 11:05:08 +1000 Subject: [PATCH] Bug-fixing FixedFractionAdaptiveMarkingStrategy --- src/AdaptivityFlagsMarkingStrategies.jl | 14 +++++++------- test/AdaptivityFlagsMarkingStrategiesTests.jl | 6 +----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/AdaptivityFlagsMarkingStrategies.jl b/src/AdaptivityFlagsMarkingStrategies.jl index 367e338..7685d4d 100644 --- a/src/AdaptivityFlagsMarkingStrategies.jl +++ b/src/AdaptivityFlagsMarkingStrategies.jl @@ -47,16 +47,16 @@ function _compute_thresholds(error_indicators, error_indicator.*error_indicator end - ref_sq_min_estimate = map(sq_error_indicators, num_owned_cells) do sq_error_indicator, num_owned_cells - minimum(view(sq_error_indicator,1:num_owned_cells)) + ref_min_estimate = map(sq_error_indicators, num_owned_cells) do sq_error_indicator, num_owned_cells + sqrt(minimum(view(sq_error_indicator,1:num_owned_cells))) end - ref_sq_max_estimate = map(sq_error_indicators, num_owned_cells) do sq_error_indicator, num_owned_cells - maximum(view(sq_error_indicator,1:num_owned_cells)) + ref_max_estimate = map(sq_error_indicators, num_owned_cells) do sq_error_indicator, num_owned_cells + sqrt(maximum(view(sq_error_indicator,1:num_owned_cells))) end - ref_min_estimate=reduction(min,ref_sq_min_estimate,init=typemax(eltype(ref_sq_min_estimate))) - ref_max_estimate=reduction(max,ref_sq_max_estimate,init=typemin(eltype(ref_sq_max_estimate))) + ref_min_estimate=reduction(min,ref_min_estimate,init=typemax(eltype(ref_min_estimate))) + ref_max_estimate=reduction(max,ref_max_estimate,init=typemin(eltype(ref_max_estimate))) # We compute refinement thresholds by bisection of the interval spanned by # the smallest and largest error indicator. this leads to a small problem: @@ -176,7 +176,7 @@ function _compute_thresholds(error_indicators, current_num_cells_to_be_refined = 0 if (!refinement_converged) for i=1:num_owned_cells - if (sq_error_indicators[i]>=ref_split_estimate*ref_split_estimate) + if (sq_error_indicators[i]>ref_split_estimate*ref_split_estimate) current_num_cells_to_be_refined += 1 end end diff --git a/test/AdaptivityFlagsMarkingStrategiesTests.jl b/test/AdaptivityFlagsMarkingStrategiesTests.jl index 2f2da3f..afa1ad8 100644 --- a/test/AdaptivityFlagsMarkingStrategiesTests.jl +++ b/test/AdaptivityFlagsMarkingStrategiesTests.jl @@ -13,7 +13,7 @@ module AdaptivityFlagsMarkingStrategiesTests dmodel::OctreeDistributedDiscreteModel{Dc}, order) where Dc - refinement_fraction=0.1 + refinement_fraction=0.2 coarsening_fraction=0.05 cell_partition = get_cell_gids(dmodel) @@ -41,10 +41,6 @@ module AdaptivityFlagsMarkingStrategiesTests sqrt.(get_array(dc)) end - # error_indicators = map(ranks,partition(cell_partition)) do rank, partition - # rand(local_length(partition)) - # end - ref_coarse_flags=map(ranks,partition(get_cell_gids(dmodel.dmodel))) do rank,indices flags=zeros(Cint,length(indices)) flags.=nothing_flag