{ "cells": [ { "cell_type": "markdown", "source": [ "# 8: Other SBP schemes (FD, CGSEM) via `DGMulti` solver" ], "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": [ "For a tutorial about DG schemes via the `DGMulti` solver please visit the previous tutorial.\n", "The `DGMulti` solver also supports other methods than DG. The important property a method has to\n", "fulfill is the summation-by-parts (SBP) property. The package [SummationByPartsOperators.jl](https://github.com/ranocha/SummationByPartsOperators.jl)\n", "provides such methods, like a finite difference SBP (FD SBP) scheme. To do this,\n", "you need to create an SBP derivative operator and pass that as `approximation_type`\n", "to the `DGMulti` constructor. For example, the classical second-order FD SBP operator\n", "can be created as" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly\n", "D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_order=2,\n", " xmin=0.0, xmax=1.0, N=11)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Here, the arguments `xmin` and `xmax` do not matter beyond setting the real type\n", "used for the operator - they just set a reference element and are rescaled on the\n", "physical elements. The parameter `N` determines the number of finite difference nodes.\n", "Then, `D` can be used as `approximation_type` like `SBP()` in a multi-block fashion.\n", "In multiple dimensions, such a 1D SBP operator will be used in a tensor product fashion,\n", "i.e., in each coordinate direction. In particular, you can use them only on 1D, 2D `Quad()`,\n", "and 3D `Hex()` elements.\n", "\n", "You can also use fully periodic single-block FD methods by creating a periodic SBP\n", "operator. For example, a fully periodic FD operator can be constructed as" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "D = periodic_derivative_operator(derivative_order=1, accuracy_order=2,\n", " xmin=0.0, xmax=1.0, N=11)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "An example using such an FD method is implemented in\n", "[`elixir_euler_fdsbp_periodic.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl).\n", "For all parameters and other calling options, please have a look in the\n", "[documentation of SummationByPartsOperators.jl](https://ranocha.de/SummationByPartsOperators.jl/stable/)." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Another possible method is for instance a continuous Galerkin (CGSEM) method. You can use such a\n", "method with polynomial degree of `3` (`N=4` Legendre Lobatto nodes on `[0, 1]`) coupled continuously\n", "on a uniform mesh with `Nx=10` elements by setting `approximation_type` to" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly\n", "D = couple_continuously(legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4),\n", " UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10))" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "To choose a discontinuous coupling (DGSEM), use `couple_discontinuously()` instead of `couple_continuously()`." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "For more information and other SBP operators, see the documentations of [StartUpDG.jl](https://jlchan.github.io/StartUpDG.jl/dev/)\n", "and [SummationByPartsOperators.jl](https://ranocha.de/SummationByPartsOperators.jl/stable/)." ], "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\", \"StartUpDG\", \"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 }