Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d104ca8
allow Dict and NamedTuple as boundary conditions
JoshuaLampert Jan 26, 2026
0f7a215
unify handling of periodic boundary conditions
JoshuaLampert Jan 26, 2026
bf14cff
add tests for T8codeMesh and UnstructuredMesh2D
JoshuaLampert Jan 26, 2026
3f937c9
test actual boundary conditions
JoshuaLampert Jan 26, 2026
afcc7e4
move new test file to unit tests
JoshuaLampert Jan 26, 2026
53e54d8
format
JoshuaLampert Jan 26, 2026
1241830
enforce SciMLBase.jl v2.134.0
JoshuaLampert Jan 26, 2026
0fdf0b1
revert restriction on SciMLBase.jl
JoshuaLampert Jan 26, 2026
9cbd5ea
also test other dimensions for coverage
JoshuaLampert Jan 26, 2026
41f8f06
coverage
JoshuaLampert Jan 26, 2026
7fe0390
always use NamedTuples instead of Dicts
JoshuaLampert Jan 27, 2026
7be0eec
Merge branch 'main' into unify-bc
JoshuaLampert Jan 27, 2026
a717ac4
use same syntax to for DGMulti to create NamedTuples
JoshuaLampert Jan 27, 2026
cf07be1
fix
JoshuaLampert Jan 27, 2026
8bf3b8a
fix more
JoshuaLampert Jan 27, 2026
cd1b285
format
JoshuaLampert Jan 27, 2026
cdc408d
fixed another one
JoshuaLampert Jan 27, 2026
3afabbf
fix one more
JoshuaLampert Jan 27, 2026
9b65490
consistently use semicolon for NamedTuples
JoshuaLampert Jan 27, 2026
e5a34bb
Add NEWS entry
JoshuaLampert Jan 27, 2026
5befb09
fix structured
JoshuaLampert Jan 27, 2026
dac81d8
use NamedTuple also in UnstructuredSortedBoundaryTypes
JoshuaLampert Jan 27, 2026
4420910
fixes
JoshuaLampert Jan 27, 2026
61cd1e6
remove periodic bcs by default
JoshuaLampert Jan 30, 2026
97d5810
simplify default boundary conditions
JoshuaLampert Jan 30, 2026
92551b2
Apply suggestions from code review
JoshuaLampert Jan 30, 2026
1e11c9c
Merge branch 'main' into unify-bc
JoshuaLampert Feb 4, 2026
552beb3
use NamedTuple for is_on_boundary
JoshuaLampert Feb 6, 2026
66beae6
Merge branch 'main' into unify-bc
JoshuaLampert Feb 6, 2026
6122b3d
Merge branch 'main' into unify-bc
JoshuaLampert Feb 6, 2026
723bae5
add some semicolons for consistency
JoshuaLampert Feb 6, 2026
d84e64b
Apply suggestion from @ranocha
JoshuaLampert Feb 6, 2026
10fb44f
Apply suggestion from @ranocha
JoshuaLampert Feb 6, 2026
0bcc5ed
Merge branch 'main' into unify-bc
JoshuaLampert Feb 6, 2026
e8e717b
improve type stability of UnstructuredSortedBoundaryTypes
ranocha Feb 7, 2026
d35588f
fix order of type parameters
ranocha Feb 7, 2026
603a0a9
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
ranocha Feb 7, 2026
84aecaf
Merge branch 'main' into unify-bc
ranocha Feb 7, 2026
8bf0f1e
No default boundary conditions (#2770)
JoshuaLampert Feb 7, 2026
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ for human readability.
## Changes when updating to v0.15 from v0.14.x

#### Changed

- Boundary conditions are now passed as a `NamedTuple` consistently across all mesh types, i.e., boundary conditions, which
were previously passed as a `Dict` for the `P4estMesh`, `T8codeMesh`, and `UnstructuredMesh2D` mesh types have to be converted to `NamedTuple`s ([#2761]).
- Renamed `energy_internal` for `NonIdealCompressibleEulerEquations1D` to `energy_internal_specific` ([#2762]). This makes `energy_internal` for `NonIdealCompressibleEulerEquations1D` consistent with the rest of Trixi.jl, where `energy_internal` refers to the specific internal energy scaled by density.
- The variable name (printed to the screen and files) of the total energy in the compressible Euler equations has been changed from `rho_e` to `rho_e_total` to avoid confusion with the internal energy `rho_e_internal` ([#2778]).
- `convergence_test` now returns the complete convergence orders and the full errors matrix. To obtain the mean convergence rates, use `Trixi.calc_mean_convergence` on the convergence orders ([#2753]).
Expand Down Expand Up @@ -37,6 +40,7 @@ for human readability.
## Changes in the v0.13 lifecycle

#### Added

- Initial 3D support for subcell limiting with `P4estMesh` was added ([#2582], [#2647], [#2688], [#2722]).
In the new version, IDP positivity limiting for conservative variables (using
the keyword `positivity_variables_cons` in `SubcellLimiterIDP()`) and nonlinear
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/src/files/DGMulti_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole());
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)
boundary_conditions = (; outer_boundary = boundary_condition_convergence_test,
inner_boundary = boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand Down
28 changes: 14 additions & 14 deletions docs/literate/src/files/hohqmesh_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ initial_condition = uniform_flow_state
## boundary condition types
boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state)

## boundary condition dictionary
boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow,
:Top => boundary_condition_uniform_flow,
:Right => boundary_condition_uniform_flow,
:Left => boundary_condition_uniform_flow,
:LeftSlant => boundary_condition_slip_wall,
:RightSlant => boundary_condition_slip_wall,
:IceCream => boundary_condition_slip_wall);
## boundary conditions (NamedTuple)
boundary_conditions = (; Bottom = boundary_condition_uniform_flow,
Top = boundary_condition_uniform_flow,
Right = boundary_condition_uniform_flow,
Left = boundary_condition_uniform_flow,
LeftSlant = boundary_condition_slip_wall,
RightSlant = boundary_condition_slip_wall,
IceCream = boundary_condition_slip_wall);

## DGSEM solver.
## 1) polydeg must be >= the polynomial order set in the HOHQMesh control file to guarantee
Expand Down Expand Up @@ -495,13 +495,13 @@ output = generate_mesh(control_file);

# We can reuse much of the elixir file to setup the uniform flow over an ice cream cone from the
# previous part of this tutorial. The only component of the elixir file that must be changed is the boundary condition
# dictionary because we now have a boundary named `OuterCircle` instead of four edges of a bounding box.
# `NamedTuple` because we now have a boundary named `OuterCircle` instead of four edges of a bounding box.

## boundary condition dictionary
boundary_conditions = Dict(:OuterCircle => boundary_condition_uniform_flow,
:LeftSlant => boundary_condition_slip_wall,
:RightSlant => boundary_condition_slip_wall,
:IceCream => boundary_condition_slip_wall);
## boundary conditions (NamedTuple)
boundary_conditions = (; OuterCircle = boundary_condition_uniform_flow,
LeftSlant = boundary_condition_slip_wall,
RightSlant = boundary_condition_slip_wall,
IceCream = boundary_condition_slip_wall);

# Also, we must update the construction of the mesh from our new mesh file `ice_cream_curved_sides.mesh` that
# is located in the `out` folder.
Expand Down
8 changes: 4 additions & 4 deletions docs/literate/src/files/p4est_from_gmsh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem",
# equations::CompressibleEulerEquations2D)
# flux = Trixi.flux(u_inner, normal_direction, equations)
#
# boundary_conditions = Dict(:PhysicalLine1 => boundary_condition_supersonic_inflow, # Left boundary
# :PhysicalLine2 => boundary_condition_supersonic_outflow, # Right boundary
# :PhysicalLine3 => boundary_condition_supersonic_outflow, # Top and bottom boundary
# :PhysicalLine4 => boundary_condition_slip_wall) # Airfoil
# boundary_conditions = (; PhysicalLine1 = boundary_condition_supersonic_inflow, # Left boundary
# PhysicalLine2 = boundary_condition_supersonic_outflow, # Right boundary
# PhysicalLine3 = boundary_condition_supersonic_outflow, # Top and bottom boundary
# PhysicalLine4 = boundary_condition_slip_wall) # Airfoil
#
# semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
# boundary_conditions = boundary_conditions)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/meshes/p4est_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,5 +941,5 @@ reinitialize_boundaries!(semi.boundary_conditions, cache) # Needs to be called a
This code could then be placed in the [`resize!`](https://github.com/trixi-framework/Trixi.jl/blob/eaeb04113523500ed831e3ab459694f12f7a49ea/src/time_integration/methods_2N.jl#L251-L255) function of a corresponding multirate integrator to ensure load-balancing for simulations involving AMR.

### Boundary conditions
For [`P4estMesh`](@ref)es, boundary conditions are defined and stored in [dictionaries](https://docs.julialang.org/en/v1/base/collections/#Base.Dict) (see, for example, `examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_amr.jl`).
For [`P4estMesh`](@ref)es, boundary conditions must be defined using [named tuples](https://docs.julialang.org/en/v1/manual/functions/#Named-Tuples) (see, for example, `examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_amr.jl`).
If you want to apply the same boundary condition to all faces of the mesh, you can use the `boundary_condition_default(mesh, boundary_condition)` function, as demonstrated in `examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_amr.jl` and `examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl`.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dg = DGMulti(basis,
volume_integral = volume_integral)

boundary_condition = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :entire_boundary => boundary_condition)
boundary_conditions = (; entire_boundary = boundary_condition)

###############################################################################
# setup the 1D mesh
Expand Down Expand Up @@ -90,7 +90,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, save_solution)
# ###############################################################################
# # run the simulation

# We use a fixed time step here, as the wave speed estimate
# We use a fixed time step here, as the wave speed estimate
# (which aims to bound the largest eigenvalues from above)
# in the stepsize callback produced sometimes unphysical values
sol = solve(ode, SSPRK43(), adaptive = false;
Expand Down
18 changes: 9 additions & 9 deletions examples/dgmulti_2d/elixir_advection_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ left(x, tol = 50 * eps()) = abs(x[1] + 1) < tol
right(x, tol = 50 * eps()) = abs(x[1] - 1) < tol
bottom(x, tol = 50 * eps()) = abs(x[2] + 1) < tol
top(x, tol = 50 * eps()) = abs(x[2] - 1) < tol
is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom)
is_on_boundary = (; left = left, right = right, top = top, bottom = bottom)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary)
Expand All @@ -29,16 +29,16 @@ boundary_condition_zero = BoundaryConditionDirichlet((x, t, equations_parabolic)
boundary_condition_neumann_zero = BoundaryConditionNeumann((x, t, equations_parabolic) -> SVector(0.0))

# define inviscid boundary conditions
boundary_conditions = (; :left => boundary_condition_left,
:bottom => boundary_condition_zero,
:top => boundary_condition_do_nothing,
:right => boundary_condition_do_nothing)
boundary_conditions = (; left = boundary_condition_left,
bottom = boundary_condition_zero,
top = boundary_condition_do_nothing,
right = boundary_condition_do_nothing)

# define viscous boundary conditions
boundary_conditions_parabolic = (; :left => boundary_condition_left,
:bottom => boundary_condition_zero,
:top => boundary_condition_zero,
:right => boundary_condition_neumann_zero)
boundary_conditions_parabolic = (; left = boundary_condition_left,
bottom = boundary_condition_zero,
top = boundary_condition_zero,
right = boundary_condition_neumann_zero)

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, dg;
Expand Down
14 changes: 7 additions & 7 deletions examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ right(x, tol = 50 * eps()) = abs(x[1]) < tol
bottom(x, tol = 50 * eps()) = abs(x[2] + 0.5) < tol
top(x, tol = 50 * eps()) = abs(x[2] - 0.5) < tol
entire_boundary(x, tol = 50 * eps()) = true
is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom,
:entire_boundary => entire_boundary)
is_on_boundary = (; left = left, right = right, top = top, bottom = bottom,
entire_boundary = entire_boundary)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension;
Expand All @@ -48,13 +48,13 @@ mesh = DGMultiMesh(dg, cells_per_dimension;
boundary_condition = BoundaryConditionDirichlet(initial_condition)

# define inviscid boundary conditions, enforce "do nothing" boundary condition at the outflow
boundary_conditions = (; :left => boundary_condition,
:top => boundary_condition,
:bottom => boundary_condition,
:right => boundary_condition_do_nothing)
boundary_conditions = (; left = boundary_condition,
top = boundary_condition,
bottom = boundary_condition,
right = boundary_condition_do_nothing)

# define viscous boundary conditions
boundary_conditions_parabolic = (; :entire_boundary => boundary_condition)
boundary_conditions_parabolic = (; entire_boundary = boundary_condition)

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, dg;
Expand Down
6 changes: 3 additions & 3 deletions examples/dgmulti_2d/elixir_euler_bilinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source_terms = source_terms_convergence_test
# example where we tag two separate boundary segments of the mesh
top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol
rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol)
is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary)
is_on_boundary = (; top = top_boundary, rest = rest_of_boundary)

function mapping(xi, eta)
x = xi + 0.1 * sin(pi * xi) * sin(pi * eta)
Expand All @@ -30,8 +30,8 @@ end
mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary = is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
:rest => boundary_condition_convergence_test)
boundary_conditions = (; top = boundary_condition_convergence_test,
rest = boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand Down
6 changes: 3 additions & 3 deletions examples/dgmulti_2d/elixir_euler_curved.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source_terms = source_terms_convergence_test
# example where we tag two separate boundary segments of the mesh
top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol
rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol)
is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary)
is_on_boundary = (; top = top_boundary, rest = rest_of_boundary)

function mapping(xi, eta)
x = xi + 0.1 * sin(pi * xi) * sin(pi * eta)
Expand All @@ -23,8 +23,8 @@ cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary = is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
:rest => boundary_condition_convergence_test)
boundary_conditions = (; top = boundary_condition_convergence_test,
rest = boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand Down
12 changes: 6 additions & 6 deletions examples/dgmulti_2d/elixir_euler_hohqmesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ initial_condition = initial_condition_convergence_test
source_terms = source_terms_convergence_test

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :Slant => boundary_condition_convergence_test,
:Bezier => boundary_condition_convergence_test,
:Right => boundary_condition_convergence_test,
:Bottom => boundary_condition_convergence_test,
:Top => boundary_condition_convergence_test)
boundary_conditions = (; Slant = boundary_condition_convergence_test,
Bezier = boundary_condition_convergence_test,
Right = boundary_condition_convergence_test,
Bottom = boundary_condition_convergence_test,
Top = boundary_condition_convergence_test)

###############################################################################
# Get the DG approximation space
Expand All @@ -27,7 +27,7 @@ boundary_conditions = (; :Slant => boundary_condition_convergence_test,
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# `StepsizeCallback` (CFL-Condition) and less diffusion.
dg = DGMulti(polydeg = 8, element_type = Quad(), approximation_type = SBP(),
surface_integral = SurfaceIntegralWeakForm(FluxLaxFriedrichs(max_abs_speed_naive)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mesh = DGMultiMesh(dg, cells_per_dimension,
periodicity = (true, false))

initial_condition = initial_condition_rayleigh_taylor_instability
boundary_conditions = (; :entire_boundary => boundary_condition_slip_wall)
boundary_conditions = (; entire_boundary = boundary_condition_slip_wall)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;
source_terms = source_terms_rayleigh_taylor_instability,
Expand Down
4 changes: 2 additions & 2 deletions examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole())
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)
boundary_conditions = (; outer_boundary = boundary_condition_convergence_test,
inner_boundary = boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand Down
6 changes: 3 additions & 3 deletions examples/dgmulti_2d/elixir_euler_weakform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ source_terms = source_terms_convergence_test
# example where we tag two separate boundary segments of the mesh
top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol
rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol)
is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary)
is_on_boundary = (; top = top_boundary, rest = rest_of_boundary)

cells_per_dimension = (8, 8)
mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary = is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
:rest => boundary_condition_convergence_test)
boundary_conditions = (; top = boundary_condition_convergence_test,
rest = boundary_condition_convergence_test)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms,
Expand Down
4 changes: 2 additions & 2 deletions examples/dgmulti_2d/elixir_mhd_reflective_wall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ initial_condition = initial_condition_perturbation
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# `StepsizeCallback` (CFL-Condition) and less diffusion.
surface_flux = (FluxLaxFriedrichs(max_abs_speed_naive), flux_nonconservative_powell)
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
Expand All @@ -46,7 +46,7 @@ x_neg(x, tol = 50 * eps()) = abs(x[1] + 1) < tol
x_pos(x, tol = 50 * eps()) = abs(x[1] - 1) < tol
y_neg(x, tol = 50 * eps()) = abs(x[2] + 1) < tol
y_pos(x, tol = 50 * eps()) = abs(x[2] - 1) < tol
is_on_boundary = Dict(:x_neg => x_neg, :x_pos => x_pos, :y_neg => y_neg, :y_pos => y_pos)
is_on_boundary = (; x_neg = x_neg, x_pos = x_pos, y_neg = y_neg, y_pos = y_pos)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(solver, cells_per_dimension; periodicity = (false, false),
Expand Down
Loading
Loading