SimpleDiscontinuousGalerkin.jl API

SimpleDiscontinuousGalerkin.SimpleDiscontinuousGalerkinModule
SimpleDiscontinuousGalerkin

SimpleDiscontinuousGalerkin.jl is a Julia package that implements some basic discontinuous Galerkin (DG) methods for the solution of hyperbolic partial differential equations (PDEs). The package is designed to be simple and easy to use and understand. It is intended for educational purposes and to provide a starting point for more complex DG methods. For a more comprehensive and advanced implementation of DG methods, we recommend using the package Trixi.jl. This package can be understood as a minimalistic version of Trixi.jl, which is designed to be easy to understand and modify. Many design concepts are inspired by Trixi.jl, but the implementation is much simpler and more straightforward.

SimpleDiscontinuousGalerkin.jl builds on the foundations of the package SummationByPartsOperators.jl.

See also: SimpleDiscontinuousGalerkin.jl

source

Equations

SimpleDiscontinuousGalerkin.flux_ecMethod
flux_ec(u_ll, u_rr, equations::BurgersEquation1D)

Entropy-conserving, symmetric flux for the inviscid Burgers' equation.

\[F(u_L, u_R) = \frac{u_L^2 + u_L u_R + u_R^2}{6}\]

source
SimpleDiscontinuousGalerkin.CompressibleEulerEquations1DType
CompressibleEulerEquations1D(gamma)

The compressible Euler equations

\[\frac{\partial}{\partial t} \begin{pmatrix} \rho \\ \rho v_1 \\ \rho e_{\text{total}} \end{pmatrix} + \frac{\partial}{\partial x} \begin{pmatrix} \rho v_1 \\ \rho v_1^2 + p \\ (\rho e_{\text{total}} +p) v_1 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}\]

for an ideal gas with ratio of specific heats gamma in one space dimension. Here, $\rho$ is the density, $v_1$ the velocity, $e_{\text{total}}$ the specific total energy, and

\[p = (\gamma - 1) \left( \rho e_{\text{total}} - \frac{1}{2} \rho v_1^2 \right)\]

the pressure.

source
SimpleDiscontinuousGalerkin.flux_ranochaMethod
flux_ranocha(u_ll, u_rr, equations::CompressibleEulerEquations1D)

Entropy conserving and kinetic energy preserving two-point flux by

  • Hendrik Ranocha (2018) Generalised Summation-by-Parts Operators and Entropy Stability of Numerical Methods for Hyperbolic Balance Laws PhD thesis, TU Braunschweig

See also

  • Hendrik Ranocha (2020) Entropy Conserving and Kinetic Energy Preserving Numerical Methods for the Euler Equations Using Summation-by-Parts Operators Proceedings of ICOSAHOM 2018
source
SimpleDiscontinuousGalerkin.initial_condition_density_waveMethod
initial_condition_density_wave(x, t, equations::CompressibleEulerEquations1D)

A sine wave in the density with constant velocity and pressure; reduces the compressible Euler equations to the linear advection equations. This setup is the test case for stability of EC fluxes from the paper

  • Gregor J. Gassner, Magnus Svärd, Florian J. Hindenlang (2020) Stability issues of entropy-stable and/or split-form high-order schemes arXiv: 2007.09026

with the following parameters

  • domain [-1, 1]
  • mesh = 4x4
  • polydeg = 5
source
SimpleDiscontinuousGalerkin.AbstractEquationsType
AbstractEquations{NDIMS, NVARS}

An abstract supertype of specific equations such as the linear advection equation. The type parameters encode the number of spatial dimensions (NDIMS) and the number of primary variables (NVARS) of the physics model.

source
SimpleDiscontinuousGalerkin.cons2entropyMethod
cons2entropy(u, equations)

Return the entropy variables from the conservative variables u for the given system of equations. The entropy variables are defined as the derivative of the entropy with respect to the conservative variables.

source
SimpleDiscontinuousGalerkin.eachvariableMethod
eachvariable(equations::AbstractEquations)

Return an iterator over the indices that specify the location in relevant data structures for the variables in equations. In particular, not the variables themselves are returned.

source
SimpleDiscontinuousGalerkin.get_nameMethod
get_name(equations::AbstractEquations)

Return the canonical, human-readable name for the given system of equations.

Examples

julia> SimpleDiscontinuousGalerkin.get_name(LinearAdvectionEquation1D(1.0))
"LinearAdvectionEquation1D"
source
SimpleDiscontinuousGalerkin.MaxwellEquations1DType
MaxwellEquations1D(c = 299_792_458.0)

The Maxwell equations of electro dynamics

\[\frac{\partial}{\partial t} \begin{pmatrix} E \\ B \end{pmatrix} + \frac{\partial}{\partial x} \begin{pmatrix} c^2 B \\ E \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix}\]

in one dimension with speed of light c = 299792458 m/s (in vacuum). In one dimension the Maxwell equations reduce to a wave equation. The orthogonal magnetic (e.g.B_y) and electric field (E_z) propagate as waves through the domain in x-direction. For reference, see

  • e.g. p.15 of Numerical Methods for Conservation Laws: From Analysis to Algorithms https://doi.org/10.1137/1.9781611975109

  • or equation (1) in https://inria.hal.science/hal-01720293/document

source
SimpleDiscontinuousGalerkin.FluxHLLType
FluxHLL(min_max_speed=min_max_speed_davis)

Create an HLL (Harten, Lax, van Leer) numerical flux where the minimum and maximum wave speeds are estimated as λ_min, λ_max = min_max_speed(u_ll, u_rr, orientation_or_normal_direction, equations), defaulting to min_max_speed_davis. Original paper:

  • Amiram Harten, Peter D. Lax, Bram van Leer (1983) On Upstream Differencing and Godunov-Type Schemes for Hyperbolic Conservation Laws DOI: 10.1137/1025002
source
SimpleDiscontinuousGalerkin.flux_centralMethod
flux_central(u_ll, u_rr, equations::AbstractEquations)

The classical central numerical flux f((u_ll) + f(u_rr)) / 2. When this flux is used as volume flux, the discretization is equivalent to the classical weak form DG method (except floating point errors).

source
SimpleDiscontinuousGalerkin.max_abs_speedFunction
max_abs_speed(u_ll, u_rr, equations)

Simple and fast estimate of the maximal wave speed of the Riemann problem with left and right states u_ll, u_rr, based only on the local wave speeds associated to u_ll and u_rr.

source
SimpleDiscontinuousGalerkin.min_max_speed_davisFunction
min_max_speed_davis(u_ll, u_rr, equations)

Simple and fast estimates of the minimal and maximal wave speed of the Riemann problem with left and right states u_ll, u_rr, usually based only on the local wave speeds associated to u_ll and u_rr.

See eq. (10.38) from

  • Eleuterio F. Toro (2009) Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction DOI: 10.1007/b79761

See also FluxHLL, min_max_speed_davis.

source

Mesh

SimpleDiscontinuousGalerkin.OversetGridMeshType
OversetGridMesh{NDIMS, RealT, MeshLeft, MeshRight}
OversetGridMesh(mesh_left, mesh_right)

Create an overset grid (Chimera) mesh that combines two meshes, mesh_left and mesh_right, which have an overlap region.

source

Boundary conditions

SimpleDiscontinuousGalerkin.BoundaryConditionDirichletType
BoundaryConditionDirichlet(boundary_value_function)

Create a Dirichlet boundary condition that uses the function boundary_value_function to specify the values at the boundary. This can be used to create a boundary condition that specifies exact boundary values by passing the exact solution of the equation. The passed boundary value function will be called with the same arguments as an initial condition function is called, i.e., as

boundary_value_function(x, t, equations)

where x specifies the coordinates, t is the current time, and equation is the corresponding system of equations.

Examples

julia> BoundaryConditionDirichlet(initial_condition_convergence_test)
source

Solver

SimpleDiscontinuousGalerkin.eachnodeMethod
eachnode(solver::DG, element)

Return an iterator over the indices that specify the location in relevant data structures for the nodes in a specific element in solver. In particular, not the nodes themselves are returned.

source
SimpleDiscontinuousGalerkin.DGSEMType
DGSEM(; RealT=Float64, polydeg::Integer,
        surface_flux=flux_central,
        surface_integral=SurfaceIntegralWeakForm(surface_flux),
        volume_integral=VolumeIntegralWeakForm())

Create a discontinuous Galerkin spectral element method (DGSEM) using a LegendreDerivativeOperator with polynomials of degree polydeg.

source
SimpleDiscontinuousGalerkin.FDSBPType
FDSBP(D; RealT=Float64,
         surface_flux=flux_central,
         surface_integral=SurfaceIntegralWeakForm(surface_flux),
         volume_integral=VolumeIntegralWeakForm())

Create a discontinuous Galerkin method using a summation-by-parts operator D from SummationByPartsOperators.jl. This is similar to the DGSEM, but uses a general derivative operator instead of a Legendre derivative operator.

source
SimpleDiscontinuousGalerkin.PerElementFDSBPType
PerElementFDSBP(bases::Vector{BasisType};
                surface_flux = flux_central,
                surface_integral = SurfaceIntegralWeakForm(surface_flux),
                volume_integral = VolumeIntegralWeakForm()) where BasisType

Create a discontinuous Galerkin method using different bases for each element. This is like FDSBP, but allows for a different SBP operator on each element. See also: PerElementBasis.

source
SimpleDiscontinuousGalerkin.SurfaceIntegralWeakFormType
SurfaceIntegralWeakForm(surface_flux=flux_central, surface_flux_boundary=surface_flux)

The classical weak form surface integral type for DG methods as explained in standard textbooks. It uses surface_flux for the interior fluxes and surface_flux_boundary for the boundary fluxes.

See also VolumeIntegralWeakForm.

References

source

Semidiscretization

SimpleDiscontinuousGalerkin.flat_gridMethod
flat_grid(semi)

Return a vector of the coordinates of all nodes in semi, flattened across all elements. This is useful for plotting or other operations that require a single vector of coordinates.

source

Callbacks

SimpleDiscontinuousGalerkin.AnalysisCallbackType
AnalysisCallback(semi; interval=0,
                       extra_analysis_errors=Symbol[],
                       extra_analysis_integrals=(),
                       io=stdout)

Analyze a numerical solution every interval time steps. The L2- and the L∞-norm for each component are computed by default. Additional errors can be computed, e.g. by passing extra_analysis_errors = (:conservation_error,).

Further scalar functions func in extra_analysis_integrals are applied to the numerical solution and integrated over the computational domain. Some examples for this are mass, and entropy. You can also write your own function with the same signature as the examples listed above and pass it via extra_analysis_integrals. The computed errors and integrals are saved for each timestep and can be obtained by calling errors and integrals.

During the Simulation, the AnalysisCallback will print information to io.

source
SimpleDiscontinuousGalerkin.StepsizeCallbackType
StepsizeCallback(; cfl=1.0, interval = 1)

Set the time step size according to a CFL condition with CFL number cfl if the time integration method isn't adaptive itself.

The supplied keyword argument cfl must be either a Real number or a function of time t returning a Real number. By default, the timestep will be adjusted at every step. For different values of interval, the timestep will be adjusted every interval steps.

source

Utilities

SimpleDiscontinuousGalerkin.calc_mean_convergenceMethod
calc_mean_convergence(eocs)

Calculate the mean convergence rates from the given experimental orders of convergence eocs. The eocs are expected to be in the format returned by convergence_test, i.e., a Dict where the keys are the error types (e.g., :l2, :linf) and the values are matrices with the EOCs for each variable in the columns and the iterations in the rows. Returns a Dict with the same keys as eocs and the mean convergence rates for all variables as values.

source
SimpleDiscontinuousGalerkin.convergence_testMethod
convergence_test([mod::Module=Main,] example, iterations; io::IO = stdout, kwargs...)
convergence_test([mod::Module=Main,] example, Ns::AbstractVector; io::IO = stdout, kwargs...)

Run multiple simulations using the setup given in example and compute the experimental order of convergence (EOC) in the $L^2$ and $L^\infty$ norm. If iterations is passed as integer, in each iteration, the resolution of the respective mesh will be doubled. If Ns is passed as vector, the simulations will be run for each value of Ns. Additional keyword arguments kwargs... and the optional module mod are passed directly to trixi_include.

Adjusted from Trixi.jl.

source
SimpleDiscontinuousGalerkin.examples_dirMethod
examples_dir()

Return the directory where the example files provided by SimpleDiscontinuousGalerkin.jl are located. If SimpleDiscontinuousGalerkin.jl is installed as a regular package (with ]add SimpleDiscontinuousGalerkin), these files are read-only and should not be modified. To find out which files are available, use, e.g., readdir.

Copied from Trixi.jl.

Examples

readdir(examples_dir())
source