-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first draft IMEX JinXin #1963
base: JinXin
Are you sure you want to change the base?
first draft IMEX JinXin #1963
Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
There was a missing sign on my implementation, now the code seems to run well. I'm gonna make further test, clean up everything and improve the implementation where is possible. |
Could you please run the code formatter as described in https://trixi-framework.github.io/Trixi.jl/stable/styleguide/? |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Please find some comments below.
# Abstract base type for time integration schemes of explicit strong stability-preserving (SSP) | ||
# Runge-Kutta (RK) methods. They are high-order time discretizations that guarantee the TVD property. | ||
abstract type SimpleAlgorithmIMEX end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the comment
mesh, equations, solver, cache = Trixi.mesh_equations_solver_cache(semi) | ||
relaxation_rate = equations.eps_relaxation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we should have two options for this type of integrator:
- If Jin-Xin relaxation equations are used, do the IMEX stuff
- Otherwise, just apply the explicit method
We may not need to implement this right now but should keep a TODO note
for var in (nvars_base + 1):(nvars_base * 3) | ||
u_wrap[var, i, j, element] *= factor | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called set_to_zero!
but also multiplies the other variables by some factor
. Is this desired? If so, can we rename the function accordingly?
function set_cons_var_to_zero!(u, semi, solver, cache, equations, mesh::TreeMesh1D) | ||
u_wrap = Trixi.wrap_array(u, semi) | ||
nvars_base = nvariables(equations.equations_base) | ||
@unpack inverse_jacobian = cache.elements | ||
for element in eachelement(solver, cache) | ||
factor = inverse_jacobian[element] | ||
factor = 1.0 | ||
for i in eachnode(solver) | ||
for var in 1:nvars_base | ||
u_wrap[var, i, element] = 0.0 | ||
end | ||
for var in (nvars_base + 1):(nvars_base * 2) | ||
u_wrap[var, i, element] *= factor | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.r0,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.fu1,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.fu2,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.fu3,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.du1,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.du2,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.du3,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.u1,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.u2,) | ||
get_tmp_cache(integrator::SimpleIntegratorIMEX) = (integrator.u3,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one of these functions survives - so we should have only one version
""" | ||
modify_dt_for_tstops!(integrator::SimpleIntegratorSSP) | ||
Modify the time-step size to match the time stops specified in integrator.opts.tstops. | ||
To avoid adding OrdinaryDiffEq to Trixi's dependencies, this routine is a copy of | ||
https://github.com/SciML/OrdinaryDiffEq.jl/blob/d76335281c540ee5a6d1bd8bb634713e004f62ee/src/integrators/integrator_utils.jl#L38-L54 | ||
""" | ||
function modify_dt_for_tstops!(integrator::SimpleIntegratorIMEX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
modify_dt_for_tstops!(integrator::SimpleIntegratorSSP) | |
Modify the time-step size to match the time stops specified in integrator.opts.tstops. | |
To avoid adding OrdinaryDiffEq to Trixi's dependencies, this routine is a copy of | |
https://github.com/SciML/OrdinaryDiffEq.jl/blob/d76335281c540ee5a6d1bd8bb634713e004f62ee/src/integrators/integrator_utils.jl#L38-L54 | |
""" | |
function modify_dt_for_tstops!(integrator::SimpleIntegratorIMEX) |
function Base.resize!(semi::AbstractSemidiscretization, new_size) | ||
resize!(semi, semi.solver.volume_integral, new_size) | ||
end | ||
|
||
Base.resize!(semi, volume_integral::AbstractVolumeIntegral, new_size) = nothing | ||
|
||
function Base.resize!(semi, volume_integral::VolumeIntegralSubcellLimiting, new_size) | ||
# Resize container antidiffusive_fluxes | ||
resize!(semi.cache.antidiffusive_fluxes, new_size) | ||
|
||
# Resize container subcell_limiter_coefficients | ||
@unpack limiter = volume_integral | ||
resize!(limiter.cache.subcell_limiter_coefficients, new_size) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed here, is it?
Looks like you used another version of the JuliaFormatter for formatting resulting in many unrelated changes, see also #1976. Can you rerun the formatter with the other version, please? |
Co-authored-by: Hendrik Ranocha <[email protected]>
Co-authored-by: Hendrik Ranocha <[email protected]>
Co-authored-by: Hendrik Ranocha <[email protected]>
I made a first dirty and "straightforward" draft, but as I anticipated it might have some bugs. I still didn't generalize to keep it simple until I'm sure it will work. I broke it down to the simplest way to make it work, but I couldn't find any major mistakes.