Skip to content

Commit

Permalink
Bug-fixing FixedFractionAdaptiveMarkingStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
amartinhuertas committed Sep 23, 2023
1 parent 385e9f4 commit f3ee0dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/AdaptivityFlagsMarkingStrategies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions test/AdaptivityFlagsMarkingStrategiesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3ee0dc

Please sign in to comment.