Path: blob/main/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic_perk4.jl
2055 views
using Trixi12# Convex and ECOS are imported because they are used for finding the optimal time step and optimal3# monomial coefficients in the stability polynomial of P-ERK time integrators.4using Convex, ECOS56###############################################################################7# semidiscretization of the hyperbolic diffusion equations89equations = HyperbolicDiffusionEquations1D()1011initial_condition = initial_condition_poisson_nonperiodic1213boundary_conditions = boundary_condition_poisson_nonperiodic1415solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs)1617coordinates_min = 0.018coordinates_max = 1.019mesh = TreeMesh(coordinates_min, coordinates_max,20initial_refinement_level = 3,21n_cells_max = 30_000,22periodicity = false)2324semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,25boundary_conditions = boundary_conditions,26source_terms = source_terms_poisson_nonperiodic)2728###############################################################################29# ODE solvers, callbacks etc.3031tspan = (0.0, 5.0)32ode = semidiscretize(semi, tspan);3334summary_callback = SummaryCallback()3536resid_tol = 5.0e-1237steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0)3839analysis_interval = 10040analysis_callback = AnalysisCallback(semi, interval = analysis_interval)4142alive_callback = AliveCallback(analysis_interval = analysis_interval)4344# Construct fourth order paired explicit Runge-Kutta method with 11 stages for given simulation setup.45# Pass `tspan` to calculate maximum time step allowed for the bisection algorithm used46# in calculating the polynomial coefficients in the ODE algorithm.47ode_algorithm = Trixi.PairedExplicitRK4(11, tspan, semi)4849cfl_number = Trixi.calculate_cfl(ode_algorithm, ode)50stepsize_callback = StepsizeCallback(cfl = 0.9 * cfl_number)5152callbacks = CallbackSet(summary_callback,53analysis_callback, alive_callback,54stepsize_callback)5556###############################################################################57# run the simulation5859sol = Trixi.solve(ode, ode_algorithm;60dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback61ode_default_options()..., callback = callbacks);626364