Alright, although I am not sure whether this is helpful or not, my two structs are
# This struct is needed to fake
# https://github.com/SciML/OrdinaryDiffEq.jl/blob/0c2048a502101647ac35faabd80da8a5645beac7/src/integrators/type.jl#L77
# This implements the interface components described at
# https://diffeq.sciml.ai/v6.8/basics/integrator/#Handing-Integrators-1
# which are used in Trixi.
mutable struct Integrator{RealT <: Real, uType, Params, Sol, F, Alg,
IntegratorOptions}
u::uType
du::uType
u_tmp::uType
t::RealT
dt::RealT # current time step
dtcache::RealT # Used for euler-acoustic coupling
iter::Int # current number of time steps (iteration)
p::Params # will be the semidiscretization from Trixi
sol::Sol # faked
f::F
alg::Alg # This is our own class written above; Abbreviation for ALGorithm
opts::IntegratorOptions
finalstep::Bool # added for convenience
# stages:
k1::uType
k_higher::uType
k_S1::uType
t_stage::RealT
end
and
# This struct is needed to fake
# https://github.com/SciML/OrdinaryDiffEq.jl/blob/0c2048a502101647ac35faabd80da8a5645beac7/src/integrators/type.jl#L77
# This implements the interface components described at
# https://diffeq.sciml.ai/v6.8/basics/integrator/#Handing-Integrators-1
# which are used in Trixi.
mutable struct Multi_Integrator{RealT <: Real, uType, Params, Sol, F, Alg,
IntegratorOptions}
u::uType
du::uType
u_tmp::uType
t::RealT
dt::RealT # current time step
dtcache::RealT # Used for euler-acoustic coupling
iter::Int # current number of time steps (iteration)
p::Params # will be the semidiscretization from Trixi
sol::Sol # faked
f::F
alg::Alg # This is our own class written above; Abbreviation for ALGorithm
opts::IntegratorOptions
finalstep::Bool # added for convenience
# stages:
k1::uType
k_higher::uType
k_S1::uType
# Variables managing level-depending integration
level_info_elements::Vector{Vector{Int64}}
level_info_elements_acc::Vector{Vector{Int64}}
level_info_interfaces_acc::Vector{Vector{Int64}}
level_info_boundaries_acc::Vector{Vector{Int64}}
level_info_boundaries_orientation_acc::Vector{Vector{Vector{Int64}}}
level_info_mortars_acc::Vector{Vector{Int64}}
level_u_indices_elements::Vector{Vector{Int64}}
t_stage::RealT
coarsest_lvl::Int64
n_levels::Int64
end
where alg::Alg
is the only argument that is different for the structures out of RealT <: Real, uType, Params, Sol, F, Alg, IntegratorOptions
.
The function corresponding to foo()
is given by
function k1k2!(integrator, p, c)
integrator.f(integrator.du, integrator.u, p, integrator.t)
@threaded for i in eachindex(integrator.du)
integrator.k1[i] = integrator.du[i] * integrator.dt
end
integrator.t_stage = integrator.t + c[2] * integrator.dt
@threaded for i in eachindex(integrator.u)
integrator.u_tmp[i] = integrator.u[i] + c[2] * integrator.k1[i]
end
end
where @threaded
is a macro essentially equivalent to @batch
from Polyester.jl.