Skip to content
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

Open
wants to merge 13 commits into
base: JinXin
Choose a base branch
from

Conversation

MarcoArtiano
Copy link

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.

Copy link
Contributor

Review checklist

This 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

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

@MarcoArtiano
Copy link
Author

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.

@ranocha
Copy link
Member

ranocha commented Jun 3, 2024

Could you please run the code formatter as described in https://trixi-framework.github.io/Trixi.jl/stable/styleguide/?

@MarcoArtiano
Copy link
Author

Could you please run the code formatter as described in https://trixi-framework.github.io/Trixi.jl/stable/styleguide/?

Done!

Copy link
Member

@ranocha ranocha left a 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.

Comment on lines +8 to +10
# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the comment

src/time_integration/methods_IMEXJinXin.jl Outdated Show resolved Hide resolved
src/time_integration/methods_IMEXJinXin.jl Outdated Show resolved Hide resolved
src/time_integration/methods_IMEXJinXin.jl Outdated Show resolved Hide resolved
Comment on lines +219 to +220
mesh, equations, solver, cache = Trixi.mesh_equations_solver_cache(semi)
relaxation_rate = equations.eps_relaxation
Copy link
Member

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

Comment on lines +442 to +444
for var in (nvars_base + 1):(nvars_base * 3)
u_wrap[var, i, j, element] *= factor
end
Copy link
Member

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?

Comment on lines +450 to +464
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines +649 to +658
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,)
Copy link
Member

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

Comment on lines +678 to +684
"""
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
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)

Comment on lines +714 to +727
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
Copy link
Member

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?

@JoshuaLampert
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants