Skip to content

Commit

Permalink
Merge branch 'main' into Maxwell1D
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCan authored Jul 2, 2024
2 parents 9bdbd14 + 58acd35 commit 6345c6f
Show file tree
Hide file tree
Showing 52 changed files with 1,775 additions and 764 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@v4
- name: Check spelling
uses: crate-ci/typos@v1.21.0
uses: crate-ci/typos@v1.22.9
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ are listed in alphabetical order:
* Julia Odenthal
* Sigrun Ortleb
* Hendrik Ranocha
* Warisa Roongaraya
* Andrés M. Rueda-Ramírez
* Felipe Santillan
* Michael Schlottke-Lakemper
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ Trixi.jl follows the interpretation of [semantic versioning (semver)](https://ju
used in the Julia ecosystem. Notable changes will be documented in this file
for human readability.

## Changes when updating to v0.8 from v0.7.x

#### Added

#### Changed

- The specification of boundary names on which `AnalysisSurfaceIntegral`s are computed (such as drag and lift coefficients) has changed from `Symbol` and `Vector{Symbol}` to `NTuple{Symbol}`.
Thus, for one boundary the syntax changes from `:boundary` to `(:boundary,)` and for `Vector`s `[:boundary1, :boundary2]` to `(:boundary1, :boundary2)` ([#1959]).
- The names of output files like the one created from the `SaveSolutionCallback` have changed from `%06d` to `%09d` to allow longer-running simulations ([#1996]).

#### Deprecated

#### Removed

## Changes in the v0.7 lifecycle

#### Added
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.7.16-pre"
version = "0.8.2-DEV"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Measurements = "2.5"
OrdinaryDiffEq = "6.49.1"
Plots = "1.9"
Test = "1"
Trixi2Vtk = "0.3"
Trixi2Vtk = "0.3.16"
TrixiBase = "0.1.1"
14 changes: 7 additions & 7 deletions docs/literate/src/files/first_steps/create_first_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,28 @@ plot!(getmesh(pd))
# import Pkg
# Pkg.add(["Trixi2Vtk"])
# ```
# Now we load the Trixi2Vtk.jl package and convert the file `out/solution_000032.h5` with
# Now we load the Trixi2Vtk.jl package and convert the file `out/solution_000000032.h5` with
# the final solution using the [`trixi2vtk`](@ref) function saving the resulting file in the
# `out` folder.

using Trixi2Vtk
trixi2vtk(joinpath("out", "solution_000032.h5"), output_directory="out")
trixi2vtk(joinpath("out", "solution_000000032.h5"), output_directory="out")

# Now two files `solution_000032.vtu` and `solution_000032_celldata.vtu` have been generated in the
# Now two files `solution_000000032.vtu` and `solution_000000032_celldata.vtu` have been generated in the
# `out` folder. The first one contains all the information for visualizing the solution, the
# second one contains all the cell-based or discretization-based information.

# Now let's visualize the solution from the generated files in ParaView. Follow this short
# instruction to get the visualization.
# - Download, install and open [ParaView](https://www.paraview.org/download/).
# - Press `Ctrl+O` and select the generated files `solution_000032.vtu` and
# `solution_000032_celldata.vtu` from the `out` folder.
# - Press `Ctrl+O` and select the generated files `solution_000000032.vtu` and
# `solution_000000032_celldata.vtu` from the `out` folder.
# - In the upper-left corner in the Pipeline Browser window, left-click on the eye-icon near
# `solution_000032.vtu`.
# `solution_000000032.vtu`.
# - In the lower-left corner in the Properties window, change the Coloring from Solid Color to
# scalar. This already generates the visualization of the final solution.
# - Now let's add the mesh to the visualization. In the upper-left corner in the
# Pipeline Browser window, left-click on the eye-icon near `solution_000032_celldata.vtu`.
# Pipeline Browser window, left-click on the eye-icon near `solution_000000032_celldata.vtu`.
# - In the lower-left corner in the Properties window, change the Representation from Surface
# to Wireframe. Then a white grid should appear on the visualization.
# Now, if you followed the instructions exactly, you should get a similar image as shown in the
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/src/files/hohqmesh_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end #hide #md

using Trixi2Vtk
redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md
trixi2vtk("out/solution_000180.h5", output_directory="out")
trixi2vtk("out/solution_000000180.h5", output_directory="out")
end #hide #md

# Note this step takes about 15-30 seconds as the package `Trixi2Vtk` must be precompiled and executed for the first time
Expand All @@ -64,7 +64,7 @@ end #hide #md
# visualization nodes. For instance, if we want to use 12 uniformly spaced nodes for visualization we can execute

redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md
trixi2vtk("out/solution_000180.h5", output_directory="out", nvisnodes=12)
trixi2vtk("out/solution_000000180.h5", output_directory="out", nvisnodes=12)
end #hide #md

# By default `trixi2vtk` sets `nvisnodes` to be the same as the number of nodes specified in
Expand Down
18 changes: 14 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,21 @@ tutorials = create_tutorials(files)

# Create changelog
Changelog.generate(
Changelog.Documenter(), # output type
joinpath(@__DIR__, "..", "NEWS.md"), # input file
joinpath(@__DIR__, "src", "changelog.md"); # output file
repo = "trixi-framework/Trixi.jl", # default repository for links
Changelog.Documenter(), # output type
joinpath(@__DIR__, "..", "NEWS.md"), # input file
joinpath(@__DIR__, "src", "changelog_tmp.md"); # output file
repo = "trixi-framework/Trixi.jl", # default repository for links
branch = "main", # default branch for links
)
# Fix edit URL of changelog
open(joinpath(@__DIR__, "src", "changelog.md"), "w") do io
for line in eachline(joinpath(@__DIR__, "src", "changelog_tmp.md"))
if startswith(line, "EditURL")
line = "EditURL = \"https://github.com/trixi-framework/Trixi.jl/blob/main/NEWS.md\""
end
println(io, line)
end
end

# Make documentation
makedocs(
Expand Down
2 changes: 1 addition & 1 deletion docs/src/restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ conditionals like `if restart` with a boolean variable `restart` that is user de

First we need to define from which file we want to restart, e.g.
```julia
restart_file = "restart_000021.h5"
restart_file = "restart_000000021.h5"
restart_filename = joinpath("out", restart_file)
```

Expand Down
12 changes: 6 additions & 6 deletions docs/src/visualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ julia> using Trixi2Vtk
```
To process an HDF5 file generated by Trixi.jl, execute
```julia
julia> trixi2vtk(joinpath("out", "solution_000000.h5"), output_directory="out")
julia> trixi2vtk(joinpath("out", "solution_000000000.h5"), output_directory="out")
```
This will create two unstructured VTK files in the `out` subdirectory that can
be opened with ParaView or VisIt: `solution_000000.vtu` contains the
discontinuous Galerkin solution data while `solution_000000_celldata.vtu` holds
be opened with ParaView or VisIt: `solution_000000000.vtu` contains the
discontinuous Galerkin solution data while `solution_000000000_celldata.vtu` holds
any cell-based values such as the current AMR indicator or the cell refinement
level.

!["solution_000000_scalar_mesh"](https://github.com/trixi-framework/Trixi2Vtk.jl/raw/main/docs/src/assets/solution_000000_scalar_mesh.png)
!["solution_000000000_scalar_mesh"](https://github.com/trixi-framework/Trixi2Vtk.jl/raw/main/docs/src/assets/solution_000000_scalar_mesh.png)

This allows you to generate VTK files for solution, restart and mesh files. By
default, Trixi2Vtk generates `.vtu` (unstructured VTK) files for both
Expand All @@ -440,7 +440,7 @@ publication-quality images, but increases the file size.
If you want to convert multiple solution/restart files at once, you can just supply
multiple input files as the positional arguments to `trixi2vtk`, e.g.,
```julia
julia> trixi2vtk("out/solution_000000.h5", "out/solution_000040.h5")
julia> trixi2vtk("out/solution_000000000.h5", "out/solution_000000040.h5")
```
You may also use file globbing to select a range of files based on filename patterns, e.g.,
```julia
Expand All @@ -450,7 +450,7 @@ to convert all solution files in the `out/` directory or
```julia
julia> trixi2vtk("out/restart_00[0-9]000.h5")
```
to convert every one-thousandth restart file (`out/restart_000000.h5`,
to convert every one-thousandth restart file (`out/restart_000000000.h5`,
`out/restart_001000.h5` etc.).

When multiple solution/restart files are provided, Trixi2Vtk will also generate a
Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

elixir_file = "elixir_advection_extended.jl"
restart_file = "restart_000021.h5"
restart_file = "restart_000000021.h5"

trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))

Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_2d_dgsem/elixir_advection_restart_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

elixir_file = "elixir_advection_extended.jl"
restart_file = "restart_000021.h5"
restart_file = "restart_000000021.h5"

trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ analysis_interval = 2000

l_inf = 1.0 # Length of airfoil

force_boundary_names = [:AirfoilBottom, :AirfoilTop]
force_boundary_names = (:AirfoilBottom, :AirfoilTop)
drag_coefficient = AnalysisSurfaceIntegral(semi, force_boundary_names,
DragCoefficientPressure(aoa(), rho_inf(),
u_inf(equations), l_inf))
Expand Down
4 changes: 2 additions & 2 deletions examples/p4est_2d_dgsem/elixir_euler_subsonic_cylinder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ rho_inf = 1.4
u_inf = 0.38
l_inf = 1.0 # Diameter of circle

drag_coefficient = AnalysisSurfaceIntegral(semi, :x_neg,
drag_coefficient = AnalysisSurfaceIntegral(semi, (:x_neg,),
DragCoefficientPressure(aoa, rho_inf, u_inf,
l_inf))

lift_coefficient = AnalysisSurfaceIntegral(semi, :x_neg,
lift_coefficient = AnalysisSurfaceIntegral(semi, (:x_neg,),
LiftCoefficientPressure(aoa, rho_inf, u_inf,
l_inf))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ summary_callback = SummaryCallback()

analysis_interval = 2000

force_boundary_names = [:AirfoilBottom, :AirfoilTop]
force_boundary_names = (:AirfoilBottom, :AirfoilTop)
drag_coefficient = AnalysisSurfaceIntegral(semi, force_boundary_names,
DragCoefficientPressure(aoa(), rho_inf(),
u_inf(equations),
Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"),
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000010.h5")
restart_filename = joinpath("out", "restart_000000010.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
Expand Down
2 changes: 1 addition & 1 deletion examples/structured_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

elixir_file = "elixir_advection_extended.jl"
restart_file = "restart_000021.h5"
restart_file = "restart_000000021.h5"

trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))

Expand Down
2 changes: 1 addition & 1 deletion examples/structured_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"),
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000010.h5")
restart_filename = joinpath("out", "restart_000000010.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), a
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000040.h5")
restart_filename = joinpath("out", "restart_000000040.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_advection_restart_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), a
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000040.h5")
restart_filename = joinpath("out", "restart_000000040.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"))
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000019.h5")
restart_filename = joinpath("out", "restart_000000019.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/unstructured_2d_dgsem/elixir_euler_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_basic.jl"))
# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", "restart_000050.h5")
restart_filename = joinpath("out", "restart_000000050.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
Expand Down
11 changes: 10 additions & 1 deletion src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,15 @@ include("analysis_dg2d_parallel.jl")
include("analysis_dg3d.jl")
include("analysis_dg3d_parallel.jl")

# This version of `analyze` is used for [`AnalysisSurfaceIntegral`](@ref) which requires
# `semi` to be passed along to retrieve the current boundary indices, which are non-static
# in the case of AMR.
function analyze(quantity::AnalysisSurfaceIntegral, du, u, t,
semi::AbstractSemidiscretization)
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
analyze(quantity, du, u, t, mesh, equations, solver, cache, semi)
end

# Special analyze for `SemidiscretizationHyperbolicParabolic` such that
# precomputed gradients are available. Required for `enstrophy` (see above) and viscous forces.
# Note that this needs to be included after `analysis_surface_integral_2d.jl` to
Expand All @@ -669,6 +678,6 @@ function analyze(quantity::AnalysisSurfaceIntegral{Variable},
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
equations_parabolic = semi.equations_parabolic
cache_parabolic = semi.cache_parabolic
analyze(quantity, du, u, t, mesh, equations, equations_parabolic, solver, cache,
analyze(quantity, du, u, t, mesh, equations, equations_parabolic, solver, cache, semi,
cache_parabolic)
end
48 changes: 25 additions & 23 deletions src/callbacks_step/analysis_surface_integral_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,18 @@ drag coefficient [`DragCoefficientPressure`](@ref) of e.g. an airfoil with the b
name `:Airfoil` in 2D.
- `semi::Semidiscretization`: Passed in to retrieve boundary condition information
- `boundary_symbol_or_boundary_symbols::Symbol|Vector{Symbol}`: Name(s) of the boundary/boundaries
- `boundary_symbols::NTuple{NBoundaries, Symbol}`: Name(s) of the boundary/boundaries
where the quantity of interest is computed
- `variable::Variable`: Quantity of interest, like lift or drag
"""
struct AnalysisSurfaceIntegral{Variable}
indices::Vector{Int} # Indices in `boundary_condition_indices` where quantity of interest is computed
struct AnalysisSurfaceIntegral{Variable, NBoundaries}
variable::Variable # Quantity of interest, like lift or drag
boundary_symbols::NTuple{NBoundaries, Symbol} # Name(s) of the boundary/boundaries

function AnalysisSurfaceIntegral(semi, boundary_symbol, variable)
@unpack boundary_symbol_indices = semi.boundary_conditions
indices = boundary_symbol_indices[boundary_symbol]

return new{typeof(variable)}(indices, variable)
end

function AnalysisSurfaceIntegral(semi, boundary_symbols::Vector{Symbol}, variable)
@unpack boundary_symbol_indices = semi.boundary_conditions
indices = Vector{Int}()
for name in boundary_symbols
append!(indices, boundary_symbol_indices[name])
end
sort!(indices)

return new{typeof(variable)}(indices, variable)
function AnalysisSurfaceIntegral(semi,
boundary_symbols::NTuple{NBoundaries, Symbol},
variable) where {NBoundaries}
return new{typeof(variable), NBoundaries}(variable, boundary_symbols)
end
end

Expand Down Expand Up @@ -255,14 +243,26 @@ function (drag_coefficient::DragCoefficientShearStress)(u, normal_direction, x,
(0.5 * rhoinf * uinf^2 * linf)
end

function get_boundary_indices(boundary_symbols, boundary_symbol_indices)
indices = Int[]
for name in boundary_symbols
append!(indices, boundary_symbol_indices[name])
end
sort!(indices) # Try to achieve some data locality by sorting

return indices
end

function analyze(surface_variable::AnalysisSurfaceIntegral, du, u, t,
mesh::P4estMesh{2},
equations, dg::DGSEM, cache)
equations, dg::DGSEM, cache, semi)
@unpack boundaries = cache
@unpack surface_flux_values, node_coordinates, contravariant_vectors = cache.elements
@unpack weights = dg.basis

@unpack indices, variable = surface_variable
@unpack variable, boundary_symbols = surface_variable
@unpack boundary_symbol_indices = semi.boundary_conditions
indices = get_boundary_indices(boundary_symbols, boundary_symbol_indices)

surface_integral = zero(eltype(u))
index_range = eachnode(dg)
Expand Down Expand Up @@ -308,13 +308,15 @@ end
function analyze(surface_variable::AnalysisSurfaceIntegral{Variable},
du, u, t, mesh::P4estMesh{2},
equations, equations_parabolic,
dg::DGSEM, cache,
dg::DGSEM, cache, semi,
cache_parabolic) where {Variable <: VariableViscous}
@unpack boundaries = cache
@unpack surface_flux_values, node_coordinates, contravariant_vectors = cache.elements
@unpack weights = dg.basis

@unpack indices, variable = surface_variable
@unpack variable, boundary_symbols = surface_variable
@unpack boundary_symbol_indices = semi.boundary_conditions
indices = get_boundary_indices(boundary_symbols, boundary_symbol_indices)

# Additions for parabolic
@unpack viscous_container = cache_parabolic
Expand Down
Loading

0 comments on commit 6345c6f

Please sign in to comment.