Skip to content

Commit cf93940

Browse files
* Redistribute of octrees runs without error.
Did not check consistency, though. * Solved the following issue: If I execute rdmodel,glue=refine(dmodel,ref_coarse_flags); twice, then Gridap generates an error the second time. The cause of the error is that we are trying to create the hanging tag in the face labeling associated to dmodel, but this does not make sense as refine should not modify dmodel
1 parent 2535f90 commit cf93940

File tree

3 files changed

+91
-87
lines changed

3 files changed

+91
-87
lines changed

src/OctreeDistributedDiscreteModels.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,10 @@ function _redistribute_parts_subseteq_parts_redistributed(model::OctreeDistribut
11701170

11711171
# Extract ghost and lnodes
11721172
ptr_pXest_ghost = setup_pXest_ghost(Val{Dc}, ptr_pXest_new)
1173-
ptr_pXest_lnodes = setup_pXest_lnodes(Val{Dc}, ptr_pXest_new, ptr_pXest_ghost)
1173+
ptr_pXest_lnodes = setup_pXest_lnodes_nonconforming(Val{Dc}, ptr_pXest_new, ptr_pXest_ghost)
11741174

11751175
# Build fine-grid mesh
1176-
fmodel = setup_distributed_discrete_model(Val{Dc},
1176+
fmodel, non_conforming_glue = setup_non_conforming_distributed_discrete_model(Val{Dc},
11771177
parts,
11781178
model.coarse_model,
11791179
model.ptr_pXest_connectivity,
@@ -1187,6 +1187,7 @@ function _redistribute_parts_subseteq_parts_redistributed(model::OctreeDistribut
11871187
red_model = OctreeDistributedDiscreteModel(Dc,Dp,
11881188
parts,
11891189
fmodel,
1190+
non_conforming_glue,
11901191
model.coarse_model,
11911192
model.ptr_pXest_connectivity,
11921193
ptr_pXest_new,

src/UniformlyRefinedForestOfOctreesDiscreteModels.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ function generate_face_labeling(parts,
851851
d_to_dface_to_entity[Dc] = faces_to_entity[Dc]
852852
d_to_dface_to_entity[Dc+1] = faces_to_entity[Dc+1]
853853
Gridap.Geometry.FaceLabeling(d_to_dface_to_entity,
854-
coarse_grid_labeling.tag_to_entities,
855-
coarse_grid_labeling.tag_to_name)
854+
copy(coarse_grid_labeling.tag_to_entities),
855+
copy(coarse_grid_labeling.tag_to_name))
856856
end
857857
face_labeling
858858
end

test.jl

Lines changed: 86 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ using MPI
66

77

88
# Define integration mesh and quadrature
9-
order=2
9+
order=1
1010
# Define manufactured functions
1111
u(x) = x[1]+x[2]^order
1212
f(x) = -Δ(u)(x)
1313
degree = 2*order+1
1414

1515
MPI.Init()
16-
ranks=distribute_with_mpi(LinearIndices((2,)))
16+
ranks=distribute_with_mpi(LinearIndices((1,)))
1717
coarse_model=CartesianDiscreteModel((0,1,0,1),(1,1))
1818
dmodel=OctreeDistributedDiscreteModel(ranks,coarse_model,1)
1919

@@ -27,99 +27,102 @@ ref_coarse_flags=map(ranks,partition(get_cell_gids(dmodel.dmodel))) do rank,indi
2727
flags=zeros(Cint,length(indices))
2828
flags.=-1
2929
if (rank==1)
30-
flags[1:2].=[refine_flag,nothing_flag]
31-
#flags[1:4].=[refine_flag,nothing_flag,nothing_flag,nothing_flag]
30+
#flags[1:2].=[refine_flag,nothing_flag]
31+
flags[1:4].=[refine_flag,nothing_flag,nothing_flag,nothing_flag]
3232
elseif (rank==2)
33-
flags[1:2].=[nothing_flag,refine_flag]
33+
flags[1:2].=[nothing_flag,nothing_flag]
3434
end
3535
print("rank: $(rank) flags: $(flags)"); print("\n")
3636
flags
3737
end
38-
rdmodel,glue=refine(dmodel,ref_coarse_flags);
38+
fmodel,glue=refine(dmodel,ref_coarse_flags);
3939
map(ranks,glue) do rank, glue
4040
if rank==2
4141
print(glue.n2o_faces_map[end]); print("\n")
4242
print(glue.refinement_rules); print("\n")
4343
end
4444
end
4545

46+
rdmodel_red, red_glue=GridapDistributed.redistribute(fmodel);
47+
48+
49+
# Vh=FESpace(fmodel,reffe,conformity=:H1;dirichlet_tags="boundary")
50+
# map(ranks,partition(Vh.gids)) do rank, indices
51+
# print("$(rank): $(local_to_owner(indices))"); print("\n")
52+
# print("$(rank): $(local_to_global(indices))"); print("\n")
53+
# end
54+
# Uh=TrialFESpace(Vh,u)
55+
56+
# ΩH = Triangulation(dmodel)
57+
# dΩH = Measure(ΩH,degree)
58+
59+
# aH(u,v) = ∫( ∇(v)⊙∇(u) )*dΩH
60+
# bH(v) = ∫(v*f)*dΩH
61+
62+
# op = AffineFEOperator(aH,bH,UH,VH)
63+
# uH = solve(op)
64+
# e = u - uH
65+
66+
# # # Compute errors
67+
# el2 = sqrt(sum( ∫( e*e )*dΩH ))
68+
# eh1 = sqrt(sum( ∫( e*e + ∇(e)⋅∇(e) )*dΩH ))
69+
70+
# tol=1e-8
71+
# @assert el2 < tol
72+
# @assert eh1 < tol
73+
74+
75+
# Ωh = Triangulation(fmodel)
76+
# dΩh = Measure(Ωh,degree)
77+
78+
# ah(u,v) = ∫( ∇(v)⊙∇(u) )*dΩh
79+
# bh(v) = ∫(v*f)*dΩh
80+
81+
# op = AffineFEOperator(ah,bh,Uh,Vh)
82+
# uh = solve(op)
83+
# e = u - uh
84+
85+
# # # Compute errors
86+
# el2 = sqrt(sum( ∫( e*e )*dΩh ))
87+
# eh1 = sqrt(sum( ∫( e*e + ∇(e)⋅∇(e) )*dΩh ))
88+
89+
# tol=1e-8
90+
# @assert el2 < tol
91+
# @assert eh1 < tol
92+
93+
# # prolongation via interpolation
94+
# uHh=interpolate(uH,Uh)
95+
# e = uh - uHh
96+
# el2 = sqrt(sum( ∫( e*e )*dΩh ))
97+
# tol=1e-8
98+
# @assert el2 < tol
99+
100+
# # prolongation via L2-projection
101+
# # Coarse FEFunction -> Fine FEFunction, by projection
102+
# ah(u,v) = ∫(v⋅u)*dΩh
103+
# lh(v) = ∫(v⋅uH)*dΩh
104+
# oph = AffineFEOperator(ah,lh,Uh,Vh)
105+
# uHh = solve(oph)
106+
# e = uh - uHh
107+
# el2 = sqrt(sum( ∫( e*e )*dΩh ))
108+
# tol=1e-8
109+
# @assert el2 < tol
110+
111+
# # restriction via interpolation
112+
# uhH=interpolate(uh,UH)
113+
# e = uH - uhH
114+
# el2 = sqrt(sum( ∫( e*e )*dΩh ))
115+
# tol=1e-8
116+
# @assert el2 < tol
117+
118+
# # restriction via L2-projection
119+
# dΩhH = Measure(ΩH,Ωh,2*order)
120+
# aH(u,v) = ∫(v⋅u)*dΩH
121+
# lH(v) = ∫(v⋅uh)*dΩhH
122+
# oph = AffineFEOperator(aH,lH,UH,VH)
123+
# uhH = solve(oph)
124+
# e = uH - uhH
125+
# el2 = sqrt(sum( ∫( e*e )*dΩH ))
46126

47-
Vh=FESpace(rdmodel,reffe,conformity=:H1;dirichlet_tags="boundary")
48-
map(ranks,partition(Vh.gids)) do rank, indices
49-
print("$(rank): $(local_to_owner(indices))"); print("\n")
50-
print("$(rank): $(local_to_global(indices))"); print("\n")
51-
end
52-
Uh=TrialFESpace(Vh,u)
53-
54-
ΩH = Triangulation(dmodel)
55-
dΩH = Measure(ΩH,degree)
56-
57-
aH(u,v) = ( (v)(u) )*dΩH
58-
bH(v) = (v*f)*dΩH
59-
60-
op = AffineFEOperator(aH,bH,UH,VH)
61-
uH = solve(op)
62-
e = u - uH
63-
64-
# # Compute errors
65-
el2 = sqrt(sum( ( e*e )*dΩH ))
66-
eh1 = sqrt(sum( ( e*e + (e)(e) )*dΩH ))
67-
68-
tol=1e-8
69-
@assert el2 < tol
70-
@assert eh1 < tol
71-
72-
73-
Ωh = Triangulation(rdmodel)
74-
dΩh = Measure(Ωh,degree)
75-
76-
ah(u,v) = ( (v)(u) )*dΩh
77-
bh(v) = (v*f)*dΩh
78-
79-
op = AffineFEOperator(ah,bh,Uh,Vh)
80-
uh = solve(op)
81-
e = u - uh
82-
83-
# # Compute errors
84-
el2 = sqrt(sum( ( e*e )*dΩh ))
85-
eh1 = sqrt(sum( ( e*e + (e)(e) )*dΩh ))
86-
87-
tol=1e-8
88-
@assert el2 < tol
89-
@assert eh1 < tol
90-
91-
# prolongation via interpolation
92-
uHh=interpolate(uH,Uh)
93-
e = uh - uHh
94-
el2 = sqrt(sum( ( e*e )*dΩh ))
95-
tol=1e-8
96-
@assert el2 < tol
97-
98-
# prolongation via L2-projection
99-
# Coarse FEFunction -> Fine FEFunction, by projection
100-
ah(u,v) = (vu)*dΩh
101-
lh(v) = (vuH)*dΩh
102-
oph = AffineFEOperator(ah,lh,Uh,Vh)
103-
uHh = solve(oph)
104-
e = uh - uHh
105-
el2 = sqrt(sum( ( e*e )*dΩh ))
106-
tol=1e-8
107-
@assert el2 < tol
108-
109-
# restriction via interpolation
110-
uhH=interpolate(uh,UH)
111-
e = uH - uhH
112-
el2 = sqrt(sum( ( e*e )*dΩh ))
113-
tol=1e-8
114-
@assert el2 < tol
115-
116-
# restriction via L2-projection
117-
dΩhH = Measure(ΩH,Ωh,2*order)
118-
aH(u,v) = (vu)*dΩH
119-
lH(v) = (vuh)*dΩhH
120-
oph = AffineFEOperator(aH,lH,UH,VH)
121-
uhH = solve(oph)
122-
e = uH - uhH
123-
el2 = sqrt(sum( ( e*e )*dΩH ))
124127

125128

0 commit comments

Comments
 (0)