Skip to content

Commit

Permalink
Additional bug-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amartinhuertas committed Mar 6, 2024
1 parent b6321f1 commit 54c111c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/OctreeDistributedDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1407,13 +1407,16 @@ function Gridap.Adaptivity.coarsen(model::OctreeDistributedDiscreteModel{Dc,Dp})

nc_glue=_create_conforming_model_non_conforming_glue(cmodel)

pXest_type = _dim_to_pXest_type(Dc)

c_octree_model = OctreeDistributedDiscreteModel(Dc,Dp,
model.parts,
cmodel,
nc_glue,
model.coarse_model,
model.ptr_pXest_connectivity,
ptr_new_pXest,
pXest_type,
PXestUniformRefinementRuleType(),
false,
model)
Expand Down Expand Up @@ -1638,7 +1641,7 @@ function _redistribute_parts_supset_parts_redistributed(
# "p4est_partition_cut_gloidx" function in the p4est library
psub=PArrays.getany(parts_redistributed_model)
Psub=GridapDistributed.num_parts(subset_comm)
first_global_quadrant=Int64((Float64(N)*Float64(psub-1))/(Float64(Psub)))
first_global_quadrant=Int64(floor((Float64(N)*Float64(psub-1))/(Float64(Psub))))
@assert first_global_quadrant>=0 && first_global_quadrant<N
else
first_global_quadrant=N
Expand Down
13 changes: 10 additions & 3 deletions src/PXestTypeMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -858,10 +858,9 @@ function setup_cell_prange(pXest_type::PXestType,
k=k+1
end
end
@debug "[$(MPI.Comm_rank(MPI.COMM_WORLD))] gho_to_glo=$(gho_to_glo) gho_to_own=$(gho_to_own)"
global_first_quadrant[part+1]-global_first_quadrant[part],global_first_quadrant[part]+1,gho_to_glo,gho_to_own
end |> tuple_of_arrays
ngids = global_first_quadrant[end]+1
ngids = global_first_quadrant[end]

partition=map(parts,noids,firstgid,gho_to_glo,gho_to_own) do part, noids, firstgid, gho_to_glo, gho_to_own
owner = part
Expand Down Expand Up @@ -2457,4 +2456,12 @@ function pXest_uniformly_coarsen!(::P8estType, ptr_pXest)
end
coarsen_fn_c=@cfunction($coarsen_fn_3d,Cint,(Ptr{p8est_t}, p4est_topidx_t, Ptr{Ptr{p8est_quadrant_t}}))
p8est_coarsen(ptr_pXest, Cint(0), coarsen_fn_c, C_NULL)
end
end

function pXest_partition_given!(::P4estType, ptr_pXest, new_num_cells_per_part)
p4est_partition_given(ptr_pXest, new_num_cells_per_part)
end

function pXest_partition_given!(::P8estType, ptr_pXest, new_num_cells_per_part)
p8est_partition_given(ptr_pXest, new_num_cells_per_part)
end
4 changes: 2 additions & 2 deletions test/OctreeDistributedDiscreteModelsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module OctreeDistributedDiscreteModelsTests
f_model_tasks_L2_back, dglueL1toL2 = redistribute(fmodel_tasks_L1,level_parts[2])

# Coarsening
model_back, glue = coarsen(f_model_tasks_L2_back)
model_back, glue = Gridap.Adaptivity.coarsen(f_model_tasks_L2_back)

if GridapDistributed.i_am_in(level_parts[2])
@test num_cells(model_back)==num_cells(model)
Expand All @@ -103,7 +103,7 @@ module OctreeDistributedDiscreteModelsTests
model = OctreeDistributedDiscreteModel(level_parts[1],coarse_model,3)
imodel = model
for i=1:3
omodel, glue = coarsen(imodel)
omodel, glue = Gridap.Adaptivity.coarsen(imodel)
imodel = omodel
end
@test num_cells(imodel) == prod(nc)
Expand Down

0 comments on commit 54c111c

Please sign in to comment.