Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Jul 11, 2024
1 parent 8fdf735 commit e0fa018
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
11 changes: 7 additions & 4 deletions src/Adaptivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ function refine_local_models(
end

# Select fine cells we want to keep
Df = Dc-1 # Dimension used to find neighboring cells\
Df = 0 # Dimension used to find neighboring cells
f_own_or_ghost_ids, f_own_ids = map(cgids,cmodels,fmodels) do cgids,cmodel,fmodel
glue = get_adaptivity_glue(fmodel)
f2c_map = glue.n2o_faces_map[Dc+1]
Expand Down Expand Up @@ -1068,7 +1068,10 @@ function refine_cell_gids(
# We finally can create the global numeration of the fine cells by piecing together:
# 1. The (local ids,global ids) of the owned fine cells
# 2. The (owners,local ids,global ids) of the ghost fine cells
fgids = map(ranks,f_own_to_local,own_fgids,lids_snd,child_gids_snd) do rank, own_lids, own_gids, ghost_lids, ghost_gids
fgids = map(
ranks,f_own_to_local,own_fgids,parts_snd,lids_snd,child_gids_snd
) do rank,own_lids,own_gids,nbors,ghost_lids,ghost_gids

own2global = own_to_global(own_gids)

n_nbors = length(ghost_lids)
Expand All @@ -1084,8 +1087,8 @@ function refine_cell_gids(
end

# Ghost cells
for nbor in 1:n_nbors
for i in ghost_lids.ptrs[nbor]:ghost_lids.ptrs[nbor+1]-1
for (n,nbor) in enumerate(nbors)
for i in ghost_lids.ptrs[n]:ghost_lids.ptrs[n+1]-1
lid = ghost_lids.data[i]
gid = ghost_gids.data[i]
local2global[lid] = gid
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ end
function Geometry.simplexify(model::DistributedDiscreteModel)
_model = UnstructuredDiscreteModel(model)
ref_model = refine(_model, refinement_method = "simplexify")
return Adaptivity.get_model(ref_model)
return UnstructuredDiscreteModel(Adaptivity.get_model(ref_model))
end

# Triangulation
Expand Down
31 changes: 20 additions & 11 deletions test/AdaptivityUnstructuredTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using GridapDistributed: i_am_in
function test_adaptivity(ranks,cmodel,fmodel)
if i_am_in(ranks)
sol(x) = sum(x)
order = 3
order = 1
qorder = 2*order
reffe = ReferenceFE(lagrangian,Float64,order)
amodel = fmodel
Expand Down Expand Up @@ -60,22 +60,31 @@ end
function main(distribute,parts,ncells)
ranks = distribute(LinearIndices((prod(parts),)))

parent = UnstructuredDiscreteModel(
CartesianDiscreteModel(ranks,parts,(0,1,0,1),ncells)
Dc = length(ncells)
domain = (Dc == 2) ? (0,1,0,1) : (0,1,0,1,0,1)
parent1 = UnstructuredDiscreteModel(
CartesianDiscreteModel(ranks,parts,domain,ncells)
)

child1 = refine(parent, refinement_method = "red_green" )
test_adaptivity(ranks,parent,child1)
i_am_main(ranks) && println("UnstructuredAdaptivityTests: red_green")
child1 = refine(parent1, refinement_method = "red_green" )
test_adaptivity(ranks,parent1,child1)

child2 = refine(parent, refinement_method = "nvb" )
test_adaptivity(ranks,parent,child2)
i_am_main(ranks) && println("UnstructuredAdaptivityTests: simplexify")
child2 = refine(parent1, refinement_method = "simplexify" )
test_adaptivity(ranks,parent1,child2)

child3 = refine(parent, refinement_method = "barycentric" )
test_adaptivity(ranks,parent,child3)
parent2 = simplexify(parent1)

child4 = refine(parent, refinement_method = "simplexify" )
test_adaptivity(ranks,parent,child4)
if Dc == 2
i_am_main(ranks) && println("UnstructuredAdaptivityTests: nvb")
child3 = refine(parent2, refinement_method = "nvb" )
test_adaptivity(ranks,parent2,child3)
end

i_am_main(ranks) && println("UnstructuredAdaptivityTests: barycentric")
child4 = refine(parent2, refinement_method = "barycentric" )
test_adaptivity(ranks,parent2,child4)
end

function main(distribute)
Expand Down

0 comments on commit e0fa018

Please sign in to comment.