Skip to content

Commit

Permalink
Add support for BoundaryConditionDirichlet for P4estMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Nov 22, 2023
1 parent 828d676 commit f7a810d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
21 changes: 18 additions & 3 deletions src/equations/compressible_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ Should be used together with [`StructuredMesh`](@ref).
return boundary_flux
end

# TODO: Add docstring when about to merge.
@inline function characteristic_boundary_value_function(outer_boundary_value_function,
u_inner, orientation::Integer,
direction, x, t, equations)
direction, x, t,
equations::CompressibleEulerEquations2D)
# Get inverse of density
srho = 1 / u_inner[1]

Expand All @@ -419,7 +421,8 @@ end
@inline function characteristic_boundary_value_function(outer_boundary_value_function,
u_inner,
normal_direction::AbstractVector,
direction, x, t, equations)
direction, x, t,
equations::CompressibleEulerEquations2D)
# Get normal velocity
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
factor = 1
Expand All @@ -434,10 +437,22 @@ end
u_inner, vn, x, t, equations)
end

@inline function characteristic_boundary_value_function(outer_boundary_value_function,
u_inner,
normal_direction::AbstractVector,
x, t,
equations::CompressibleEulerEquations2D)
vn = (normal_direction[1] * u_inner[2] + normal_direction[2] * u_inner[3]) /
norm(normal_direction)

return characteristic_boundary_value_function_inner(outer_boundary_value_function,
u_inner, vn, x, t, equations)
end

# Inner function to distinguish between different mesh types.
@inline function characteristic_boundary_value_function_inner(outer_boundary_value_function,
u_inner, vn, x, t,
equations)
equations::CompressibleEulerEquations2D)
# Get inverse of density
srho = 1 / u_inner[1]

Expand Down
16 changes: 16 additions & 0 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ end
return flux
end

# Characteristic-based boundary condition for use with P4estMesh
@inline function (boundary_condition::BoundaryConditionCharacteristic)(u_inner,
normal_direction,
x, t,
surface_flux_function,
equations)
u_boundary = characteristic_boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner, normal_direction, x, t,
equations)

# Calculate boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)

return flux
end

# operator types used for dispatch on parabolic boundary fluxes
struct Gradient end
struct Divergence end
Expand Down
19 changes: 17 additions & 2 deletions src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1872,8 +1872,8 @@ end
@inline function get_boundary_outer_state(u_inner, cache, t,
boundary_condition::BoundaryConditionCharacteristic,
orientation_or_normal, direction, equations,
dg, indices...)
@unpack node_coordinates = cache.elements
dg::DG, indices...)
(; node_coordinates) = cache.elements

x = get_node_coords(node_coordinates, equations, dg, indices...)
u_outer = boundary_condition.boundary_value_function(boundary_condition.outer_boundary_value_function,
Expand All @@ -1882,4 +1882,19 @@ end

return u_outer
end

@inline function get_boundary_outer_state(u_inner, cache, t,
boundary_condition::BoundaryConditionCharacteristic,
normal_direction::AbstractVector, equations,
dg::DG, indices...)
(; node_coordinates) = cache.elements

x = get_node_coords(node_coordinates, equations, dg, indices...)

u_outer = boundary_condition.boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner, normal_direction,
direction, x, t, equations)

return u_outer
end
end # @muladd

0 comments on commit f7a810d

Please sign in to comment.