Skip to content

Commit

Permalink
First Test with Robin BCs working
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Jul 10, 2019
1 parent 2063363 commit 946054a
Showing 1 changed file with 55 additions and 5 deletions.
60 changes: 55 additions & 5 deletions test/FESpacesTests/FEOperatorsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ eh1 = sqrt(sum( integrate(h1(e),trian,quad) ))
@test TestFESpace(op) === V

zh = zero(U)
r = apply(op,zh)
r2 = similar(r)
res = apply(op,zh)
r2 = similar(res)
apply!(r2,op,zh)
@test r r2
@test res r2

cache = solve!(zh,solver,op)
@test free_dofs(zh) free_dofs(uh)
Expand Down Expand Up @@ -111,13 +111,63 @@ g(v) = inner(v,gfield)

# Define weak form terms
t_Ω = AffineFETerm(a,b,trian,quad)
t_Γ = FESource(g,btrian,bquad)
t_ΓN = FESource(g,btrian,bquad)

# Define Assembler
assem = SparseMatrixAssembler(V,U)

# Define FE problem
op = LinearFEOperator(V,U,assem,t_Ω,t_Γ)
op = LinearFEOperator(V,U,assem,t_Ω,t_ΓN)

# Solve!
uh = solve(solver,op)

# Define exact solution and error
e = u - uh

# Compute errors
el2 = sqrt(sum( integrate(l2(e),trian,quad) ))
eh1 = sqrt(sum( integrate(h1(e),trian,quad) ))

#writevtk(trian,"trian",nref=4,cellfields=["uh"=>uh,"u"=>u,"e"=>e])

@test el2 < 1.e-8
@test eh1 < 1.e-8

# With Robin boundary conditions

# Manufactured Robin function
rfun(x) = 1.0 + ufun(x)

# Construct the FEspace
order = 1
diritags = [1,2,3,4,5,7]
fespace = ConformingFESpace(Float64,model,order,diritags)

# Define test and trial
V = TestFESpace(fespace)
U = TrialFESpace(fespace,ufun)

# Setup integration on Robin boundary
robintags = [6,]
rtrian = BoundaryTriangulation(model,robintags)
rquad = CellQuadrature(rtrian,order=2)

# Object describing Robin function
rfield = CellField(rtrian,rfun)

# Integrands of the Robin BC
r(v) = inner(v,rfield)
m(v,u) = inner(v,u)

# Define Robin terms
t_ΓR = AffineFETerm(m,r,rtrian,rquad)

# Define Assembler
assem = SparseMatrixAssembler(V,U)

# Define FE problem
op = LinearFEOperator(V,U,assem,t_Ω,t_ΓN,t_ΓR)

# Solve!
uh = solve(solver,op)
Expand Down

0 comments on commit 946054a

Please sign in to comment.