Skip to content

Commit 7af5578

Browse files
Merge pull request #751 from gridap/fill_to_fillstored_GridapODEs
fill! to fillstored!
2 parents 7046347 + a025028 commit 7af5578

File tree

11 files changed

+18
-16
lines changed

11 files changed

+18
-16
lines changed

src/GridapODEs/ODETools/AffineNewmark.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkAffineOperator,x::AbstractVector
9797
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
9898
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
9999
z = zero(eltype(A))
100-
fill!(A,z)
100+
fillstored!(A,z)
101101
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
102102
end
103103

src/GridapODEs/ODETools/AffineThetaMethod.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ end
106106

107107
function _matrix!(A,odeop,tθ,dtθ,u0,ode_cache,vθ)
108108
z = zero(eltype(A))
109-
fill!(A,z)
109+
fillstored!(A,z)
110110
jacobians!(A,odeop,tθ,(vθ,vθ),(1.0,1/dtθ),ode_cache)
111111
end
112112

113113
function _mass_matrix!(A,odeop,tθ,dtθ,u0,ode_cache,vθ)
114114
z = zero(eltype(A))
115-
fill!(A,z)
115+
fillstored!(A,z)
116116
jacobian!(A,odeop,tθ,(vθ,vθ),2,(1/dtθ),ode_cache)
117117
end
118118

@@ -143,7 +143,7 @@ function ThetaMethodConstantOperator(odeop::ConstantODEOperator,tθ::Float64,dt
143143
residual!(b,odeop,tθ,(u0,vθ),ode_cache)
144144
b = -1*b
145145
z = zero(eltype(A))
146-
fill!(A,z)
146+
fillstored!(A,z)
147147
jacobians!(A,odeop,tθ,(vθ,vθ),(1.0,1/dtθ),ode_cache)
148148
return A, b
149149
end

src/GridapODEs/ODETools/ConstantMatrixNewmark.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkConstantMatrixOperator,x::Abstra
9292
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
9393
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
9494
z = zero(eltype(A))
95-
fill!(A,z)
95+
fillstored!(A,z)
9696
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
9797
end
9898

src/GridapODEs/ODETools/ConstantNewmark.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkConstantOperator,x::AbstractVect
125125
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
126126
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
127127
z = zero(eltype(A))
128-
fill!(A,z)
128+
fillstored!(A,z)
129129
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
130130
end
131131

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

@@ -147,6 +147,6 @@ function _damping_matrix!(A::AbstractMatrix,op::NewmarkConstantOperator,x::Abstr
147147
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
148148
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
149149
z = zero(eltype(A))
150-
fill!(A,z)
150+
fillstored!(A,z)
151151
jacobian!(A,op.odeop,op.t1,(u1,v1,a1),2,1.0,cache)
152152
end

src/GridapODEs/ODETools/ForwardEuler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function jacobian!(A::AbstractMatrix,op::ForwardEulerNonlinearOperator,x::Abstra
5959
vf = op.vf
6060
vf = (x-op.u0)/op.dt
6161
z = zero(eltype(A))
62-
fill!(A,z)
62+
fillstored!(A,z)
6363
jacobians!(A,op.odeop,op.tf,(op.u0,vf),(0,1/op.dt),op.ode_cache)
6464
end
6565

src/GridapODEs/ODETools/Newmark.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function jacobian!(A::AbstractMatrix,op::NewmarkNonlinearOperator,x::AbstractVec
7575
a1 = 1.0/(op.β*op.dt^2)*(u1-u0) - 1.0/(op.β*op.dt)*v0 - (1-2*op.β)/(2*op.β)*a0
7676
v1 = op.γ/(op.β*op.dt)*(u1-u0) + (1-op.γ/op.β)*v0 + op.dt*(1-op.γ/(2*op.β))*a0
7777
z = zero(eltype(A))
78-
fill!(A,z)
78+
fillstored!(A,z)
7979
jacobians!(A,op.odeop,op.t1,(u1,v1,a1),(1.0,op.γ/(op.β*op.dt),1.0/(op.β*op.dt^2)),cache)
8080
end
8181

src/GridapODEs/ODETools/ODETools.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ using Test
1010
using DocStringExtensions
1111

1212
using ForwardDiff
13-
using LinearAlgebra: fill!
13+
using LinearAlgebra: fillstored!
14+
using SparseArrays: issparse
1415

1516
const ϵ = 100*eps()
1617
export ∂t

src/GridapODEs/ODETools/RungeKutta.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function jacobian!(A::AbstractMatrix,op::RungeKuttaNonlinearOperator,x::Abstract
175175
vi = op.vi
176176
vi = (x-op.u0)/(op.a[op.i,op.i]*op.dt)
177177
z = zero(eltype(A))
178-
fill!(A,z)
178+
fillstored!(A,z)
179179
jacobians!(A,op.odeop,op.ti,(ui,vi),(1.0,1.0/(op.a[op.i,op.i]*op.dt)),op.ode_cache)
180180
end
181181

src/GridapODEs/ODETools/ThetaMethod.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function jacobian!(A::AbstractMatrix,op::ThetaMethodNonlinearOperator,x::Abstrac
7979
= op.
8080
= (x-op.u0)/op.dtθ
8181
z = zero(eltype(A))
82-
fill!(A,z)
82+
fillstored!(A,z)
8383
jacobians!(A,op.odeop,op.tθ,(uF,vθ),(1.0,1/op.dtθ),op.ode_cache)
8484
end
8585

test/GridapODEsTests/ODEsTests/ODEOperatorMocks.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Gridap.GridapODEs.ODETools: jacobian!
1616
import Gridap.GridapODEs.ODETools: jacobians!
1717
import Gridap.GridapODEs.ODETools: allocate_jacobian
1818
import Gridap.GridapODEs.ODETools: residual!
19+
using SparseArrays: spzeros
1920

2021
struct ODEOperatorMock{T<:Real,C} <: ODEOperator{C}
2122
a::T
@@ -104,7 +105,7 @@ function jacobians!(
104105
end
105106

106107
function allocate_jacobian(op::ODEOperatorMock,u::AbstractVector,cache)
107-
zeros(2,2)
108+
spzeros(2,2)
108109
end
109110

110111
allocate_cache(op::ODEOperatorMock) = nothing

0 commit comments

Comments
 (0)