@@ -35,6 +35,45 @@ function are_equal(a1::PVector,a2::PVector)
3535 are_equal (own_values (a1),own_values (a2))
3636end
3737
38+ function test_redistribution_new (redist_model, model, redist_space, space, glue)
39+
40+ new_data_ids = partition (get_free_dof_ids (redist_space))
41+ new_cell_to_new_lid = map (get_cell_dof_ids,local_views (redist_space))
42+
43+ if ! isnothing (space)
44+ old_data_ids = partition (get_free_dof_ids (space))
45+ old_cell_to_old_lid = map (get_cell_dof_ids,local_views (space))
46+ else
47+ old_data_ids, old_cell_to_old_lid = nothing , nothing , nothing
48+ end
49+
50+ old_ids, red_old_ids = GridapDistributed. redistribute_indices (
51+ old_data_ids, old_cell_to_old_lid, new_cell_to_new_lid, redist_model, glue; reverse= false ,
52+ )
53+
54+ new_ids, red_new_ids = GridapDistributed. redistribute_indices (
55+ new_data_ids, new_cell_to_new_lid, old_cell_to_old_lid, model, glue; reverse= true ,
56+ )
57+
58+ # Old -> New -> Old
59+ x_old = consistent! (prandn (old_ids)) |> fetch
60+ x_old_red = redistribute (x_old, red_old_ids) |> fetch
61+
62+ x_new = PVector (partition (x_old_red), new_ids)
63+ x_new_red = redistribute (x_new, red_new_ids) |> fetch
64+ @test are_equal (partition (x_old), partition (x_new_red))
65+
66+ # New -> Old -> New
67+ x_new = consistent! (prandn (new_ids)) |> fetch
68+ x_new_red = redistribute (x_new, red_new_ids) |> fetch
69+
70+ x_old = PVector (partition (x_new_red), old_ids)
71+ x_old_red = redistribute (x_old, red_old_ids) |> fetch
72+ @test are_equal (partition (x_new), partition (x_old_red))
73+
74+ return true
75+ end
76+
3877function test_redistribution (coarse_ranks, fine_ranks, model, redist_model, redist_glue)
3978 sol (x) = cos (2 π* x[1 ]) + cos (2 π* x[2 ]) # We need this for periodic tests to work
4079 reffe = ReferenceFE (lagrangian,Float64,1 )
@@ -77,6 +116,9 @@ function test_redistribution(coarse_ranks, fine_ranks, model, redist_model, redi
77116 @test are_equal (free_values,tmp_free_values)
78117 end
79118
119+ # New machinery
120+ test_redistribution_new (redist_model, model, redist_space, space, redist_glue)
121+
80122 return true
81123end
82124
@@ -159,8 +201,8 @@ function main(distribute,ncells,isperiodic)
159201 test_redistribution (coarse_ranks,fine_ranks,parent,redist_parent,redist_glue_parent)
160202 test_redistribution (coarse_ranks,fine_ranks,child,redist_child_2,redist_glue_child)
161203
162- test_adaptivity (coarse_ranks,parent,child,coarse_adaptivity_glue)
163- test_adaptivity (fine_ranks,redist_parent,redist_child_1,fine_adaptivity_glue)
204+ # test_adaptivity(coarse_ranks,parent,child,coarse_adaptivity_glue)
205+ # test_adaptivity(fine_ranks,redist_parent,redist_child_1,fine_adaptivity_glue)
164206 return
165207end
166208
@@ -171,4 +213,6 @@ function main(distribute)
171213 main (distribute,(8 ,8 ),(true ,true ))
172214end
173215
216+ main (DebugArray)
217+
174218end # module AdaptivityTests
0 commit comments