Skip to content

Commit

Permalink
Added a new parameter with the pXest_refinement_rule_type
Browse files Browse the repository at this point in the history
to the VoidOctreeDistributedDiscreteModel constructor that receives
the MPI ranks and the initial coarse model.

This is required for redistribution purposes, namely when we
redistribute a model from a subcommunicator to a larger communicator.
We now require to know the pXest_refinement_rule_type in those
processors in the larger communicator that do not belong to the
subcommunicator.
  • Loading branch information
amartinhuertas committed Aug 29, 2024
1 parent 9f47c6a commit 398d12c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[deps.Gridap]]
deps = ["AbstractTrees", "BSON", "BlockArrays", "Combinatorics", "DataStructures", "DocStringExtensions", "FastGaussQuadrature", "FileIO", "FillArrays", "ForwardDiff", "JLD2", "JSON", "LineSearches", "LinearAlgebra", "NLsolve", "NearestNeighbors", "PolynomialBases", "Preferences", "QuadGK", "Random", "SparseArrays", "SparseMatricesCSR", "StaticArrays", "Statistics", "Test", "WriteVTK"]
git-tree-sha1 = "efc1f4860ffcb06caf3b05716540f753fb75a5e8"
git-tree-sha1 = "df5ac52e9d1f14e2f5c773a82f0e14c665009b3e"
repo-rev = "facet_integration_non_conforming_meshes"
repo-url = "https://github.com/gridap/Gridap.jl"
uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
Expand Down
12 changes: 7 additions & 5 deletions src/OctreeDistributedDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mutable struct OctreeDistributedDiscreteModel{Dc,Dp,A,B,C,D,E,F} <: GridapDistri
ptr_pXest_connectivity,
ptr_pXest,
pXest_type::PXestType,
pXest_refinement_rule_type::Union{Nothing,PXestRefinementRuleType},
pXest_refinement_rule_type::PXestRefinementRuleType,
owns_ptr_pXest_connectivity::Bool,
gc_ref)

Expand Down Expand Up @@ -401,7 +401,7 @@ function OctreeDistributedDiscreteModel(parts::AbstractVector{<:Integer},
## HUGE WARNING: Shouldn't we provide here the complementary of parts
## instead of parts? Otherwise, when calling _free!(...)
## we cannot trust on parts.
return VoidOctreeDistributedDiscreteModel(coarse_model,parts)
return VoidOctreeDistributedDiscreteModel(coarse_model,parts,PXestUniformRefinementRuleType())
end
end

Expand All @@ -415,7 +415,9 @@ end

const VoidOctreeDistributedDiscreteModel{Dc,Dp,A,C,D} = OctreeDistributedDiscreteModel{Dc,Dp,A,Nothing,C,D,Nothing}

function VoidOctreeDistributedDiscreteModel(coarse_model::DiscreteModel{Dc,Dp},parts) where {Dc,Dp}
function VoidOctreeDistributedDiscreteModel(coarse_model::DiscreteModel{Dc,Dp},
parts,
pXest_refinement_rule_type::PXestRefinementRuleType) where {Dc,Dp}
ptr_pXest_connectivity = setup_pXest_connectivity(coarse_model)
OctreeDistributedDiscreteModel(Dc,
Dp,
Expand All @@ -426,7 +428,7 @@ function VoidOctreeDistributedDiscreteModel(coarse_model::DiscreteModel{Dc,Dp},p
ptr_pXest_connectivity,
nothing,
_dim_to_pXest_type(Dc),
nothing,
pXest_refinement_rule_type,
true,
nothing)
end
Expand All @@ -441,7 +443,7 @@ function VoidOctreeDistributedDiscreteModel(model::OctreeDistributedDiscreteMode
model.ptr_pXest_connectivity,
nothing,
_dim_to_pXest_type(Dc),
nothing,
model.pXest_refinement_rule_type,
false,
model)
end
Expand Down
8 changes: 5 additions & 3 deletions test/OctreeDistributedDiscreteModelsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ module OctreeDistributedDiscreteModelsTests
level_parts = generate_level_parts(ranks,num_parts_x_level)
coarse_model = CartesianDiscreteModel(domain,nc)
model = OctreeDistributedDiscreteModel(level_parts[2],coarse_model,1)
vmodel1 = GridapP4est.VoidOctreeDistributedDiscreteModel(model,ranks)
vmodel2 = GridapP4est.VoidOctreeDistributedDiscreteModel(coarse_model,ranks)

vmodel1 = GridapP4est.VoidOctreeDistributedDiscreteModel(model,
ranks)
vmodel2 = GridapP4est.VoidOctreeDistributedDiscreteModel(coarse_model,
ranks,
GridapP4est.PXestUniformRefinementRuleType())
# Refining and distributing
fmodel , rglue = refine(model,parts=level_parts[1])
dfmodel, dglue = redistribute(fmodel)
Expand Down

0 comments on commit 398d12c

Please sign in to comment.