Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b964c93
new paragraph: Boundary conditions
vincmarks Jul 17, 2025
d9790da
new paragraph: Boundary conditions
vincmarks Jul 17, 2025
c1ceea3
additional functions for default choice of boundary conditions
vincmarks Jul 17, 2025
ffc3e41
added the default condition functions in Trixi
vincmarks Jul 17, 2025
7737998
added the tree mesh default boundary condition
vincmarks Aug 7, 2025
dc011bf
add boundary condition paragraph
vincmarks Aug 7, 2025
284972e
some reformulaition
vincmarks Aug 7, 2025
b1d5f25
Merge remote-tracking branch 'upstream/main'
vincmarks Aug 7, 2025
752aeed
added the boundary_condition_default_tree funtions to trixi
vincmarks Aug 7, 2025
a4378aa
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
1331679
Update docs/src/meshes/tree_mesh.md
vincmarks Sep 25, 2025
170590d
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
4f0b064
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
446c35c
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
b210598
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
fdc03f4
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
1a13708
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
b0c90fb
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
a49e325
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
35dc6c9
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
f668846
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
f08d444
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
29a2923
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
ffbfe39
Update src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
vincmarks Sep 25, 2025
6525572
Merge branch 'main' into main
JoshuaLampert Sep 25, 2025
6485964
Apply suggestions from code review
vincmarks Sep 25, 2025
a094957
added reference files to get an impression of the new function: boun…
vincmarks Sep 25, 2025
231ac02
adding examples for the boundary_condition_default(mesh, boundary_con…
vincmarks Sep 25, 2025
75be46e
included the default_boundary_conditions.jl file and the boundary_con…
vincmarks Sep 25, 2025
0c00a4a
create a new file (default_boundary_conditions.jl)for the boundary_co…
vincmarks Sep 25, 2025
3a66fa2
Merge branch 'main' of github.com:vincmarks/Trixi.jl
vincmarks Sep 25, 2025
dbc823b
fixed typo: named tuples instead of dicitonaries
vincmarks Sep 25, 2025
c87e74b
Merge branch 'main' into main
DanielDoehring Sep 25, 2025
f4d82a3
Merge branch 'main' into main
ranocha Oct 10, 2025
03da9a6
Merge branch 'main' into main
DanielDoehring Oct 12, 2025
e86c2ba
delete unnecessary functions
vincmarks Oct 19, 2025
2ead177
only use boundary_condition_default function
vincmarks Oct 19, 2025
402c84c
formatting
vincmarks Oct 19, 2025
b4f2b39
Merge branch 'main' of github.com:vincmarks/Trixi.jl
vincmarks Oct 19, 2025
eb3e2fc
Syncen with Trixi.jl
vincmarks Oct 19, 2025
85a9b82
Sync with upstream main branch
vincmarks Oct 19, 2025
d97c162
Apply suggestions from code review
vincmarks Oct 27, 2025
76b67f6
Merge remote-tracking branch 'upstream/main'
vincmarks Oct 27, 2025
0583638
using the function ``boundary_condition_default ``
vincmarks Oct 27, 2025
a6a9bae
fixed typo
vincmarks Oct 27, 2025
bfd6fdf
using the function boundary_condition_default
vincmarks Oct 28, 2025
0d35888
not using the function boundary_condition_default here
vincmarks Oct 28, 2025
f5538da
changed the file where the function `boundary_condition_default(mesh,…
vincmarks Oct 28, 2025
57646b7
Merge branch 'main' into main
DanielDoehring Oct 28, 2025
171347a
Merge branch 'main' into main
ranocha Oct 29, 2025
64152a1
Apply suggestions from code review
vincmarks Oct 29, 2025
0303bf6
Merge branch 'main' into main
ranocha Oct 29, 2025
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
8 changes: 8 additions & 0 deletions docs/src/meshes/p4est_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,3 +939,11 @@ rebalance_solver!(u0, mesh, equations, dg, cache, old_global_first_quadrant)
reinitialize_boundaries!(semi.boundary_conditions, cache) # Needs to be called after `rebalance_solver!`
```
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 `P4est meshes`, boundary conditions are defined and stored in dictionaries (as shown for example in `examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_amr.jl`). If you’d like to apply the same condition to every face of the mesh, you can use the convenient functions `boundary_condition_default_p4est_2D` and `boundary_condition_default_p4est_3D`. For example, in the two dimensional case:

```julia
boundary_condition = boundary_condition_slip_wall
boundary_conditions = boundary_condition_default_p4est_2D(boundary_condition)
```
8 changes: 8 additions & 0 deletions docs/src/meshes/structured_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ such as the compressible Euler equations can use [`FluxRotated`](@ref) to
wrap numerical fluxes implemented only for Cartesian meshes. This simplifies
the re-use of existing functionality for the [`TreeMesh`](@ref) but is usually
less efficient, cf. [PR #550](https://github.com/trixi-framework/Trixi.jl/pull/550).

### Boundary conditions
For `Structured meshes`, boundary conditions are defined and stored in named tuples (as shown for example in `examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl`). If you’d like to apply the same condition to every face of the mesh, you can use the convenient functions `boundary_condition_default_structured_1D`, `boundary_condition_default_structured_2D` and `boundary_condition_default_structured_3D`. For example, in the one dimensional case:

```julia
boundary_condition = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = boundary_condition_default_structured_1D(boundary_condition)
```
10 changes: 10 additions & 0 deletions docs/src/meshes/tree_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ It is limited to hypercube domains (that is, lines in 1D, squares in 2D and cube
Due to its Cartesian nature, (numerical) fluxes need to implement methods
dispatching on the `orientation::Integer` as described in the
[conventions](@ref conventions).


### Boundary conditions
For `TreeMesh`es, boundary conditions are defined and stored in named tuples (as shown for example in `examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl`). If you’d like to apply the same condition to every face of the mesh, you can use the convenient `functions boundary_condition_default_tree_1D`, `boundary_condition_default_tree_2D` and `boundary_condition_default_tree_3D`. For example, in the two dimensional case:

```julia
initial_condition = initial_condition_eriksson_johnson

boundary_conditions = boundary_condition_default_tree_2D(BoundaryConditionDirichlet(initial_condition))
```
8 changes: 8 additions & 0 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ export initial_condition_constant,
initial_condition_weak_blast_wave

export boundary_condition_do_nothing,
boundary_condition_default_p4est_2D,
boundary_condition_default_p4est_3D,
boundary_condition_default_structured_1D,
boundary_condition_default_structured_2D,
boundary_condition_default_structured_3D,
boundary_condition_default_tree_1D,
boundary_condition_default_tree_2D,
boundary_condition_default_tree_3D,
boundary_condition_periodic,
BoundaryConditionDirichlet,
BoundaryConditionNeumann,
Expand Down
198 changes: 197 additions & 1 deletion src/solvers/dgsem_unstructured/sort_boundary_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,200 @@ end

# @eval due to @muladd
@eval Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
end # @muladd


"""
boundary_condition_default_p4est_2D(boundary_condition)

Create a default boundary condition dictionary for p4est meshes in 2D
that use the standard boundary naming convention.

This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary

# Arguments
- `boundary_condition`: The boundary condition function to apply to all boundaries

# Returns
- `Dict{Symbol, Any}`: Dictionary mapping boundary names to the boundary condition
"""
function boundary_condition_default_p4est_2D(boundary_condition)

return Dict(:x_neg => boundary_condition,
:y_neg => boundary_condition,
:y_pos => boundary_condition,
:x_pos => boundary_condition)
end

"""
boundary_condition_default_3D(boundary_condition)

Create a default boundary condition dictionary for p4est meshes in 3D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary
- `:z_neg`: negative z-direction boundary
- `:z_pos`: positive z-direction boundary
# Arguments
- `boundary_condition`: The boundary condition function to apply to all boundaries
# Returns
- `Dict{Symbol, Any}`: Dictionary mapping boundary names to the boundary condition
"""

function boundary_condition_default_p4est_3D(boundary_condition)

return Dict(:x_neg => boundary_condition,
:x_pos => boundary_condition,
:y_neg => boundary_condition,
:y_pos => boundary_condition,
:z_neg => boundary_condition,
:z_pos => boundary_condition)
end


"""
boundary_condition_default_structured_1D(boundary_condition)

Create a default boundary condition dictionary for structured meshes in 1D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
# Arguments
- `boundarycondition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition
"""
function boundary_condition_default_structured_1D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition)
end
"""
boundary_condition_default_structured_2D(boundary_condition)

Create a default boundary condition dictionary for structured meshes in 2D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary
# Arguments
- `boundarycondition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition
"""
function boundary_condition_default_structured_2D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition,
y_neg = boundary_condition,
y_pos = boundary_condition)
end

"""
boundary_condition_default_structured_3D(boundary_condition)

Create a default boundary condition dictionary for structured meshes in 3D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary
- `:z_neg`: negative z-direction boundary
- `:z_pos`: positive z-direction boundary
# Arguments
- `boundarycondition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition
"""
function boundary_condition_default_structured_3D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition,
y_neg = boundary_condition,
y_pos = boundary_condition,
z_neg = boundary_condition,
z_pos = boundary_condition)

end


"""
boundary_condition_default_tree_1D(boundary_condition)

Create a default boundary condition dictionary for tree meshes in 1D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
# Arguments
- `boundary_condition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition

"""
function boundary_condition_default_tree_1D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition)
end

"""
boundary_condition_default_tree_2D(boundary_condition)

Create a default boundary condition dictionary for tree meshes in 2D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary
# Arguments
- `boundary_condition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition
"""
function boundary_condition_default_tree_2D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition,
y_neg = boundary_condition,
y_pos = boundary_condition)
end

"""
boundary_condition_default_tree_3D(boundary_condition)

Create a default boundary condition dictionary for tree meshes in 3D
that use the standard boundary naming convention.
This function applies the same boundary condition to all standard boundaries:
- `:x_neg`: negative x-direction boundary
- `:x_pos`: positive x-direction boundary
- `:y_neg`: negative y-direction boundary
- `:y_pos`: positive y-direction boundary
- `:z_neg`: negative z-direction boundary
- `:z_pos`: positive z-direction boundary
# Arguments
- `boundary_condition`: The boundary condition function to apply to all boundaries
# Returns
- Named tuple mapping boundary names to the boundary condition
"""
function boundary_condition_default_tree_3D(boundary_condition)

return (x_neg = boundary_condition,
x_pos = boundary_condition,
y_neg = boundary_condition,
y_pos = boundary_condition,
z_neg = boundary_condition,
z_pos = boundary_condition)
end
end#@muladd