-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GLM speed calculations for coupled semidiscretizations (#1835)
* Added capability to the glm speed calculations to cope with coupled semidiscretizations. * Update src/callbacks_step/glm_speed.jl Co-authored-by: Joshua Lampert <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Joshua Lampert <[email protected]> * Corrected glm_speed issue for non-coupling simulations. Just had to make sure it can handle the situation where there is only one semidiscretization. * Applied autoformatter. * Added comment to glm speed. * Added temptative example elixir for coupled GlmMhd equations. This requires the modified callback for the GLM cleaning speed. * Added ability to deal with both, single semidiscretizations and multiple one when it comes to GlmMhd. * Added temporary fix for flux_nonconservative_powell function for IdealGlmMhdEquations2D. * Fix in cumputing boundary fluxes in coupled domains for the case of conservative and non-conservative fluxes. * Applied autoformatter. * Update src/callbacks_step/glm_speed.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/structured_2d_dgsem/elixir_mhd_coupled.jl Co-authored-by: Andrew Winters <[email protected]> * Applied autoformatter. * Added coupled 2d GLM-MHD simulations on structured grid in the tests. * Added comment on adding non-conservative fluxes to the conservative fluxes. * Changed the coupled GLM-MHD 2d example to an Alfven wave system. * Removed redefined non-conservative Powell flux. * Redefined non-conservative Powell flux so it can be used with more arguments. * Debugged the extension of flux_nonconservative_powell. * Added explicit periodicity to the meshes. * Applied autoformatter. * Applied updated autoformatter. * Fixed issue with the GlmSpeedCallback printing format. * Applied autoformatter. * Update src/callbacks_step/glm_speed.jl Co-authored-by: Andrew Winters <[email protected]> * Clarified what we mean by semi_index. * Update src/semidiscretization/semidiscretization_coupled.jl Co-authored-by: Andrew Winters <[email protected]> * Applied autoformatter. * Added how to to GLM speed callbacks in coupled systems. * Added news item about the GLM speed calculation in coupled systems. * Update NEWS.md Co-authored-by: Joshua Lampert <[email protected]> * Throw a descriptive error message if the equations of subtype AbstractIdealGlmMhdEquations are not included in the list of semidiscretizations of AbstractIdealGlmMhdEquations. * Added checking for semi_indices in case of SemidiscretizationCoupled. * Added index of semidiscretization for GLM speed calculation. * Aplplied autoformatter. * Applied autoformatter. * Update docs/src/multi-physics_coupling.md Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update docs/src/multi-physics_coupling.md Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/semidiscretization/semidiscretization_coupled.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Updated semi_indices for glm speed calculations to Vector. * Some refactoring of the GLM speed calculations for coupled systems. * Applied autoformatter. * Update examples/structured_2d_dgsem/elixir_mhd_coupled.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Moved the update_cleaning_speed function for semi_coupled::SemidiscretizationCoupled to src/semidiscretization/semidiscretization_coupled.jl. * Applied autoformatter. * Update src/callbacks_step/glm_speed.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> --------- Co-authored-by: iomsn <[email protected]> Co-authored-by: Joshua Lampert <[email protected]> Co-authored-by: Andrew Winters <[email protected]> Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
- Loading branch information
1 parent
adba1bb
commit cd097fc
Showing
6 changed files
with
284 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# Two semidiscretizations of the ideal GLM-MHD systems using converter functions such that | ||
# they are coupled across the domain boundaries to generate a periodic system. | ||
# | ||
# In this elixir, we have a square domain that is divided into a left and right half. | ||
# On each half of the domain, an independent SemidiscretizationHyperbolic is created for | ||
# each set of ideal GLM-MHD equations. The two systems are coupled in the x-direction | ||
# and are periodic in the y-direction. | ||
# For a high-level overview, see also the figure below: | ||
# | ||
# (-2, 2) ( 2, 2) | ||
# ┌────────────────────┬────────────────────┐ | ||
# │ ↑ periodic ↑ │ ↑ periodic ↑ │ | ||
# │ │ │ | ||
# │ ========= │ ========= │ | ||
# │ system #1 │ system #2 │ | ||
# │ ========= │ ========= │ | ||
# │ │ │ | ||
# │<-- coupled │<-- coupled │ | ||
# │ coupled -->│ coupled -->│ | ||
# │ │ │ | ||
# │ ↓ periodic ↓ │ ↓ periodic ↓ │ | ||
# └────────────────────┴────────────────────┘ | ||
# (-2, -2) ( 2, -2) | ||
|
||
gamma = 5 / 3 | ||
equations = IdealGlmMhdEquations2D(gamma) | ||
|
||
cells_per_dimension = (32, 64) | ||
|
||
# Extend the definition of the non-conservative Powell flux functions. | ||
import Trixi.flux_nonconservative_powell | ||
function flux_nonconservative_powell(u_ll, u_rr, | ||
normal_direction_ll::AbstractVector, | ||
equations::IdealGlmMhdEquations2D) | ||
flux_nonconservative_powell(u_ll, u_rr, normal_direction_ll, normal_direction_ll, | ||
equations) | ||
end | ||
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) | ||
solver = DGSEM(polydeg = 3, | ||
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
########### | ||
# system #1 | ||
########### | ||
|
||
initial_condition1 = initial_condition_convergence_test | ||
coordinates_min1 = (-1 / sin(pi / 4), -1 / sin(pi / 4)) | ||
coordinates_max1 = (0.0, 1 / sin(pi / 4)) | ||
mesh1 = StructuredMesh(cells_per_dimension, | ||
coordinates_min1, | ||
coordinates_max1, | ||
periodicity = (false, true)) | ||
|
||
coupling_function1 = (x, u, equations_other, equations_own) -> u | ||
boundary_conditions1 = (x_neg = BoundaryConditionCoupled(2, (:end, :i_forward), Float64, | ||
coupling_function1), | ||
x_pos = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64, | ||
coupling_function1), | ||
y_neg = boundary_condition_periodic, | ||
y_pos = boundary_condition_periodic) | ||
|
||
semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition1, solver, | ||
boundary_conditions = boundary_conditions1) | ||
|
||
########### | ||
# system #2 | ||
########### | ||
|
||
initial_condition2 = initial_condition_convergence_test | ||
coordinates_min2 = (0.0, -1 / sin(pi / 4)) | ||
coordinates_max2 = (1 / sin(pi / 4), 1 / sin(pi / 4)) | ||
mesh2 = StructuredMesh(cells_per_dimension, | ||
coordinates_min2, | ||
coordinates_max2, | ||
periodicity = (false, true)) | ||
|
||
coupling_function2 = (x, u, equations_other, equations_own) -> u | ||
boundary_conditions2 = (x_neg = BoundaryConditionCoupled(1, (:end, :i_forward), Float64, | ||
coupling_function2), | ||
x_pos = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64, | ||
coupling_function2), | ||
y_neg = boundary_condition_periodic, | ||
y_pos = boundary_condition_periodic) | ||
|
||
semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition2, solver, | ||
boundary_conditions = boundary_conditions2) | ||
|
||
# Create a semidiscretization that bundles all the semidiscretizations. | ||
semi = SemidiscretizationCoupled(semi1, semi2) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.1) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
|
||
analysis_callback1 = AnalysisCallback(semi1, interval = 100) | ||
analysis_callback2 = AnalysisCallback(semi2, interval = 100) | ||
analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 50, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
solution_variables = cons2prim) | ||
|
||
cfl = 1.0 | ||
|
||
stepsize_callback = StepsizeCallback(cfl = cfl) | ||
|
||
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl, | ||
semi_indices = [1, 2]) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_solution, | ||
stepsize_callback, | ||
glm_speed_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 0.01, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters