Skip to content

Commit

Permalink
Merge branch 'dev' into sg/wet-dry-swe-2d
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwinters5000 authored Jun 30, 2023
2 parents 56cbd05 + d22a815 commit a5b128f
Show file tree
Hide file tree
Showing 89 changed files with 1,516 additions and 718 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: Checkout Actions Repository
uses: actions/checkout@v3
- name: Check spelling
uses: crate-ci/[email protected].0
uses: crate-ci/[email protected].6
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ for human readability.
#### Added

- Experimental support for 3D parabolic diffusion terms has been added.
- Capability to set truly discontinuous initial conditions in 1D.

#### Changed

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Trixi"
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"]
version = "0.5.29-pre"
version = "0.5.31-pre"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand Down
2 changes: 1 addition & 1 deletion docs/literate/src/files/adding_nonconservative_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ plot(sol)
# above.

error_1 = analysis_callback(sol).l2 |> first
@test isapprox(error_1, 0.0002961027497) #src
@test isapprox(error_1, 0.00029609575838969394) #src
# Next, we increase the grid resolution by one refinement level and run the
# simulation again.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/github-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ branch, and the corresponding pull request will be updated automatically.
Please note that a review has nothing to do with the lack of experience of the
person developing changes: We try to review all code before it gets added to
`main`, even from the most experienced developers. This is good practice and
helps to keep the error rate low while ensuring the the code is developed in a
helps to keep the error rate low while ensuring that the code is developed in a
consistent fashion. Furthermore, do not take criticism of your code personally -
we just try to keep Trixi.jl as accessible and easy to use for everyone.

Expand All @@ -121,7 +121,7 @@ Once your branch is reviewed and declared ready for merging by the reviewer,
make sure that all the latest changes have been pushed. Then, one of the
developers will merge your PR. If you are one of the developers, you can also go
to the pull request page on GitHub and and click on **Merge pull request**.
Voilá, you are done! Your branch will have been merged to
Voilà, you are done! Your branch will have been merged to
`main` and the source branch will have been deleted in the GitHub repository
(if you are not working in your own fork).

Expand Down
15 changes: 13 additions & 2 deletions docs/src/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ of your PR), you need to install JuliaFormatter.jl first by running
```shell
julia -e 'using Pkg; Pkg.add("JuliaFormatter")'
```
You can then recursively format all Julia files in the Trixi.jl repo by executing
You can then recursively format the core Julia files in the Trixi.jl repo by executing
```shell
julia -e 'using JuliaFormatter; format(".")
julia -e 'using JuliaFormatter; format(["benchmark", "ext", "src", "utils"])'
```
from inside the Trixi.jl repository. For convenience, there is also a script you can
directly run from your terminal shell, which will automatically install JuliaFormatter in a
Expand All @@ -65,3 +65,14 @@ utils/trixi-format.jl
```
You can get more information about using the convenience script by running it with the
`--help`/`-h` flag.

### Checking formatting before committing
It can be convenient to check the formatting of source code automatically before each commit.
We use git-hooks for it and provide a `pre-commit` script in the `utils` folder. The script uses
[JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) just like formatting script that
runs over the whole Trixi.jl directory.
You can copy the `pre-commit`-script into `.git/hooks/pre-commit` and it will check your formatting
before each commit. If errors are found the commit is aborted and you can add the corrections via
```shell
git add -p
```
56 changes: 56 additions & 0 deletions examples/dgmulti_3d/elixir_advection_tensor_wedge.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using OrdinaryDiffEq
using Trixi
using LinearAlgebra

###############################################################################
equations = LinearScalarAdvectionEquation3D(1.0, 1.0, 1.0)

initial_condition = initial_condition_convergence_test

# Define the polynomial degrees for the polynoms of the triangular base and the line
# of the tensor-prism
tensor_polydeg = (3, 4)

dg = DGMulti(element_type = Wedge(),
approximation_type = Polynomial(),
surface_flux = flux_lax_friedrichs,
polydeg = tensor_polydeg)


cells_per_dimension = (8, 8, 8)
mesh = DGMultiMesh(dg,
cells_per_dimension,
coordinates_min = (-1.0, -1.0, -1.0),
coordinates_max = (1.0, 1.0, 1.0),
periodicity = true)


semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
boundary_conditions=boundary_condition_periodic)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 5.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg))

alive_callback = AliveCallback(analysis_interval=analysis_interval)

# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
stepsize_callback = StepsizeCallback(cfl=1.0)

callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback)


###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), dt = 1.0,
save_everystep=false, callback=callbacks);

summary_callback() # print the timer summary
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the linear advection-diffusion equation

diffusivity() = 5.0e-2
advection_velocity = (1.0, 0.0)
equations = LinearScalarAdvectionEquation2D(advection_velocity)
equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations)

# Example setup taken from
# - Truman Ellis, Jesse Chan, and Leszek Demkowicz (2016).
# Robust DPG methods for transient convection-diffusion.
# In: Building bridges: connections and challenges in modern approaches
# to numerical partial differential equations.
# [DOI](https://doi.org/10.1007/978-3-319-41640-3_6).
function initial_condition_eriksson_johnson(x, t, equations)
l = 4
epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt
lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon)
lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon)
r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon)
s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon)
u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) +
cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1))
return SVector{1}(u)
end
initial_condition = initial_condition_eriksson_johnson

boundary_conditions = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition),
:y_neg => BoundaryConditionDirichlet(initial_condition),
:y_pos => BoundaryConditionDirichlet(initial_condition),
:x_pos => boundary_condition_do_nothing)

boundary_conditions_parabolic = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition),
:x_pos => BoundaryConditionDirichlet(initial_condition),
:y_neg => BoundaryConditionDirichlet(initial_condition),
:y_pos => BoundaryConditionDirichlet(initial_condition))

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs)

coordinates_min = (-1.0, -0.5)
coordinates_max = ( 0.0, 0.5)

# This maps the domain [-1, 1]^2 to [-1, 0] x [-0.5, 0.5] while also
# introducing a curved warping to interior nodes.
function mapping(xi, eta)
x = xi + 0.1 * sin(pi * xi) * sin(pi * eta)
y = eta + 0.1 * sin(pi * xi) * sin(pi * eta)
return SVector(0.5 * (1 + x) - 1, 0.5 * y)
end

trees_per_dimension = (4, 4)
mesh = P4estMesh(trees_per_dimension,
polydeg=3, initial_refinement_level=2,
mapping=mapping, periodicity=(false, false))

# A semidiscretization collects data structures and functions for the spatial discretization
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver,
boundary_conditions = (boundary_conditions, boundary_conditions_parabolic))


###############################################################################
# ODE solvers, callbacks etc.

# Create ODE problem with time span `tspan`
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan);

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
summary_callback = SummaryCallback()

# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval=analysis_interval)

# The AliveCallback prints short status information in regular intervals
alive_callback = AliveCallback(analysis_interval=analysis_interval)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback)


###############################################################################
# run the simulation

# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
time_int_tol = 1.0e-11
sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol,
ode_default_options()..., callback=callbacks)

# Print the timer summary
summary_callback()
4 changes: 2 additions & 2 deletions examples/p4est_2d_dgsem/elixir_euler_sedov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ equations = CompressibleEulerEquations2D(1.4)
initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations2D)
The Sedov blast wave setup based on Flash
- http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000
- https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000
"""
function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations2D)
# Set up polar coordinates
Expand All @@ -20,7 +20,7 @@ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEq
y_norm = x[2] - inicenter[2]
r = sqrt(x_norm^2 + y_norm^2)

# Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000
# Setup based on https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000
r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6)
E = 1.0
p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2)
Expand Down
Loading

0 comments on commit a5b128f

Please sign in to comment.