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

Update to gridap 0.17 #58

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ForwardDiff = "0.10"
Gridap = "0.16"
Gridap = "0.17"
LineSearches = "7.1"
Sundials = "4.5"
julia = "1.6"
Expand Down
9 changes: 4 additions & 5 deletions src/DiffEqsWrappers/DiffEqsWrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ using GridapODEs.ODETools: jacobian!
using Gridap.Algebra: allocate_jacobian

using Gridap.FESpaces: get_algebraic_operator

using Gridap.Algebra: fill_entries!
using LinearAlgebra: fillstored!

export prototype_jacobian
export prototype_mass
Expand Down Expand Up @@ -51,21 +50,21 @@ function diffeq_wrappers(op)
function _jacobian!(jac, du, u, p, gamma, t)
ode_cache = update_cache!(ode_cache, ode_op, t)
z = zero(eltype(jac))
fill_entries!(jac, z)
fillstored!(jac, z)
jacobians!(jac, ode_op, t, (u, du), (1.0, gamma), ode_cache)
end

function _mass!(mass, du, u, p, t)
ode_cache = update_cache!(ode_cache, ode_op, t)
z = zero(eltype(mass))
fill_entries!(mass, z)
fillstored!(mass, z)
jacobian!(mass, ode_op, t, (u, du), 2, 1.0, ode_cache)
end

function _stiffness!(stif, du, u, p, t)
ode_cache = update_cache!(ode_cache, ode_op, t)
z = zero(eltype(stif))
fill_entries!(stif, z)
fillstored!(stif, z)
jacobian!(stif, ode_op, t, (u, du), 1, 1.0, ode_cache)
end

Expand Down
2 changes: 1 addition & 1 deletion src/ODETools/AffineNewmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkAffineOperator,x::AbstractVector
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
end

Expand Down
6 changes: 3 additions & 3 deletions src/ODETools/AffineThetaMethod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ end

function _matrix!(A,odeop,tθ,dtθ,u0,ode_cache,vθ)
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,odeop,tθ,(vθ,vθ),(1.0,1/dtθ),ode_cache)
end

function _mass_matrix!(A,odeop,tθ,dtθ,u0,ode_cache,vθ)
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobian!(A,odeop,tθ,(vθ,vθ),2,(1/dtθ),ode_cache)
end

Expand Down Expand Up @@ -140,7 +140,7 @@ function ThetaMethodConstantOperator(odeop::ConstantODEOperator,tθ::Float64,dt
residual!(b,odeop,tθ,(u0,vθ),ode_cache)
b = -1*b
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,odeop,tθ,(vθ,vθ),(1.0,1/dtθ),ode_cache)
return A, b
end
2 changes: 1 addition & 1 deletion src/ODETools/ConstantMatrixNewmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkConstantMatrixOperator,x::Abstra
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
end

Expand Down
6 changes: 3 additions & 3 deletions src/ODETools/ConstantNewmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkConstantOperator,x::AbstractVect
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
end

Expand All @@ -136,7 +136,7 @@ function _mass_matrix!(A::AbstractMatrix,op::NewmarkConstantOperator,x::Abstract
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobian!(A,op.odeop,op.t1,(u1,v1,a1),3,1.0,cache)
end

Expand All @@ -147,6 +147,6 @@ function _damping_matrix!(A::AbstractMatrix,op::NewmarkConstantOperator,x::Abstr
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobian!(A,op.odeop,op.t1,(u1,v1,a1),2,1.0,cache)
end
2 changes: 1 addition & 1 deletion src/ODETools/ForwardEuler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function jacobian!(A::AbstractMatrix,op::ForwardEulerNonlinearOperator,x::Abstra
vf = op.vf
vf = (x-op.u0)/op.dt
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobian!(A,op.odeop,op.tf,(op.u0,vf),1,(1/op.dt),op.ode_cache)
end

Expand Down
2 changes: 1 addition & 1 deletion src/ODETools/Newmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkNonlinearOperator,x::AbstractVec
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
end

Expand Down
2 changes: 1 addition & 1 deletion src/ODETools/ODETools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ODETools
using Test

using ForwardDiff
using LinearAlgebra: fillstored!

const ϵ = 100*eps()
export ∂t
Expand Down Expand Up @@ -59,7 +60,6 @@ export MidPoint
export ThetaMethod
export RungeKutta
export Newmark
import Gridap.Algebra: fill_entries!

export ODESolution
export test_ode_solution
Expand Down
2 changes: 1 addition & 1 deletion src/ODETools/RungeKutta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function jacobian!(A::AbstractMatrix,op::RungeKuttaNonlinearOperator,x::Abstract
vi = op.vi
vi = (x-op.u0)/(op.a[op.i,op.i]*op.dt)
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.ti,(ui,vi),(1/(op.a[op.i,op.i]*op.dt)),op.ode_cache)
end

Expand Down
2 changes: 1 addition & 1 deletion src/ODETools/ThetaMethod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function jacobian!(A::AbstractMatrix,op::ThetaMethodNonlinearOperator,x::Abstrac
vθ = op.vθ
vθ = (x-op.u0)/op.dtθ
z = zero(eltype(A))
fill_entries!(A,z)
fillstored!(A,z)
jacobians!(A,op.odeop,op.tθ,(uF,vθ),(1.0,1/op.dtθ),op.ode_cache)
end

Expand Down
3 changes: 1 addition & 2 deletions test/ODEsTests/ODESolverMocks.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Gridap.Algebra: residual
using Gridap.Algebra: jacobian
using Gridap.Algebra: fill_entries!
import Gridap.Algebra: NonlinearSolver
import Gridap.Algebra: NonlinearOperator
import Gridap.Algebra: solve!
Expand Down Expand Up @@ -35,7 +34,7 @@ end
function jacobian!(A::AbstractMatrix,op::OperatorMock,x::AbstractVector)
uf = x
uf_t = (x-op.u0)/op.dt
fill_entries!(A,0.0)
fillstored!(A,0.0)
jacobian!(A,op.odeop,op.tf,uf,uf_t,op.cache)
jacobian_t!(A,op.odeop,op.tf,uf,uf_t,(1/op.dt),op.cache)
end
Expand Down