|
| 1 | +using OrdinaryDiffEq |
| 2 | +using Trixi |
| 3 | + |
| 4 | +#schaer mountain test case |
| 5 | + |
| 6 | +# Initial condition |
| 7 | +function initial_condition_schaer_mountain(x, t, |
| 8 | + equations::CompressibleEulerEquationsWithGravity2D) |
| 9 | + g = 9.81 |
| 10 | + c_p = 1004.0 |
| 11 | + c_v = 717.0 |
| 12 | + gamma = c_p / c_v |
| 13 | + |
| 14 | + # Exner pressure from hydrostatic balance for x[2] |
| 15 | + potential_temperature_int = 280.0 #constant of integration |
| 16 | + bvfrequency = 0.01 #Brunt-Väisälä frequency |
| 17 | + |
| 18 | + exner = 1 + |
| 19 | + g^2 / (c_p * potential_temperature_int * bvfrequency^2) * |
| 20 | + (exp(-bvfrequency^2 / g * x[2]) - 1) |
| 21 | + |
| 22 | + # mean potential temperature |
| 23 | + potential_temperature = potential_temperature_int * exp(bvfrequency^2 / g * x[2]) |
| 24 | + |
| 25 | + # temperature |
| 26 | + T = potential_temperature * exner |
| 27 | + |
| 28 | + # pressure |
| 29 | + p_0 = 100_000.0 # reference pressure |
| 30 | + R = c_p - c_v # gas constant (dry air) |
| 31 | + p = p_0 * exner^(c_p / R) |
| 32 | + |
| 33 | + # density |
| 34 | + rho = p / (R * T) |
| 35 | + |
| 36 | + #Geopotential |
| 37 | + phi = g * x[2] |
| 38 | + |
| 39 | + v1 = 10.0 |
| 40 | + v2 = 0.0 |
| 41 | + E = c_v * T + 0.5 * (v1^2 + v2^2) + phi |
| 42 | + return SVector(rho, rho * v1, rho * v2, rho * E, phi) |
| 43 | +end |
| 44 | + |
| 45 | +############################################################################### |
| 46 | + |
| 47 | +function mapping(xi_, eta_) |
| 48 | + xi = xi_ * 25_000 #xi_ * 10_000.0 |
| 49 | + eta = eta_ * 10_500 + 10_500# eta_ * 500.0 + 500.0 |
| 50 | + #upper boundary |
| 51 | + H = 21_000.0 |
| 52 | + |
| 53 | + #topography |
| 54 | + h_c = 250.0 |
| 55 | + lambda_c = 4000.0 |
| 56 | + a_c = 5000.0 |
| 57 | + |
| 58 | + topo = -h_c * exp(-(xi / a_c)^2) * cos(pi * xi / lambda_c)^2 |
| 59 | + |
| 60 | + x = xi |
| 61 | + y = H * (eta - topo) / (H - topo) |
| 62 | + return SVector(x, y) |
| 63 | +end |
| 64 | + |
| 65 | +# Create curved mesh with 200 x 100 elements |
| 66 | +polydeg = 3 |
| 67 | +cells_per_dimension = (60, 30) |
| 68 | +mesh = P4estMesh(cells_per_dimension; polydeg = polydeg, mapping = mapping, |
| 69 | + periodicity = false) |
| 70 | + |
| 71 | +############################################################################### |
| 72 | +# semidiscretization of the compressible Euler equations |
| 73 | +equations = CompressibleEulerEquationsWithGravity2D(1004.0 / 717.0) |
| 74 | + |
| 75 | +initial_condition = initial_condition_schaer_mountain |
| 76 | + |
| 77 | +boundary_conditions_dirichlet = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition_schaer_mountain), |
| 78 | + :x_pos => BoundaryConditionDirichlet(initial_condition_schaer_mountain), |
| 79 | + :y_neg => boundary_condition_slip_wall, |
| 80 | + :y_pos => boundary_condition_slip_wall) |
| 81 | + |
| 82 | +basis = LobattoLegendreBasis(polydeg) |
| 83 | + |
| 84 | +volume_flux = (flux_kennedy_gruber, flux_nonconservative_waruszewski) |
| 85 | +surface_flux = (FluxLMARS(340.0), flux_nonconservative_waruszewski) |
| 86 | + |
| 87 | +volume_integral = VolumeIntegralFluxDifferencing(volume_flux) |
| 88 | + |
| 89 | +solver = DGSEM(basis, surface_flux, volume_integral) |
| 90 | + |
| 91 | +coordinates_min = (-25_000.0, 0.0) |
| 92 | +coordinates_max = (25_000.0, 21_000.0) |
| 93 | + |
| 94 | +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, |
| 95 | + boundary_conditions = boundary_conditions_dirichlet) |
| 96 | + |
| 97 | +############################################################################### |
| 98 | +# ODE solvers, callbacks etc. |
| 99 | + |
| 100 | +tspan = (0.0, 60 * 60)# * 10) # 10h = 36000 s |
| 101 | + |
| 102 | +ode = semidiscretize(semi, tspan) |
| 103 | + |
| 104 | +summary_callback = SummaryCallback() |
| 105 | + |
| 106 | +analysis_interval = 1000 |
| 107 | +solution_variables = cons2prim |
| 108 | + |
| 109 | +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, |
| 110 | + extra_analysis_errors = (:entropy_conservation_error,)) |
| 111 | + |
| 112 | +alive_callback = AliveCallback(analysis_interval = analysis_interval) |
| 113 | + |
| 114 | +save_solution = SaveSolutionCallback(interval = analysis_interval, |
| 115 | + save_initial_solution = true, |
| 116 | + save_final_solution = true, |
| 117 | + output_directory = "out", |
| 118 | + solution_variables = solution_variables) |
| 119 | + |
| 120 | +stepsize_callback = StepsizeCallback(cfl = 1.0) |
| 121 | + |
| 122 | +callbacks = CallbackSet(summary_callback, |
| 123 | + analysis_callback, |
| 124 | + alive_callback, |
| 125 | + save_solution, |
| 126 | + stepsize_callback) |
| 127 | + |
| 128 | +############################################################################### |
| 129 | +# run the simulation |
| 130 | +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), |
| 131 | + maxiters = 1.0e7, |
| 132 | + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback |
| 133 | + save_everystep = false, callback = callbacks); |
| 134 | + |
| 135 | +summary_callback() |
0 commit comments