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

GLM speed calculations for coupled semidiscretizations #1835

Merged
merged 86 commits into from
May 3, 2024
Merged
Changes from 3 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
00d1e51
Added capability to the glm speed calculations to cope
iomsn Feb 6, 2024
9191121
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 6, 2024
00010e7
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 7, 2024
d37ab18
Update src/callbacks_step/glm_speed.jl
SimonCan Feb 7, 2024
02afd09
Update src/callbacks_step/glm_speed.jl
SimonCan Feb 7, 2024
d00e1c7
Corrected glm_speed issue for non-coupling simulations.
iomsn Feb 7, 2024
57327d9
Merge branch 'sc/glm_speed_coupled_semis' of https://github.com/trixi…
iomsn Feb 7, 2024
19e271d
Applied autoformatter.
iomsn Feb 8, 2024
52c674f
Added comment to glm speed.
iomsn Feb 8, 2024
8136c5f
Added temptative example elixir for coupled GlmMhd equations.
iomsn Feb 12, 2024
06f3a96
Added ability to deal with both, single semidiscretizations and multi…
iomsn Feb 13, 2024
228768b
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 15, 2024
8dea565
Added temporary fix for flux_nonconservative_powell function for
iomsn Feb 15, 2024
7f7a0ff
Fix in cumputing boundary fluxes in coupled domains
iomsn Feb 15, 2024
c098a51
Merge branch 'sc/glm_speed_coupled_semis' of https://github.com/trixi…
iomsn Feb 15, 2024
21717ba
Applied autoformatter.
iomsn Feb 15, 2024
0a346c5
Update src/callbacks_step/glm_speed.jl
SimonCan Feb 16, 2024
199106b
Update examples/structured_2d_dgsem/elixir_mhd_coupled.jl
SimonCan Feb 16, 2024
fb9b057
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 19, 2024
739b550
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 22, 2024
927406a
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Feb 26, 2024
cf51f90
Applied autoformatter.
iomsn Feb 28, 2024
5ac5bde
Added coupled 2d GLM-MHD simulations on structured grid in the tests.
iomsn Feb 28, 2024
dc81243
Added comment on adding non-conservative fluxes to the conservative f…
iomsn Feb 28, 2024
cda53ad
Changed the coupled GLM-MHD 2d example to an Alfven wave system.
iomsn Feb 28, 2024
73551c5
Removed redefined non-conservative Powell flux.
iomsn Feb 28, 2024
7a584a5
Redefined non-conservative Powell flux so it can be used with more ar…
iomsn Feb 28, 2024
28e7e7b
Debugged the extension of flux_nonconservative_powell.
iomsn Feb 28, 2024
6cce841
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 7, 2024
1e64eca
Added explicit periodicity to the meshes.
iomsn Mar 7, 2024
55a67ac
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 11, 2024
fd0055f
Applied autoformatter.
iomsn Mar 11, 2024
b686df7
Merge branch 'sc/glm_speed_coupled_semis' of https://github.com/trixi…
iomsn Mar 11, 2024
0ddaaae
Applied updated autoformatter.
iomsn Mar 12, 2024
8d8cfca
Fixed issue with the GlmSpeedCallback printing format.
iomsn Mar 13, 2024
7c3248c
Applied autoformatter.
iomsn Mar 13, 2024
2114a81
Update src/callbacks_step/glm_speed.jl
SimonCan Mar 14, 2024
630c91e
Clarified what we mean by semi_index.
iomsn Mar 14, 2024
55cf043
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Mar 14, 2024
4966c4f
Merge branch 'sc/glm_speed_coupled_semis' of https://github.com/trixi…
iomsn Mar 14, 2024
e8e2aba
Applied autoformatter.
iomsn Mar 14, 2024
ecd5ec7
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 15, 2024
8503e9b
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 19, 2024
6bbaa32
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 21, 2024
d2469f1
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 22, 2024
4889cfe
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Mar 29, 2024
3d879d0
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 2, 2024
5679230
Added how to to GLM speed callbacks in coupled systems.
SimonCan Apr 2, 2024
b186b8d
Added news item about the GLM speed calculation in coupled systems.
SimonCan Apr 2, 2024
2f8cd52
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 3, 2024
7086f76
Update NEWS.md
SimonCan Apr 15, 2024
5a0f83b
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 15, 2024
15634bc
Throw a descriptive error message if the equations of subtype Abstrac…
SimonCan Apr 15, 2024
1962b36
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 16, 2024
28a3c06
Added checking for semi_indices in case of SemidiscretizationCoupled.
SimonCan Apr 16, 2024
07e6f38
Added index of semidiscretization for GLM speed calculation.
SimonCan Apr 16, 2024
f6a917e
Merge branch 'sc/glm_speed_coupled_semis' of https://github.com/trixi…
SimonCan Apr 16, 2024
f3b18c2
Aplplied autoformatter.
SimonCan Apr 17, 2024
c952f08
Applied autoformatter.
SimonCan Apr 17, 2024
aa79c28
Update docs/src/multi-physics_coupling.md
SimonCan Apr 24, 2024
4acb302
Update docs/src/multi-physics_coupling.md
SimonCan Apr 24, 2024
c3c7936
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Apr 24, 2024
4715e52
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 24, 2024
6cd1baf
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 24, 2024
8f6c884
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 24, 2024
9653bad
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 24, 2024
ba3a92a
Updated semi_indices for glm speed calculations to Vector.
SimonCan Apr 24, 2024
b1e0bf5
Some refactoring of the GLM speed calculations for coupled systems.
SimonCan Apr 24, 2024
4a85672
Applied autoformatter.
SimonCan Apr 24, 2024
6bd2f87
Update examples/structured_2d_dgsem/elixir_mhd_coupled.jl
SimonCan Apr 25, 2024
9aa89a5
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
7e004c1
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
cfd2e47
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
603f9fe
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
ca011e3
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
a432fb4
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
01b374f
Update src/callbacks_step/glm_speed.jl
SimonCan Apr 25, 2024
c6d196d
Moved the update_cleaning_speed function for semi_coupled::Semidiscre…
SimonCan Apr 25, 2024
5984a2c
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 26, 2024
ff3c0df
Applied autoformatter.
SimonCan Apr 29, 2024
15bad8e
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 29, 2024
e288c54
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan Apr 30, 2024
c77d2a4
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan May 2, 2024
ccefbf9
Merge branch 'main' into sc/glm_speed_coupled_semis
SimonCan May 2, 2024
1469600
Update src/callbacks_step/glm_speed.jl
SimonCan May 3, 2024
d195d97
Merge branch 'main' into sc/glm_speed_coupled_semis
andrewwinters5000 May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions src/callbacks_step/glm_speed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
#! format: noindent

"""
GlmSpeedCallback(; glm_scale=0.5, cfl)
GlmSpeedCallback(; glm_scale=0.5, cfl, semi_indices=())

Update the divergence cleaning wave speed `c_h` according to the time step
computed in [`StepsizeCallback`](@ref) for the ideal GLM-MHD equations.
The `cfl` number should be set to the same value as for the time step size calculation. The
`glm_scale` ensures that the GLM wave speed is lower than the fastest physical waves in the MHD
solution and should thus be set to a value within the interval [0,1]. Note that `glm_scale = 0`
deactivates the divergence cleaning.
In case of a couplings semidiscretization specify for which semi_index the divergence
cleaning should be applied to.
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
"""
struct GlmSpeedCallback{RealT <: Real}
glm_scale::RealT
cfl::RealT
semi_indices::Tuple
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
end

function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:GlmSpeedCallback})
@nospecialize cb # reduce precompilation time

glm_speed_callback = cb.affect!
@unpack glm_scale, cfl = glm_speed_callback
print(io, "GlmSpeedCallback(glm_scale=", glm_scale, ", cfl=", cfl, ")")
@unpack glm_scale, cfl, semi_infices = glm_speed_callback
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
print(io, "GlmSpeedCallback(glm_scale=", glm_scale, ", cfl=", cfl, "semi_indices=", semi_infices, ")")
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
end

function Base.show(io::IO, ::MIME"text/plain",
Expand All @@ -40,15 +43,16 @@ function Base.show(io::IO, ::MIME"text/plain",
setup = [
"GLM wave speed scaling" => glm_speed_callback.glm_scale,
"Expected CFL number" => glm_speed_callback.cfl,
# "Coupled semidiscretization indices" => glm_speed_callback.semi_indices,
]
summary_box(io, "GlmSpeedCallback", setup)
end
end

function GlmSpeedCallback(; glm_scale = 0.5, cfl)
function GlmSpeedCallback(; glm_scale = 0.5, cfl, semi_indices = ())
@assert 0<=glm_scale<=1 "glm_scale must be between 0 and 1"

glm_speed_callback = GlmSpeedCallback(glm_scale, cfl)
glm_speed_callback = GlmSpeedCallback(glm_scale, cfl, semi_indices)

DiscreteCallback(glm_speed_callback, glm_speed_callback, # the first one is the condition, the second the affect!
save_positions = (false, false),
Expand All @@ -69,17 +73,25 @@ end
@inline function (glm_speed_callback::GlmSpeedCallback)(integrator)
dt = get_proposed_dt(integrator)
semi = integrator.p
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
@unpack glm_scale, cfl = glm_speed_callback

@unpack glm_scale, cfl, semi_indices = glm_speed_callback

# compute time step for GLM linear advection equation with c_h=1 (redone due to the possible AMR)
c_h_deltat = calc_dt_for_cleaning_speed(cfl, mesh, equations, solver, cache)

# c_h is proportional to its own time step divided by the complete MHD time step
equations.c_h = glm_scale * c_h_deltat / dt
if length(semi_indices) == 0
semi = tuple(semi)
end

# avoid re-evaluating possible FSAL stages
u_modified!(integrator, false)
for semi_index in semi_indices
mesh, equations, solver, cache = mesh_equations_solver_cache(semi.semis[semi_index])

# compute time step for GLM linear advection equation with c_h=1 (redone due to the possible AMR)
c_h_deltat = calc_dt_for_cleaning_speed(cfl, mesh, equations, solver, cache)

# c_h is proportional to its own time step divided by the complete MHD time step
equations.c_h = glm_scale * c_h_deltat / dt

# avoid re-evaluating possible FSAL stages
u_modified!(integrator, false)
end

return nothing
end
Expand Down
Loading