Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Fixing Forward Euler test
Browse files Browse the repository at this point in the history
  • Loading branch information
oriolcg committed Dec 9, 2021
1 parent c3f60e3 commit 9be6d01
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Binary file removed results.vtu
Binary file not shown.
3 changes: 1 addition & 2 deletions src/ODETools/ForwardEuler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ function residual!(b::AbstractVector,op::ForwardEulerNonlinearOperator,x::Abstra
end

function jacobian!(A::AbstractMatrix,op::ForwardEulerNonlinearOperator,x::AbstractVector)
uF = x
vf = op.vf
vf = (x-op.u0)/op.dt
z = zero(eltype(A))
fillstored!(A,z)
jacobian!(A,op.odeop,op.tf,(op.u0,vf),1,(1/op.dt),op.ode_cache)
jacobians!(A,op.odeop,op.tf,(op.u0,vf),(0,1/op.dt),op.ode_cache)
end

function allocate_residual(op::ForwardEulerNonlinearOperator,x::AbstractVector)
Expand Down
4 changes: 3 additions & 1 deletion src/TransientFETools/TransientFEOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ function jacobians!(
cache)
_matdata = ()
for i in 1:get_order(op)+1
_matdata = (_matdata...,matdata_jacobian(op,t,xh,i,γ[i]))
if (γ[i] > 0.0)
_matdata = (_matdata...,matdata_jacobian(op,t,xh,i,γ[i]))
end
end
matdata = vcat_matdata(_matdata)
assemble_matrix_add!(A,op.assem_t, matdata)
Expand Down
7 changes: 2 additions & 5 deletions test/TransientFEsTests/ForwardEulerHeatEquationTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ a(u,v) = ∇(v)⋅∇(u)
b(v,t) = v*f(t)

res(t,(u,ut),v) = ( a(u,v) + ut*v - b(v,t) )dΩ
jac(t,(u,ut),du,v) = a(du,v)
jac(t,(u,ut),du,v) = ( a(du,v) )dΩ
jac_t(t,(u,ut),dut,v) = ( dut*v )dΩ

#t_Ω = FETerm(res,jac,jac_t,trian,quad)
op = TransientFEOperator(res,jac,jac_t,U,V0)

t0 = 0.0
Expand All @@ -62,8 +61,6 @@ U0 = U(0.0)
uh0 = interpolate_everywhere(u(0.0),U0)

ls = LUSolver()
using Gridap.Algebra: NewtonRaphsonSolver
nls = NLSolver(ls;show_trace=true,method=:newton) #linesearch=BackTracking())
ode_solver = ThetaMethod(ls,dt,θ)

sol_t = solve(ode_solver,op,uh0,t0,tF)
Expand All @@ -77,7 +74,7 @@ for (uh_tn, tn) in sol_t
global _t_n
_t_n += dt
e = u(tn) - uh_tn
el2 = sqrt(sum( integrate(l2(e),trian,quad) ))
el2 = sqrt(sum( (l2(e))dΩ ))
@test el2 < tol
end

Expand Down
2 changes: 2 additions & 0 deletions test/TransientFEsTests/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ using Test

@testset "HeatEquationAutoDiffTests" begin include("HeatEquationAutoDiffTests.jl") end

@testset "ForwardEulerHeatEquationTests" begin include("ForwardEulerHeatEquationTests.jl") end

end # module

0 comments on commit 9be6d01

Please sign in to comment.