@@ -6,14 +6,14 @@ using MPI
6
6
7
7
8
8
# Define integration mesh and quadrature
9
- order= 2
9
+ order= 1
10
10
# Define manufactured functions
11
11
u (x) = x[1 ]+ x[2 ]^ order
12
12
f (x) = - Δ (u)(x)
13
13
degree = 2 * order+ 1
14
14
15
15
MPI. Init ()
16
- ranks= distribute_with_mpi (LinearIndices ((2 ,)))
16
+ ranks= distribute_with_mpi (LinearIndices ((1 ,)))
17
17
coarse_model= CartesianDiscreteModel ((0 ,1 ,0 ,1 ),(1 ,1 ))
18
18
dmodel= OctreeDistributedDiscreteModel (ranks,coarse_model,1 )
19
19
@@ -27,99 +27,102 @@ ref_coarse_flags=map(ranks,partition(get_cell_gids(dmodel.dmodel))) do rank,indi
27
27
flags= zeros (Cint,length (indices))
28
28
flags.= - 1
29
29
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]
32
32
elseif (rank== 2 )
33
- flags[1 : 2 ]. = [nothing_flag,refine_flag ]
33
+ flags[1 : 2 ]. = [nothing_flag,nothing_flag ]
34
34
end
35
35
print (" rank: $(rank) flags: $(flags) " ); print (" \n " )
36
36
flags
37
37
end
38
- rdmodel ,glue= refine (dmodel,ref_coarse_flags);
38
+ fmodel ,glue= refine (dmodel,ref_coarse_flags);
39
39
map (ranks,glue) do rank, glue
40
40
if rank== 2
41
41
print (glue. n2o_faces_map[end ]); print (" \n " )
42
42
print (glue. refinement_rules); print (" \n " )
43
43
end
44
44
end
45
45
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 ))
46
126
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) = ∫ (v⋅ u)* dΩh
101
- lh (v) = ∫ (v⋅ uH)* 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) = ∫ (v⋅ u)* dΩH
119
- lH (v) = ∫ (v⋅ uh)* 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 ))
124
127
125
128
0 commit comments