diff --git a/src/Adaptivity.jl b/src/Adaptivity.jl index dc8b40e..c2caba0 100644 --- a/src/Adaptivity.jl +++ b/src/Adaptivity.jl @@ -539,6 +539,9 @@ function redistribute( end function get_cartesian_owners(gids,nparts,ncells) + # This is currently O(sqrt(np)), but I believe we could make it + # O(ln(np)) if we ensured the search is sorted. Even faster if we sort + # the gids first, which progressively reduces the number of ranges to search. ranges = map(nparts,ncells) do np, nc map(p -> PartitionedArrays.local_range(p,np,nc,false,false), 1:np) end diff --git a/test/CartesianAdaptivityTests.jl b/test/CartesianAdaptivityTests.jl index 70a046d..1921b50 100644 --- a/test/CartesianAdaptivityTests.jl +++ b/test/CartesianAdaptivityTests.jl @@ -121,7 +121,7 @@ end ############################################################################################ -function main(distribute) +function main(distribute,ncells,isperiodic) fine_parts = (2,2) fine_ranks = distribute(LinearIndices((4,))) @@ -130,7 +130,7 @@ function main(distribute) # Create models and glues if i_am_in(coarse_ranks) - parent = CartesianDiscreteModel(coarse_ranks,coarse_parts,(0,1,0,1),(4,4)) + parent = CartesianDiscreteModel(coarse_ranks,coarse_parts,(0,1,0,1),ncells;isperiodic) child = refine(parent,(2,2)) coarse_adaptivity_glue = get_adaptivity_glue(child) else @@ -153,4 +153,11 @@ function main(distribute) return end +function main(distribute) + main(distribute,(8,8),(false,false)) + main(distribute,(8,8),(true,false)) + main(distribute,(4,4),(false,true)) + main(distribute,(4,4),(true,true)) +end + end # module AdaptivityTests \ No newline at end of file