{ "cells": [ { "cell_type": "markdown", "source": [ "# 9: Upwind FD SBP schemes" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "**Note:** To improve responsiveness via caching, the notebooks are updated only once a week. They are only\n", "available for the latest stable release of Trixi.jl at the time of caching." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "General tensor product SBP methods are supported via the `DGMulti` solver\n", "in a reasonably complete way, see the previous tutorial.\n", "Nevertheless, there is also experimental support for SBP methods with\n", "other solver and mesh types." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "The first step is to set up an SBP operator. A classical (central) SBP\n", "operator can be created as follows." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Trixi\n", "D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),\n", " derivative_order=1, accuracy_order=2,\n", " xmin=0.0, xmax=1.0, N=11)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Instead of prefixing the source of coefficients `MattssonNordström2004()`,\n", "you can also load the package SummationByPartsOperators.jl. Either way,\n", "this yields an object representing the operator efficiently. If you want to\n", "compare it to coefficients presented in the literature, you can convert it\n", "to a matrix." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Matrix(D_SBP)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Upwind SBP operators are a concept introduced in 2017 by Ken Mattsson. You can\n", "create them as follows." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017,\n", " derivative_order=1, accuracy_order=2,\n", " xmin=0.0, xmax=1.0, N=11)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Upwind operators are derivative operators biased towards one direction.\n", "The \"minus\" variants has a bias towards the left side, i.e., it uses values\n", "from more nodes to the left than from the right to compute the discrete\n", "derivative approximation at a given node (in the interior of the domain).\n", "In matrix form, this means more non-zero entries are left from the diagonal." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Matrix(D_upw.minus)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Analogously, the \"plus\" variant has a bias towards the right side." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Matrix(D_upw.plus)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "For more information on upwind SBP operators, please refer to the documentation\n", "of [SummationByPartsOperators.jl](https://github.com/ranocha/SummationByPartsOperators.jl)\n", "and references cited there." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "The basic idea of upwind SBP schemes is to apply a flux vector splitting and\n", "use appropriate upwind operators for both parts of the flux. In 1D, this means\n", "to split the flux\n", "$$\n", "f(u) = f^-(u) + f^+(u)\n", "$$\n", "such that $f^-(u)$ is associated with left-going waves and $f^+(u)$ with\n", "right-going waves. Then, we apply upwind SBP operators $D^-, D^+$ with an\n", "appropriate upwind bias, resulting in\n", "$$\n", "\\partial_x f(u) \\approx D^+ f^-(u) + D^- f^+(u)\n", "$$\n", "Note that the established notations of upwind operators $D^\\pm$ and flux\n", "splittings $f^\\pm$ clash. The right-going waves from $f^+$ need an operator\n", "biased towards their upwind side, i.e., the left side. This upwind bias is\n", "provided by the operator $D^-$." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Many classical flux vector splittings have been developed for finite volume\n", "methods and are described in the book \"Riemann Solvers and Numerical Methods\n", "for Fluid Dynamics: A Practical Introduction\" of Eleuterio F. Toro (2009),\n", "[DOI: 10.1007/b79761](https://doi.org/10.1007/b79761). One such a well-known\n", "splitting provided by Trixi.jl is `splitting_steger_warming`." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Trixi.jl comes with several example setups using upwind SBP methods with\n", "flux vector splitting, e.g.,\n", "- [`elixir_euler_vortex.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_fdsbp/elixir_euler_vortex.jl)\n", "- [`elixir_euler_taylor_green_vortex.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Package versions" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "These results were obtained using the following versions." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using InteractiveUtils\n", "versioninfo()\n", "\n", "using Pkg\n", "Pkg.status([\"Trixi\", \"SummationByPartsOperators\"],\n", " mode=PKGMODE_MANIFEST)" ], "metadata": {}, "execution_count": null } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.10.3" }, "kernelspec": { "name": "julia-1.10", "display_name": "Julia 1.10.3", "language": "julia" } }, "nbformat": 4 }