Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework RHS Splitting and MIS Method #2058

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions docs/literate/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ using Test: @testset
import Pkg

# Create markdown and notebook files for `file`
function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder="")
function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder = "")
notebook_filename = first(splitext(file)) * ".ipynb"
if !isempty(folder)
notebook_filename = joinpath(folder, notebook_filename)
end

binder_logo = "https://mybinder.org/badge_logo.svg"
binder_logo = "https://mybinder.org/badge_logo.svg"
nbviewer_logo = "https://img.shields.io/badge/render-nbviewer-f37726"
raw_notebook_logo = "https://img.shields.io/badge/raw-notebook-4cc61e"

notebook_path = "tutorials/notebooks/$notebook_filename"
binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path"
binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path"
nbviewer_url = "https://nbviewer.jupyter.org/github/trixi-framework/Trixi.jl/blob/tutorial_notebooks/$notebook_path"
raw_notebook_url = "https://raw.githubusercontent.com/trixi-framework/Trixi.jl/tutorial_notebooks/$notebook_path"

binder_badge = "# [![]($binder_logo)]($binder_url)"
binder_badge = "# [![]($binder_logo)]($binder_url)"
nbviewer_badge = "# [![]($nbviewer_logo)]($nbviewer_url)"
raw_notebook_badge = "# [![]($raw_notebook_logo)]($raw_notebook_url)"

Expand All @@ -28,25 +28,28 @@ function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder=""
# available for the latest stable release of Trixi.jl at the time of caching.\n\n"
return string("# # $title\n\n", warning, content)
end
Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); execute=false, preprocess=preprocess_notebook, credit=false)
Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder);
execute = false, preprocess = preprocess_notebook, credit = false)

# Generate markdown file
function preprocess_docs(content)
return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $raw_notebook_badge\n\n", content)
return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $raw_notebook_badge\n\n",
content)
end
Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); preprocess=preprocess_docs,)
Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder);
preprocess = preprocess_docs,)
end

# Create tutorials with Literate.jl
function create_tutorials(files)
repo_src = joinpath(@__DIR__, "src", "files")
repo_src = joinpath(@__DIR__, "src", "files")

pages_dir = joinpath(@__DIR__, "..", "src", "tutorials")
notebooks_dir = joinpath(pages_dir, "notebooks")
pages_dir = joinpath(@__DIR__, "..", "src", "tutorials")
notebooks_dir = joinpath(pages_dir, "notebooks")

Sys.rm(pages_dir; recursive=true, force=true)
Sys.rm(pages_dir; recursive = true, force = true)

Sys.rm("out"; recursive=true, force=true)
Sys.rm("out"; recursive = true, force = true)

# Run tests on all tutorial files
@testset "TrixiTutorials" begin
Expand All @@ -59,15 +62,16 @@ function create_tutorials(files)
mod = gensym(filename[j][2][2])
@testset "$(filename[j][2][2])" begin
@eval module $mod
include(joinpath($repo_src, $(filename[j][2][1]), $(filename[j][2][2])))
include(joinpath($repo_src, $(filename[j][2][1]),
$(filename[j][2][2])))
end
end
end
else # Single files
mod = gensym(title)
@testset "$title" begin
@eval module $mod
include(joinpath($repo_src, $filename))
include(joinpath($repo_src, $filename))
end
end
end
Expand All @@ -85,18 +89,20 @@ function create_tutorials(files)
end
return content
end
Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name="introduction", preprocess=preprocess_introduction)
Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name = "introduction",
preprocess = preprocess_introduction)
# Navigation system for makedocs
pages = Any["Introduction" => "tutorials/introduction.md",]
pages = Any["Introduction" => "tutorials/introduction.md"]

# Create markdown and notebook files for tutorials
for (i, (title, filename)) in enumerate(files)
# Several files of one topic are created separately and pushed to `pages` together.
if filename isa Vector
vector = []
for j in eachindex(filename)
create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], repo_src,
pages_dir, notebooks_dir; folder=filename[j][2][1])
create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2],
repo_src,
pages_dir, notebooks_dir; folder = filename[j][2][1])

path = "$(filename[j][2][1])/$(splitext(filename[j][2][2])[1]).md"
push!(vector, "$i.$j $(filename[j][1])" => "tutorials/$path")
Expand Down
70 changes: 33 additions & 37 deletions docs/literate/src/files/DGMulti_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ dg = DGMulti(polydeg = 3,
cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
coordinates_min = (-2.0, -2.0),
coordinates_max = (2.0, 2.0),
periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
boundary_conditions=boundary_condition_periodic)
boundary_conditions = boundary_condition_periodic)
tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

alive_callback = AliveCallback(alive_interval=10)
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
alive_callback = AliveCallback(alive_interval = 10)
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
callbacks = CallbackSet(analysis_callback, alive_callback);

# Run the simulation with the same time integration algorithm as before.
sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-6, reltol=1.0e-6,
callback=callbacks, save_everystep=false);
sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-6, reltol = 1.0e-6,
callback = callbacks, save_everystep = false);
#-
using Plots
pd = PlotData2D(sol)
Expand All @@ -60,7 +60,6 @@ plot!(getmesh(pd))
# (2021) provides a nice runtime comparison between the different mesh types. On the other hand,
# the functions are more general and thus we have more option we can choose from.


# ## Simulation with Gauss nodes
# For instance, we can change the approximation type of our simulation.
using Trixi, OrdinaryDiffEq
Expand All @@ -78,28 +77,27 @@ dg = DGMulti(polydeg = 3,

cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
cells_per_dimension, # initial_refinement_level = 5
coordinates_min = (-2.0, -2.0),
coordinates_max = (2.0, 2.0),
periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
boundary_conditions=boundary_condition_periodic)
boundary_conditions = boundary_condition_periodic)
tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

alive_callback = AliveCallback(alive_interval=10)
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
alive_callback = AliveCallback(alive_interval = 10)
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
callbacks = CallbackSet(analysis_callback, alive_callback);

sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6,
ode_default_options()..., callback=callbacks);
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
ode_default_options()..., callback = callbacks);
#-
using Plots
pd = PlotData2D(sol)
plot(pd)


# ## Simulation with triangular elements
# Also, we can set another element type. We want to use triangles now.
using Trixi, OrdinaryDiffEq
Expand All @@ -119,21 +117,21 @@ dg = DGMulti(polydeg = 3,
cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
coordinates_min = (-2.0, -2.0),
coordinates_max = (2.0, 2.0),
periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
boundary_conditions=boundary_condition_periodic)
boundary_conditions = boundary_condition_periodic)
tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

alive_callback = AliveCallback(alive_interval=10)
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
alive_callback = AliveCallback(alive_interval = 10)
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
callbacks = CallbackSet(analysis_callback, alive_callback);

sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6,
ode_default_options()..., callback=callbacks);
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
ode_default_options()..., callback = callbacks);
#-
using Plots
pd = PlotData2D(sol)
Expand All @@ -142,7 +140,6 @@ plot(pd)
plot(pd["rho"])
plot!(getmesh(pd))


# ## Triangular meshes on non-Cartesian domains
# To use triangular meshes on a non-Cartesian domain, Trixi.jl uses the package [StartUpDG.jl](https://github.com/jlchan/StartUpDG.jl).
# The following example is based on [`elixir_euler_triangulate_pkg_mesh.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl)
Expand All @@ -157,7 +154,7 @@ source_terms = source_terms_convergence_test

# We create the solver `DGMulti` with triangular elements (`Tri()`) as before.
dg = DGMulti(polydeg = 3, element_type = Tri(),
approximation_type=Polynomial(),
approximation_type = Polynomial(),
surface_flux = flux_lax_friedrichs,
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))

Expand All @@ -168,11 +165,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole());

# The pre-defined Triangulate geometry in StartUpDG has integer boundary tags. With [`DGMultiMesh`](@ref)
# we assign boundary faces based on these integer boundary tags and create a mesh compatible with Trixi.jl.
mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary=>1, :inner_boundary=>2))
mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary => 1, :inner_boundary => 2))
#-
boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test,
:inner_boundary => boundary_condition_convergence_test)
:inner_boundary => boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand All @@ -181,12 +178,12 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
tspan = (0.0, 0.2)
ode = semidiscretize(semi, tspan)

alive_callback = AliveCallback(alive_interval=20)
analysis_callback = AnalysisCallback(semi, interval=200, uEltype=real(dg))
alive_callback = AliveCallback(alive_interval = 20)
analysis_callback = AnalysisCallback(semi, interval = 200, uEltype = real(dg))
callbacks = CallbackSet(alive_callback, analysis_callback);

sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks);
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks);
#-
using Plots
pd = PlotData2D(sol)
Expand All @@ -195,7 +192,6 @@ plot!(getmesh(pd))

# For more information, please have a look in the [StartUpDG.jl documentation](https://jlchan.github.io/StartUpDG.jl/stable/).


# ## Package versions

# These results were obtained using the following versions.
Expand All @@ -205,4 +201,4 @@ versioninfo()

using Pkg
Pkg.status(["Trixi", "StartUpDG", "OrdinaryDiffEq", "Plots"],
mode=PKGMODE_MANIFEST)
mode = PKGMODE_MANIFEST)
15 changes: 7 additions & 8 deletions docs/literate/src/files/DGMulti_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# to the `DGMulti` constructor. For example, the classical second-order FD SBP operator
# can be created as
using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly
D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_order=2,
xmin=0.0, xmax=1.0, N=11)
D = derivative_operator(MattssonNordström2004(), derivative_order = 1, accuracy_order = 2,
xmin = 0.0, xmax = 1.0, N = 11)
# Here, the arguments `xmin` and `xmax` do not matter beyond setting the real type
# used for the operator - they just set a reference element and are rescaled on the
# physical elements. The parameter `N` determines the number of finite difference nodes.
Expand All @@ -20,8 +20,8 @@ D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_o
#
# You can also use fully periodic single-block FD methods by creating a periodic SBP
# operator. For example, a fully periodic FD operator can be constructed as
D = periodic_derivative_operator(derivative_order=1, accuracy_order=2,
xmin=0.0, xmax=1.0, N=11)
D = periodic_derivative_operator(derivative_order = 1, accuracy_order = 2,
xmin = 0.0, xmax = 1.0, N = 11)
# An example using such an FD method is implemented in
# [`elixir_euler_fdsbp_periodic.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl).
# For all parameters and other calling options, please have a look in the
Expand All @@ -31,15 +31,14 @@ D = periodic_derivative_operator(derivative_order=1, accuracy_order=2,
# method with polynomial degree of `3` (`N=4` Legendre Lobatto nodes on `[0, 1]`) coupled continuously
# on a uniform mesh with `Nx=10` elements by setting `approximation_type` to
using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly
D = couple_continuously(legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4),
UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10))
D = couple_continuously(legendre_derivative_operator(xmin = 0.0, xmax = 1.0, N = 4),
UniformPeriodicMesh1D(xmin = -1.0, xmax = 1.0, Nx = 10))

# To choose a discontinuous coupling (DGSEM), use `couple_discontinuously()` instead of `couple_continuously()`.

# For more information and other SBP operators, see the documentations of [StartUpDG.jl](https://jlchan.github.io/StartUpDG.jl/dev/)
# and [SummationByPartsOperators.jl](https://ranocha.de/SummationByPartsOperators.jl/stable/).


# ## Package versions

# These results were obtained using the following versions.
Expand All @@ -49,4 +48,4 @@ versioninfo()

using Pkg
Pkg.status(["Trixi", "StartUpDG", "SummationByPartsOperators"],
mode=PKGMODE_MANIFEST)
mode = PKGMODE_MANIFEST)
Loading