Skip to content

Commit

Permalink
* pXest_copy calls now copies user data. Not copying user data
Browse files Browse the repository at this point in the history
  was causing double free or corruption.
* No need to count local num quadrants in the horizontal for p6est
  • Loading branch information
amartinhuertas committed Mar 16, 2024
1 parent 065d08a commit 2ec6f9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/AnisotropicallyAdapted3DDistributedDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ function _vertically_refine_coarsen_balance!(model::OctreeDistributedDiscreteMod
ptr_new_pXest
end

function vertically_adapt(model::OctreeDistributedDiscreteModel{Dc,Dp},
function vertically_adapt(model::OctreeDistributedDiscreteModel{3,3},
refinement_and_coarsening_flags::MPIArray{<:Vector{<:Integer}};
parts=nothing) where {Dc,Dp}
parts=nothing)

Gridap.Helpers.@notimplementedif parts!=nothing

Expand Down Expand Up @@ -111,7 +111,7 @@ function vertically_adapt(model::OctreeDistributedDiscreteModel{Dc,Dp},
Gridap.Adaptivity.AdaptedDiscreteModel(fmodel,model,glue)
end
fmodel = GridapDistributed.GenericDistributedDiscreteModel(adaptive_models,get_cell_gids(fmodel))
ref_model = OctreeDistributedDiscreteModel(Dc,Dp,
ref_model = OctreeDistributedDiscreteModel(3,3,
model.parts,
fmodel,
non_conforming_glue,
Expand Down Expand Up @@ -578,13 +578,7 @@ function num_locally_owned_columns(octree_model)
@assert octree_model.pXest_type==P6estType()
map(octree_model.parts) do _
pXest=octree_model.ptr_pXest[]
num_cols = 0
num_trees = Cint(pXest.columns[].connectivity[].num_trees)
for itree = 0:num_trees-1
tree = pXest_tree_array_index(octree_model.pXest_type,pXest,itree)[]
num_cols += tree.quadrants.elem_count
end
num_cols
pXest.columns[].local_num_quadrants
end
end

Expand Down Expand Up @@ -652,15 +646,20 @@ function horizontally_adapt(model::OctreeDistributedDiscreteModel{Dc,Dp},
pXest_lnodes_destroy(model.pXest_type,ptr_pXest_lnodes)
pXest_refinement_rule_type = PXestHorizontalRefinementRuleType()

extruded_ref_coarsen_flags=map(partition(get_cell_gids(model)),refinement_and_coarsening_flags) do indices, flags

extruded_ref_coarsen_flags=map(partition(get_cell_gids(model)),_refinement_and_coarsening_flags) do indices, flags
similar(flags, length(local_to_global(indices)))
end



_extrude_refinement_and_coarsening_flags!(extruded_ref_coarsen_flags,
refinement_and_coarsening_flags,
_refinement_and_coarsening_flags,
model.ptr_pXest,
ptr_new_pXest)



stride = pXest_stride_among_children(model.pXest_type,pXest_refinement_rule_type,model.ptr_pXest)

adaptivity_glue = _compute_fine_to_coarse_model_glue(model.pXest_type,
Expand Down
6 changes: 3 additions & 3 deletions src/PXestTypeMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ function pXest_coarsen!(::P8estType, ptr_pXest, coarsen_fn_c)
end

function pXest_copy(::P4estType, ptr_pXest)
p4est_copy(ptr_pXest, Cint(0))
p4est_copy(ptr_pXest, Cint(1))
end

function pXest_copy(::P6estType, ptr_pXest)
p6est_copy(ptr_pXest, Cint(0))
p6est_copy(ptr_pXest, Cint(1))
end

function pXest_copy(::P8estType, ptr_pXest)
p8est_copy(ptr_pXest, Cint(0))
p8est_copy(ptr_pXest, Cint(1))
end

function pXest_balance!(::P4estType, ptr_pXest; k_2_1_balance=0)
Expand Down

0 comments on commit 2ec6f9e

Please sign in to comment.