-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trixi-framework:main' into initial_docs
- Loading branch information
Showing
23 changed files
with
1,349 additions
and
203 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
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
116 changes: 116 additions & 0 deletions
116
examples/tree_1d_dgsem/elixir_shallowwater_exner_channel.jl
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,116 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
using TrixiShallowWater | ||
using Roots | ||
|
||
############################################################################### | ||
# Semidiscretization of the shallow water exner equations for a channel flow problem | ||
# with sediment transport | ||
|
||
equations = ShallowWaterExnerEquations1D(gravity_constant = 9.81, rho_f = 1.0, rho_s = 1.0, | ||
porosity = 0.4, | ||
sediment_model = GrassModel(A_g = 0.01)) | ||
|
||
# Initial condition for for a channel flow problem over a sediment hump. | ||
# An asymptotic solution based on the method of characteristics was derived under a rigid-lid | ||
# approximation in chapter 3.5.1 of the thesis: | ||
# - Justin Hudson (2001) | ||
# "Numerical Techniques for Morphodynamic Modelling" | ||
# [PhD Thesis, University of Reading](https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=f78dbae9cfbb12ae823975c6ce9d2585b40417ba) | ||
function initial_condition_channel(x, t, | ||
equations::ShallowWaterExnerEquations1D) | ||
(; sediment_model, porosity_inv) = equations | ||
|
||
H_ref = 10.0 # Reference water level | ||
hv = 10.0 | ||
|
||
# Use the method of characteristics to find the asymptotic solution for the bed height, see | ||
# Eq. 3.16 in the reference. | ||
# First use an iterative method to predict x0 | ||
f(x0) = x[1] - x0 - | ||
sediment_model.A_g * porosity_inv * 3 * hv^3 * t * | ||
(H_ref - sinpi((x0 - 300) / 200)^2)^(-4) | ||
fx = Roots.ZeroProblem(f, 400.0) | ||
x0 = Roots.solve(fx, atol = 0.0, rtol = 0.0) | ||
|
||
# If the result is outside 300 < x < 500 the result is invalid and instead compute x0 from | ||
if x0 > 500 || x0 < 300 | ||
x0 = x[1] - | ||
sediment_model.A_g * porosity_inv * 3 * hv^3 * t * H_ref^(-4) | ||
end | ||
|
||
# Compute the sediment and water height | ||
300 < x0 < 500 ? h_b = 0.1 + sinpi((x0 - 300) / 200)^2 : h_b = 0.1 | ||
h = H_ref - h_b | ||
|
||
return SVector(h, hv, h_b) | ||
end | ||
|
||
initial_condition = initial_condition_channel | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_ersing_etal, flux_nonconservative_ersing_etal) | ||
surface_flux = (FluxPlusDissipation(flux_ersing_etal, dissipation_roe), | ||
flux_nonconservative_ersing_etal) | ||
|
||
basis = LobattoLegendreBasis(6) | ||
|
||
indicator_sc = IndicatorHennemannGassner(equations, basis, | ||
alpha_max = 0.5, | ||
alpha_min = 0.001, | ||
alpha_smooth = true, | ||
variable = water_sediment_height) | ||
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; | ||
volume_flux_dg = volume_flux, | ||
volume_flux_fv = surface_flux) | ||
|
||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = 0.0 | ||
coordinates_max = 1000.0 | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 4, | ||
n_cells_max = 10_000, | ||
periodicity = true) | ||
|
||
# Create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solver | ||
|
||
tspan = (0.0, 30_000.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
############################################################################### | ||
# Callbacks | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 10000 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.8) | ||
|
||
save_solution = SaveSolutionCallback(dt = 10_000.0, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, | ||
stepsize_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # 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 |
69 changes: 69 additions & 0 deletions
69
examples/tree_1d_dgsem/elixir_shallowwater_exner_source_terms_grass.jl
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,69 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
using TrixiShallowWater | ||
|
||
############################################################################### | ||
# Semidiscretization of the SWE-Exner equations with source terms for convergence testing | ||
|
||
# Equations with Grass model | ||
equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5, | ||
rho_s = 1.0, porosity = 0.5, | ||
friction = ManningFriction(n = 0.0), | ||
sediment_model = GrassModel(A_g = 0.01)) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_ersing_etal, flux_nonconservative_ersing_etal) | ||
surface_flux = (flux_ersing_etal, flux_nonconservative_ersing_etal) | ||
|
||
solver = DGSEM(polydeg = 4, | ||
surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = 0.0 | ||
coordinates_max = sqrt(2.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 2, | ||
n_cells_max = 10_000, | ||
periodicity = true) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
source_terms = source_terms_convergence_test) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 200 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 1.0) | ||
|
||
save_solution = SaveSolutionCallback(interval = 200, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, | ||
stepsize_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # 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 |
70 changes: 70 additions & 0 deletions
70
examples/tree_1d_dgsem/elixir_shallowwater_exner_source_terms_mpm.jl
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,70 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
using TrixiShallowWater | ||
|
||
############################################################################### | ||
# Semidiscretization of the SWE-Exner equations with source terms for convergence testing | ||
|
||
# Equations with Meyer-Peter-Mueller model | ||
equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5, | ||
rho_s = 1.0, porosity = 0.5, | ||
friction = ManningFriction(n = 0.01), | ||
sediment_model = MeyerPeterMueller(theta_c = 0.0, | ||
d_s = 1e-3)) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_ersing_etal, flux_nonconservative_ersing_etal) | ||
surface_flux = (flux_ersing_etal, flux_nonconservative_ersing_etal) | ||
|
||
solver = DGSEM(polydeg = 4, | ||
surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = 0.0 | ||
coordinates_max = sqrt(2.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 2, | ||
n_cells_max = 10_000, | ||
periodicity = true) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
source_terms = source_terms_convergence_test) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 200 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 1.0) | ||
|
||
save_solution = SaveSolutionCallback(interval = 200, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, | ||
stepsize_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # 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 |
Oops, something went wrong.