From 398d12c2059b460bed02052a2053a5b606a7c0bc Mon Sep 17 00:00:00 2001 From: "Alberto F. Martin" Date: Thu, 29 Aug 2024 20:19:06 +1000 Subject: [PATCH] Added a new parameter with the pXest_refinement_rule_type 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. --- Manifest.toml | 2 +- src/OctreeDistributedDiscreteModels.jl | 12 +++++++----- test/OctreeDistributedDiscreteModelsTests.jl | 8 +++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 55d6949..4535647 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -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" diff --git a/src/OctreeDistributedDiscreteModels.jl b/src/OctreeDistributedDiscreteModels.jl index 5671330..6a7bd72 100644 --- a/src/OctreeDistributedDiscreteModels.jl +++ b/src/OctreeDistributedDiscreteModels.jl @@ -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) @@ -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 @@ -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, @@ -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 @@ -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 diff --git a/test/OctreeDistributedDiscreteModelsTests.jl b/test/OctreeDistributedDiscreteModelsTests.jl index c6446dd..30e0f90 100644 --- a/test/OctreeDistributedDiscreteModelsTests.jl +++ b/test/OctreeDistributedDiscreteModelsTests.jl @@ -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)