Path: blob/main/examples/tree_1d_dgsem/elixir_diffusion_ldg_dirichlet.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the pure diffusion equation56diffusivity() = 0.57equations = LinearDiffusionEquation1D(diffusivity())89# Create DG solver with polynomial degree = 310solver = DGSEM(polydeg = 3)11solver_parabolic = ParabolicFormulationLocalDG()1213# Create a uniformly refined mesh with nonperiodic boundaries14mesh = TreeMesh(0.0, 1.0,15initial_refinement_level = 4,16n_cells_max = 30_000, # set maximum capacity of tree data structure17periodicity = false)1819function analytical_solution(x, t, equations)20scalar = sinpi(x[1]) * exp(-diffusivity() * pi^2 * t)21return SVector(scalar)22end23initial_condition = analytical_solution2425boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition),26x_pos = BoundaryConditionDirichlet(initial_condition))2728# A semidiscretization collects data structures and functions for the spatial discretization29semi = SemidiscretizationParabolic(mesh, equations, initial_condition, solver;30solver_parabolic = solver_parabolic,31boundary_conditions = boundary_conditions)3233###############################################################################34# ODE solvers, callbacks etc.3536# Create ODE problem with time span from 0.0 to 1.037tspan = (0.0, 1.0)38ode = semidiscretize(semi, tspan)3940# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup41# and resets the timers42summary_callback = SummaryCallback()4344# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results45analysis_callback = AnalysisCallback(semi, interval = 100)4647# The AliveCallback prints short status information in regular intervals48alive_callback = AliveCallback(analysis_interval = 100)4950# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver51callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback)5253###############################################################################54# run the simulation5556# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks57# For CI purposes, we use fixed time-stepping for this elixir.58sol = solve(ode, RDPK3SpFSAL35(); dt = 1.0e-4, adaptive = false,59ode_default_options()..., callback = callbacks)606162