@@ -15,13 +15,6 @@ function Gridap.FESpaces.num_dirichlet_dofs(f::Gridap.MultiField.MultiFieldFESpa
15
15
end
16
16
17
17
function run (comm,subdomains)
18
- # Select matrix and vector types for discrete problem
19
- # Note that here we use serial vectors and matrices
20
- # but the assembly is distributed
21
- T = Float64
22
- vector_type = Vector{T}
23
- matrix_type = SparseMatrixCSC{T,Int}
24
-
25
18
# Manufactured solution
26
19
ux (x)= 2 * x[1 ]* x[2 ]
27
20
uy (x)= - x[2 ]^ 2
@@ -37,29 +30,23 @@ function run(comm,subdomains)
37
30
cells = (4 , 4 )
38
31
model = CartesianDiscreteModel (comm, subdomains, domain, cells)
39
32
40
- # Define Dirichlet and Neumann boundaries for local models
41
- do_on_parts (model) do part, (model,gids)
42
- labels = get_face_labeling (model)
43
- add_tag_from_tags! (labels," diri0" ,[1 ,2 ,3 ,4 ,6 ,7 ,8 ])
44
- add_tag_from_tags! (labels," diri1" ,[1 ,2 ,3 ,4 ,6 ,7 ,8 ])
45
- add_tag_from_tags! (labels," neumann" ,[5 ])
46
- end
47
-
33
+ labels = get_face_labeling (model)
34
+ add_tag_from_tags! (labels," diri0" ,[1 ,2 ,3 ,4 ,6 ,7 ,8 ])
35
+ add_tag_from_tags! (labels," diri1" ,[1 ,2 ,3 ,4 ,6 ,7 ,8 ])
36
+ add_tag_from_tags! (labels," neumann" ,[5 ])
48
37
49
38
# FE Spaces
50
39
order = 2
51
40
reffeᵤ = ReferenceFE (lagrangian,VectorValue{2 ,Float64},order)
52
41
reffeₚ = Gridap. ReferenceFEs. LagrangianRefFE (Float64,QUAD,order- 1 ;space= :P )
53
42
V = FESpace (
54
- vector_type,
55
43
model= model,
56
44
reffe= reffeᵤ,
57
45
conformity= :H1 ,
58
46
dirichlet_tags= [" diri0" ," diri1" ],
59
47
)
60
48
61
49
Q = FESpace (
62
- vector_type,
63
50
model= model,
64
51
reffe= reffeₚ,
65
52
conformity= :L2 )
@@ -71,53 +58,30 @@ function run(comm,subdomains)
71
58
P= TrialFESpace (Q)
72
59
X= MultiFieldFESpace (Y,[U,P])
73
60
74
- strategy = OwnedAndGhostCellsAssemblyStrategy (V,MapDoFsTypeGlobal ())
61
+ trian= Triangulation (model)
62
+ degree = 2 * (order+ 1 )
63
+ dΩ = Measure (trian,degree)
75
64
76
- function a (x,y)
77
- DistributedData (x,y,ddΩ,ddΓ) do part, xl, yl, dΩ, dΓ
78
- ul,pl= xl
79
- vl,ql= yl
80
- ∫ ( ∇ (vl)⊙ ∇ (ul) - (∇⋅ vl)* pl + ql* (∇⋅ ul) )dΩ
81
- end
82
- end
65
+ btrian= BoundaryTriangulation (model;tags= " neumann" )
66
+ dΓ = Measure (btrian,degree)
83
67
84
- function l (y)
85
- DistributedData (y,ddΩ,ddΓ) do part, yl, dΩ, dΓ
86
- vl,_= yl
87
- ∫ ( vl⋅ f )dΩ + ∫ ( vl⋅ s )dΓ
88
- end
68
+ function a ((u,p),(v,q))
69
+ ∫ ( ∇ (v)⊙ ∇ (u) - (∇⋅ v)* p + q* (∇⋅ u) )dΩ
89
70
end
90
71
91
- # Assembler
92
- assem = SparseMatrixAssembler (matrix_type, vector_type, X, Y, strategy)
93
-
94
- function setup_dΩ (part,(model,gids),strategy)
95
- trian = Triangulation (strategy,model)
96
- degree = 2 * (order+ 1 )
97
- Measure (trian,degree)
98
- end
99
- ddΩ = DistributedData (setup_dΩ,model,strategy)
100
-
101
- function setup_dΓ (part,(model,gids),strategy)
102
- btrian= BoundaryTriangulation (strategy,model;tags= " neumann" )
103
- degree = 2 * (order+ 1 )
104
- Measure (btrian,degree)
105
- end
106
- ddΓ = DistributedData (setup_dΓ,model,strategy)
72
+ function l ((v,q))
73
+ ∫ ( v⋅ f )dΩ + ∫ ( v⋅ s )dΓ
74
+ end
107
75
108
76
# # # FE solution
109
- op = AffineFEOperator (a,l,X,Y,assem )
77
+ op = AffineFEOperator (a,l,X,Y)
110
78
xh = solve (op)
79
+ uh,_ = xh
111
80
112
- sums = DistributedData (model, xh) do part, (model, gids), xh
113
- trian = Triangulation (model)
114
- owned_trian = remove_ghost_cells (trian, part, gids)
115
- dΩ = Measure (owned_trian, 2 * order)
116
- uh,_ = xh
117
- e = u- uh
118
- sum (∫ (e⋅ e)dΩ)
119
- end
120
- e_l2 = sum (gather (sums))
81
+ trian= Triangulation (OwnedCells,model)
82
+ dΩ= Measure (trian,2 * order)
83
+ e = u- uh
84
+ e_l2 = sum (∫ (e⋅ e)dΩ)
121
85
tol = 1.0e-9
122
86
println (" $(e_l2) < $(tol) " )
123
87
@test e_l2 < tol
@@ -128,6 +92,6 @@ function f(comm)
128
92
run (comm,subdomains)
129
93
end
130
94
131
- # SequentialCommunicator(f,subdomains)
95
+ SequentialCommunicator (f,subdomains)
132
96
133
97
end # module
0 commit comments