-
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.
* First Version Shallow Water 1D * Testdatei * Testnachricht gelöscht * Testdatei geloescht * added examples tree_1d well balanced & blast wave * Add Elixier Tree_1D SWE well ball. & blast wave * Update examples/tree_1d_dgsem/elixir_shallowwater_ec.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_ec.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_ec.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_ec.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl Co-authored-by: Andrew Winters <[email protected]> * Update examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/Trixi.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * Update src/equations/shallow_water_1d.jl Co-authored-by: Andrew Winters <[email protected]> * WIP: create test files for SWE 1D * Working test file 1d shallowwater * SWE dirichlet WIP: no errors run, EOC h_v bad * SWE Dirichlet Source Term + Well Balanced * WIP: SWE Dirichlet EC + Slip Wall * Well balanced property for SWE slip wall * SWE non-periodic remaining files * Change requests from PR except second last * Removed normal_direction fluxes + update docs * Combine well-bal. nonperiodic, code style update * Boundary Tree 2d fix * 2d elixirs SWE sourceterms dirichlet added * Well balanced wall example * Minor docstring adjustment slip wall * wall elixir comment update Co-authored-by: Andrew Winters <[email protected]> * Updated comment wall elixir Co-authored-by: Andrew Winters <[email protected]> * Suggested changes changes slip wall * Possible solution TreeMesh? * Well balanced test Tree 2d * Fix convergence_test * Exclude strucctured mesh part Co-authored-by: Andrew Winters <[email protected]> * Updated TreeMesh Wall Co-authored-by: svengoldberg <[email protected]> Co-authored-by: svengoldberg <[email protected]> Co-authored-by: Andrew Winters <[email protected]> Co-authored-by: Hendrik Ranocha <[email protected]>
- Loading branch information
1 parent
06c826e
commit 514ef46
Showing
5 changed files
with
258 additions
and
6 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.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,61 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# Semidiscretization of the shallow water equations | ||
|
||
equations = ShallowWaterEquations2D(gravity_constant=9.81) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
boundary_condition = BoundaryConditionDirichlet(initial_condition) | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) | ||
solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), | ||
volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = (0.0, 0.0) | ||
coordinates_max = (sqrt(2.0), sqrt(2.0)) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level=3, | ||
n_cells_max=10_000, | ||
periodicity=false) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_condition, | ||
source_terms=source_terms_convergence_test) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 500 | ||
analysis_callback = AnalysisCallback(semi, interval=analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval=analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval=200, | ||
save_initial_solution=true, | ||
save_final_solution=true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# use a Runge-Kutta method with automatic (error based) time step size control | ||
sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, | ||
save_everystep=false, callback=callbacks); | ||
summary_callback() # print the timer summary |
119 changes: 119 additions & 0 deletions
119
examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.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,119 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the shallow water equations with a discontinuous | ||
# bottom topography function | ||
|
||
equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.25) | ||
|
||
# An initial condition with constant total water height and zero velocities to test well-balancedness. | ||
# Note, this routine is used to compute errors in the analysis callback but the initialization is | ||
# overwritten by `initial_condition_discontinuous_well_balancedness` below. | ||
function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) | ||
# Set the background values | ||
H = equations.H0 | ||
v1 = 0.0 | ||
v2 = 0.0 | ||
# bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) | ||
x1, x2 = x | ||
b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) | ||
+ 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) | ||
return prim2cons(SVector(H, v1, v2, b), equations) | ||
end | ||
|
||
initial_condition = initial_condition_well_balancedness | ||
|
||
boundary_condition = boundary_condition_slip_wall | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) | ||
surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) | ||
solver = DGSEM(polydeg=4, surface_flux=surface_flux, | ||
volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = (-1.0, -1.0) | ||
coordinates_max = (1.0, 1.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level=2, | ||
n_cells_max=10_000, | ||
periodicity = false) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_condition) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 100.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
############################################################################### | ||
# Workaround to set a discontinuous bottom topography and initial condition for debugging and testing. | ||
|
||
# alternative version of the initial conditinon used to setup a truly discontinuous | ||
# bottom topography function for this academic testcase of well-balancedness. | ||
# The errors from the analysis callback are not important but the error for this lake at rest test case | ||
# `∑|H0-(h+b)|` should be around machine roundoff | ||
# In contrast to the usual signature of initial conditions, this one get passed the | ||
# `element_id` explicitly. In particular, this initial conditions works as intended | ||
# only for the TreeMesh2D with initial_refinement_level=2. | ||
function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) | ||
# Set the background values | ||
H = equations.H0 | ||
v1 = 0.0 | ||
v2 = 0.0 | ||
b = 0.0 | ||
|
||
# Setup a discontinuous bottom topography using the element id number | ||
if element_id == 7 | ||
b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) | ||
end | ||
|
||
return prim2cons(SVector(H, v1, v2, b), equations) | ||
end | ||
|
||
# point to the data we want to augment | ||
u = Trixi.wrap_array(ode.u0, semi) | ||
# reset the initial condition | ||
for element in eachelement(semi.solver, semi.cache) | ||
for j in eachnode(semi.solver), i in eachnode(semi.solver) | ||
x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) | ||
u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) | ||
Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) | ||
end | ||
end | ||
|
||
############################################################################### | ||
# Callbacks | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 1000 | ||
analysis_callback = AnalysisCallback(semi, interval=analysis_interval, | ||
extra_analysis_integrals=(lake_at_rest_error,)) | ||
|
||
alive_callback = AliveCallback(analysis_interval=analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval=1000, | ||
save_initial_solution=true, | ||
save_final_solution=true) | ||
|
||
stepsize_callback = StepsizeCallback(cfl=3.0) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# 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 |
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