-
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.
Increase coverage with
P4estMesh
(#635)
* Add test for non-periodic structured P4estMesh * Add Euler gravity test with P4estMesh * Remove nboundaries(UnstructuredQuadSortedBoundaryTypes) * Move p4est Euler gravity tests to other p4est tests * Add news entry for P4estMesh
- Loading branch information
1 parent
98d9b44
commit a85c087
Showing
6 changed files
with
184 additions
and
9 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
71 changes: 71 additions & 0 deletions
71
examples/2d/elixir_euler_nonperiodic_p4est_unstructured.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,71 @@ | ||
|
||
using Downloads: download | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
|
||
equations = CompressibleEulerEquations2D(1.4) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
source_terms = source_terms_convergence_test | ||
|
||
# BCs must be passed as Dict | ||
boundary_condition = BoundaryConditionDirichlet(initial_condition) | ||
boundary_conditions = Dict( | ||
:all => boundary_condition | ||
) | ||
|
||
solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) | ||
|
||
############################################################################### | ||
# Get the uncurved mesh from a file (downloads the file if not available locally) | ||
|
||
# Unstructured mesh with 24 cells of the square domain [-1, 1]^n | ||
mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") | ||
isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", | ||
mesh_file) | ||
|
||
mesh = P4estMesh(mesh_file, initial_refinement_level=0) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
source_terms=source_terms, | ||
boundary_conditions=boundary_conditions) | ||
|
||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
analysis_callback = AnalysisCallback(semi, interval=analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval=analysis_interval) | ||
|
||
save_restart = SaveRestartCallback(interval=100, | ||
save_final_restart=true) | ||
|
||
save_solution = SaveSolutionCallback(interval=100, | ||
save_initial_solution=true, | ||
save_final_solution=true, | ||
solution_variables=cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl=1.0) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_restart, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
|
||
initial_condition = initial_condition_eoc_test_coupled_euler_gravity | ||
|
||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
gamma = 2.0 | ||
equations_euler = CompressibleEulerEquations2D(gamma) | ||
|
||
polydeg = 3 | ||
solver_euler = DGSEM(polydeg, flux_hll) | ||
|
||
coordinates_min = (0.0, 0.0) | ||
coordinates_max = (2.0, 2.0) | ||
|
||
trees_per_dimension = (1, 1) | ||
mesh = P4estMesh(trees_per_dimension, polydeg=1, | ||
coordinates_min=coordinates_min, coordinates_max=coordinates_max, | ||
initial_refinement_level=2) | ||
|
||
semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, | ||
source_terms=source_terms_eoc_test_coupled_euler_gravity) | ||
|
||
|
||
############################################################################### | ||
# semidiscretization of the hyperbolic diffusion equations | ||
equations_gravity = HyperbolicDiffusionEquations2D() | ||
|
||
solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) | ||
|
||
semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, | ||
source_terms=source_terms_harmonic) | ||
|
||
|
||
############################################################################### | ||
# combining both semidiscretizations for Euler + self-gravity | ||
parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 | ||
# rho0 is (ab)used to add a "+8π" term to the source terms | ||
# for the manufactured solution | ||
gravitational_constant=1.0, # aka G | ||
cfl=1.1, | ||
resid_tol=1.0e-10, | ||
n_iterations_max=1000, | ||
timestep_gravity=timestep_gravity_erk52_3Sstar!) | ||
|
||
semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) | ||
|
||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
tspan = (0.0, 0.5) | ||
ode = semidiscretize(semi, tspan); | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
stepsize_callback = StepsizeCallback(cfl=0.8) | ||
|
||
save_solution = SaveSolutionCallback(interval=10, | ||
save_initial_solution=true, | ||
save_final_solution=true, | ||
solution_variables=cons2prim) | ||
|
||
save_restart = SaveRestartCallback(interval=100, | ||
save_final_restart=true) | ||
|
||
analysis_interval = 100 | ||
alive_callback = AliveCallback(analysis_interval=analysis_interval) | ||
|
||
analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, | ||
save_analysis=true) | ||
|
||
callbacks = CallbackSet(summary_callback, stepsize_callback, | ||
save_restart, save_solution, | ||
analysis_callback, alive_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 | ||
println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) |
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