StatProfilerHTML.jl report
Generated on Mon, 01 Apr 2024 21:01:18
File source code
Line Exclusive Inclusive Code
1 abstract type AbstractFunJac{J2} end
2 mutable struct FunJac{N, F, F2, J, P, M, J2, Prec, PS,
3 TResid <: Union{Nothing, Array{Float64, N}}} <: AbstractFunJac{J2}
4 fun::F
5 fun2::F2
6 jac::J
7 p::P
8 mass_matrix::M
9 jac_prototype::J2
10 prec::Prec
11 psetup::PS
12 u::Array{Float64, N}
13 du::Array{Float64, N}
14 resid::TResid
15 end
16 function FunJac(fun, jac, p, m, jac_prototype, prec, psetup, u, du)
17 FunJac(fun, nothing, jac, p, m,
18 jac_prototype, prec,
19 psetup, u, du, nothing)
20 end
21 function FunJac(fun, jac, p, m, jac_prototype, prec, psetup, u, du, resid)
22 FunJac(fun, nothing,
23 jac, p, m,
24 jac_prototype,
25 prec, psetup, u,
26 du, resid)
27 end
28
29 function cvodefunjac(t::Float64, u::N_Vector, du::N_Vector, funjac::FunJac{N}) where {N}
30 funjac.u = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(u), size(funjac.u))
31 funjac.du = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(du),
32 size(funjac.du))
33 _du = funjac.du
34 _u = funjac.u
35 funjac.fun(_du, _u, funjac.p, t)
36 return CV_SUCCESS
37 end
38
39 function cvodefunjac2(t::Float64, u::N_Vector, du::N_Vector, funjac::FunJac{N}) where {N}
40 funjac.u = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(u), size(funjac.u))
41 funjac.du = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(du),
42 size(funjac.du))
43 _du = funjac.du
44 _u = funjac.u
45 funjac.fun2(_du, _u, funjac.p, t)
46 return CV_SUCCESS
47 end
48
49 function cvodejac(t::realtype,
50 u::N_Vector,
51 du::N_Vector,
52 J::SUNMatrix,
53 funjac::AbstractFunJac{Nothing},
54 tmp1::N_Vector,
55 tmp2::N_Vector,
56 tmp3::N_Vector)
57 funjac.u = unsafe_wrap(Vector{Float64}, N_VGetArrayPointer_Serial(u), length(funjac.u))
58 _u = funjac.u
59 funjac.jac(convert(Matrix, J), _u, funjac.p, t)
60 return CV_SUCCESS
61 end
62
63 function cvodejac(t::realtype,
64 u::N_Vector,
65 du::N_Vector,
66 _J::SUNMatrix,
67 funjac::AbstractFunJac{<:SparseArrays.SparseMatrixCSC},
68 tmp1::N_Vector,
69 tmp2::N_Vector,
70 tmp3::N_Vector)
71 jac_prototype = funjac.jac_prototype
72
73 funjac.u = unsafe_wrap(Vector{Float64}, N_VGetArrayPointer_Serial(u), length(funjac.u))
74 _u = funjac.u
75
76 funjac.jac(jac_prototype, _u, funjac.p, t)
77
78 copyto!(_J, jac_prototype)
79
80 return CV_SUCCESS
81 end
82
83
48 (83 %) samples spent in idasolfun
48 (100 %) (incl.) when called from IDASolve line 3500
function idasolfun(t::Float64, u::N_Vector, du::N_Vector, resid::N_Vector,
84 funjac::FunJac{N}) where {N}
85 funjac.u = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(u), size(funjac.u))
86 _u = funjac.u
87 funjac.du = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(du),
88 size(funjac.du))
89 _du = funjac.du
90 funjac.resid = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(resid),
91 size(funjac.resid))
92 _resid = funjac.resid
93 48 (83 %)
48 (100 %) samples spent calling DAEFunction
funjac.fun(_resid, _du, _u, funjac.p, t)
94 return IDA_SUCCESS
95 end
96
97 function idajac(t::realtype,
98 cj::realtype,
99 u::N_Vector,
100 du::N_Vector,
101 res::N_Vector,
102 J::SUNMatrix,
103 funjac::AbstractFunJac{Nothing},
104 tmp1::N_Vector,
105 tmp2::N_Vector,
106 tmp3::N_Vector)
107 N = ndims(funjac.u)
108 funjac.u = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(u), size(funjac.u))
109 _u = funjac.u
110 funjac.du = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(du),
111 size(funjac.du))
112 _du = funjac.du
113
114 funjac.jac(convert(Matrix, J), _du, _u, funjac.p, cj, t)
115 return IDA_SUCCESS
116 end
117
118 function idajac(t::realtype,
119 cj::realtype,
120 u::N_Vector,
121 du::N_Vector,
122 res::N_Vector,
123 _J::SUNMatrix,
124 funjac::AbstractFunJac{<:SparseArrays.SparseMatrixCSC},
125 tmp1::N_Vector,
126 tmp2::N_Vector,
127 tmp3::N_Vector)
128 jac_prototype = funjac.jac_prototype
129 N = ndims(funjac.u)
130 funjac.u = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(u), size(funjac.u))
131 _u = funjac.u
132 funjac.du = unsafe_wrap(Array{Float64, N}, N_VGetArrayPointer_Serial(du),
133 size(funjac.du))
134 _du = funjac.du
135
136 funjac.jac(jac_prototype, _du, _u, funjac.p, cj, t)
137
138 copyto!(_J, jac_prototype)
139
140 return IDA_SUCCESS
141 end
142
143 function massmat(t::Float64,
144 _M::SUNMatrix,
145 mmf::AbstractFunJac,
146 tmp1::N_Vector,
147 tmp2::N_Vector,
148 tmp3::N_Vector)
149 if mmf.mass_matrix isa Array
150 M = convert(Matrix, _M)
151 M .= mmf.mass_matrix
152 else
153 copyto!(_M, mmf.mass_matrix)
154 end
155
156 return IDA_SUCCESS
157 end
158
159 function jactimes(v::N_Vector,
160 Jv::N_Vector,
161 t::Float64,
162 y::N_Vector,
163 fy::N_Vector,
164 fj::AbstractFunJac,
165 tmp::N_Vector)
166 DiffEqBase.update_coefficients!(fj.jac_prototype, y, fj.p, t)
167 LinearAlgebra.mul!(convert(Vector, Jv), fj.jac_prototype, convert(Vector, v))
168 return CV_SUCCESS
169 end
170
171 function idajactimes(t::Float64,
172 y::N_Vector,
173 fy::N_Vector,
174 r::N_Vector,
175 v::N_Vector,
176 Jv::N_Vector,
177 cj::Float64,
178 fj::AbstractFunJac,
179 tmp1::N_Vector,
180 tmp2::N_Vector)
181 DiffEqBase.update_coefficients!(fj.jac_prototype, y, fj.p, t)
182 LinearAlgebra.mul!(convert(Vector, Jv), fj.jac_prototype, convert(Vector, v))
183 return IDA_SUCCESS
184 end
185
186 function precsolve(t::Float64,
187 y::N_Vector,
188 fy::N_Vector,
189 r::N_Vector,
190 z::N_Vector,
191 gamma::Float64,
192 delta::Float64,
193 lr::Int,
194 fj::AbstractFunJac)
195 fj.prec(convert(Vector, z),
196 convert(Vector, r),
197 fj.p,
198 t,
199 convert(Vector, y),
200 convert(Vector, fy),
201 gamma,
202 delta,
203 lr)
204 return CV_SUCCESS
205 end
206
207 function precsetup(t::Float64,
208 y::N_Vector,
209 fy::N_Vector,
210 jok::Int,
211 jcurPtr::Ref{Int},
212 gamma::Float64,
213 fj::AbstractFunJac)
214 fj.psetup(fj.p,
215 t,
216 convert(Vector, y),
217 convert(Vector, fy),
218 jok == 1,
219 Base.unsafe_wrap(Vector{Int}, jcurPtr, 1),
220 gamma)
221 return CV_SUCCESS
222 end
223
224 function idaprecsolve(t::Float64,
225 y::N_Vector,
226 fy::N_Vector,
227 resid::N_Vector,
228 r::N_Vector,
229 z::N_Vector,
230 gamma::Float64,
231 delta::Float64,
232 fj::AbstractFunJac)
233 fj.prec(convert(Vector, z),
234 convert(Vector, r),
235 fj.p,
236 t,
237 convert(Vector, y),
238 convert(Vector, fy),
239 convert(Vector, resid),
240 gamma,
241 delta)
242 return IDA_SUCCESS
243 end
244
245 function idaprecsetup(t::Float64,
246 y::N_Vector,
247 fy::N_Vector,
248 rr::N_Vector,
249 gamma::Float64,
250 fj::AbstractFunJac)
251 fj.psetup(fj.p, t, convert(Vector, rr), convert(Vector, y), convert(Vector, fy), gamma)
252 return IDA_SUCCESS
253 end