Simulator
#
homemade_conslaws.Simulator
— Type.
Simulator{GridType <: Grid, Float <: AbstractFloat}
A type representing a simulation of a conservation law on a grid. The simulation is described by a ConservedSystem
and a GridType
.
#
homemade_conslaws.simulate!
— Method.
simulate!(simulator::Simulator, T, max_dt, callbacks::Vector{Callback}=[]) where Callback
Simulate the system described by simulator
until time T
using a time step size of at most max_dt
. The callbacks
are called at each time step. The cell averages are mutated in place.
Example
eq = BurgersEQ()
bc = NeumannBC()
N = 20
x_L, x_R = 0.0, 1.0
x = cell_centers(N, x_L, x_R)
u0(x) = x .< 0.5 ? 1.0 : 0.0
U0 = u0.(x)
grid = UniformGrid1D(N, bc, U0, (x_L, x_R))
F = LaxFriedrichsFlux()
reconstruction = NoReconstruction()
timestepper = ForwardEuler(grid)
system = ConservedSystem(eq, reconstruction, F, timestepper)
simulator = Simulator(system, grid, 0.)
simulate!(simulator, 1., 0.1)
U = cells(grid)
#
homemade_conslaws.simulate_and_aggregate!
— Method.
simulate_and_aggregate!(simulator::Simulator, T, max_dt, callbacks::Vector{Callback}=[]) where Callback
The same as simulate!
but keeps track of and returns the cell averages and time at each time step.
Example
eq = BurgersEQ()
bc = NeumannBC()
N = 20
x_L, x_R = 0.0, 1.0
x = cell_centers(N, x_L, x_R)
u0(x) = x .< 0.5 ? 1.0 : 0.0
U0 = u0.(x)
grid = UniformGrid1D(N, bc, U0, (x_L, x_R))
F = LaxFriedrichsFlux()
reconstruction = NoReconstruction()
timestepper = ForwardEuler(grid)
system = ConservedSystem(eq, reconstruction, F, timestepper)
simulator = Simulator(system, grid, 0.)
U, t = simulate_and_aggregate!(simulator, 1., 0.1)
u(x, t) = u0(x-0.5t)
Viz.animate_solution(U', u, grid, t, 2)
#
homemade_conslaws.ConservedSystem
— Type.
ConservedSystem{EquationType <: Equation, ReconstructionType <: Reconstruction, NumericalFluxType <: NumericalFlux, TimeStepperType <: TimeStepper}
A wrapper around the objects (equation, reconstruction, numerical flux, and time stepper) needed to solve a conservation law.