-
Notifications
You must be signed in to change notification settings - Fork 97
/
PoissonDGTests.jl
67 lines (49 loc) · 1.31 KB
/
PoissonDGTests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module PoissonDGTests
using Test
using Gridap
import Gridap: ∇
#using LinearAlgebra
#domain = (0,1,0,1)
#partition = (4,4)
#model = CartesianDiscreteModel(domain,partition)
#const h = (domain[2]-domain[1]) / partition[1]
using Gridap.Geometry: DiscreteModelMock
model = DiscreteModelMock()
const h = 1
order = 2
const γ = 10
Ω = Triangulation(model)
Γ = BoundaryTriangulation(model)
Λ = SkeletonTriangulation(model)
degree = order
dΩ = Measure(Ω,degree)
dΓ = Measure(Γ,degree)
dΛ = Measure(Λ,degree)
n_Γ = get_normal_vector(Γ)
n_Λ = get_normal_vector(Λ)
u(x) = x[1]^2 + x[2]
∇u(x) = VectorValue( 2*x[1], one(x[2]) )
Δu(x) = 2
f(x) = - Δu(x)
∇(::typeof(u)) = ∇u
V = TestFESpace(model,ReferenceFE(lagrangian,Float64,order),conformity=:L2)
U = TrialFESpace(V,u)
a(u,v) =
∫( ∇(v)⋅∇(u) )*dΩ +
∫( (γ/h)*v*u - v*(n_Γ⋅∇(u)) - (n_Γ⋅∇(v))*u )*dΓ +
∫( (γ/h)*jump(v*n_Λ)⋅jump(u*n_Λ) - jump(v*n_Λ)⋅mean(∇(u)) - mean(∇(v))⋅jump(u*n_Λ) )*dΛ
l(v) =
∫( v*f )*dΩ +
∫( (γ/h)*v*u - (n_Γ⋅∇(v))*u )*dΓ
op = AffineFEOperator(a,l,U,V)
uh = solve(op)
e = u - uh
l2(u) = sqrt(sum( ∫( u⊙u )*dΩ ))
h1(u) = sqrt(sum( ∫( u⊙u + ∇(u)⊙∇(u) )*dΩ ))
el2 = l2(e)
eh1 = h1(e)
ul2 = l2(uh)
uh1 = h1(uh)
@test el2/ul2 < 1.e-8
@test eh1/uh1 < 1.e-7
end # module