Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New slip wall boundary condition for compressible Euler 2D/3D and APE #830

Merged
merged 30 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a5e109e
proper treatement of 2d slip wall BC for compressible Euler a la van …
andrewwinters5000 Aug 26, 2021
0b24443
update test values for the unstructured solver run with new wall BC
andrewwinters5000 Aug 26, 2021
dbb264a
update test values for Rayleigh-Taylor test in DGMulti with new wall BC
andrewwinters5000 Aug 26, 2021
011caa7
3d version of pressure Riemann slip wall BC and updated test
andrewwinters5000 Aug 26, 2021
2b3b776
update variable names and other suggestions from Michael
andrewwinters5000 Aug 26, 2021
3a2dd5d
simplified the APE slip wall BC
andrewwinters5000 Aug 26, 2021
8a6ff49
Merge branch 'main' into euler_wall_bc
andrewwinters5000 Aug 26, 2021
e4e6a09
alternative wave to compute external pressue and directly set the num…
andrewwinters5000 Aug 26, 2021
23e8f84
introduce new boundary condition function for the APE system
andrewwinters5000 Aug 27, 2021
4404713
introduce BoundaryConditionFlux and now use it for compressible Euler…
andrewwinters5000 Aug 27, 2021
8d04330
accidentally added a work file that is now removed
andrewwinters5000 Aug 27, 2021
19d97fe
updated dgmulti elixir and test values with the new boundary flux tre…
andrewwinters5000 Aug 27, 2021
085f1ba
added a test for the new Euler slip wall BC on the tree mesh
andrewwinters5000 Aug 27, 2021
e1409a2
Apply suggestions from code review
andrewwinters5000 Aug 27, 2021
470bdf5
Merge branch 'main' into euler_wall_bc
andrewwinters5000 Aug 30, 2021
faed4b5
Merge branch 'main' into euler_wall_bc
andrewwinters5000 Sep 1, 2021
c6faffa
change name to boundary_condition_noslip_wall in LatticeBoltzmann2D
andrewwinters5000 Sep 1, 2021
d1860bb
change name to boundary_condition_slip_wall for ape
andrewwinters5000 Sep 1, 2021
ba3e909
adjusted unstructured mesh results and 2d/3d compressible Euler now h…
andrewwinters5000 Sep 1, 2021
0c67203
change elixir for DGMulti Rayleigh-Taylor test
andrewwinters5000 Sep 1, 2021
122968e
removed BoundaryConditionFlux and now always dispatch on the new boun…
andrewwinters5000 Sep 1, 2021
7a4ef6d
Apply suggestions from code review
andrewwinters5000 Sep 2, 2021
7a8ed18
update test for the hohqmesh tutorial with the new wall boundary cond…
andrewwinters5000 Sep 2, 2021
2712b49
All hail to the CI chief
sloede Sep 3, 2021
bca5c96
simplified StructuredMesh2D wall bc. changed test values from those o…
andrewwinters5000 Sep 3, 2021
156df28
Merge branch 'main' into euler_wall_bc
sloede Sep 4, 2021
34b5830
Merge branch 'main' into euler_wall_bc
andrewwinters5000 Sep 6, 2021
0d36768
update TreeMesh2D Euler EC elixir to also test slip wall
andrewwinters5000 Sep 6, 2021
ea44d7b
swap out slip wall for RTI structured mesh test. update with new test…
andrewwinters5000 Sep 6, 2021
6921de2
cheaper structured mesh RTI with wall BCs
ranocha Sep 6, 2021
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ for human readability.

- Implementation of acoustic perturbation equations now uses the conservative form, i.e. the
perturbed pressure `p_prime` has been replaced with `p_prime_scaled = p_prime / c_mean^2`.
- Removed the experimental `BoundaryConditionWall` and instead directly compute slip wall boundary
condition flux term using the function `boundary_condition_slip_wall`.

#### Deprecated

Expand Down
1 change: 0 additions & 1 deletion docs/src/hohqmesh_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ initial_condition = uniform_flow_state

# boundary condition types
boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state)
boundary_condition_slip_wall = BoundaryConditionWall(boundary_state_slip_wall)

# boundary condition dictionary
boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ vy = map(x-> 0.5 * (1+x), vy) # map [-1, 1] to [0, 1] for single mode RTI
vertex_coordinates = (vx, vy)
mesh = VertexMappedMesh(vertex_coordinates, EToV, dg; is_periodic=(true,false))

boundary_conditions = (; :entire_boundary => BoundaryConditionWall(boundary_state_slip_wall))
boundary_conditions = (; :entire_boundary => boundary_condition_slip_wall)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_rayleigh_taylor_instability, dg;
source_terms = source_terms_rayleigh_taylor_instability,
Expand Down
1 change: 0 additions & 1 deletion examples/p4est_3d_dgsem/elixir_euler_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ equations = CompressibleEulerEquations3D(5/3)

initial_condition = initial_condition_weak_blast_wave

boundary_condition_slip_wall = BoundaryConditionWall(boundary_state_slip_wall)
boundary_conditions = Dict(
:all => boundary_condition_slip_wall
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,29 @@ solver = DGSEM(polydeg=3, surface_flux=flux_hll,
volume_integral=VolumeIntegralFluxDifferencing(volume_flux))

# The domain is [0, 0.25] x [0, 1]
mapping(xi, eta) = SVector(0.25 * 0.5 * (1 + xi), 0.5 * (1 + eta))
mapping(xi, eta) = SVector(0.25 * 0.5 * (1.0 + xi), 0.5 * (1.0 + eta))

num_elements_per_dimension = 32
cells_per_dimension = (num_elements_per_dimension, num_elements_per_dimension * 4)
mesh = StructuredMesh(cells_per_dimension, mapping)

boundary_condition_wall = BoundaryConditionWall(boundary_state_slip_wall)
initial_condition = initial_condition_rayleigh_taylor_instability

boundary_conditions = (
x_neg=boundary_condition_wall,
x_pos=boundary_condition_wall,
y_neg=boundary_condition_wall,
y_pos=boundary_condition_wall,
x_neg=boundary_condition_slip_wall,
x_pos=boundary_condition_slip_wall,
y_neg=boundary_condition_slip_wall,
y_pos=boundary_condition_slip_wall,
)

## Alternative setup: left/right periodic BCs and Dirichlet BCs on the top/bottom.
# # Alternative setup: left/right periodic BCs and Dirichlet BCs on the top/bottom.
# boundary_conditions = (
# x_neg=boundary_condition_periodic,
# x_pos=boundary_condition_periodic,
# y_neg=BoundaryConditionDirichlet(initial_condition),
# y_pos=BoundaryConditionDirichlet(initial_condition),
# )

initial_condition = initial_condition_rayleigh_taylor_instability
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
source_terms=source_terms_rayleigh_taylor_instability,
boundary_conditions=boundary_conditions)
Expand Down
10 changes: 6 additions & 4 deletions examples/tree_2d_dgsem/elixir_euler_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ volume_flux = flux_ranocha
solver = DGSEM(polydeg=3, surface_flux=flux_ranocha,
volume_integral=VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-2, -2)
coordinates_max = ( 2, 2)
coordinates_min = (-2.0, -2.0)
coordinates_max = ( 2.0, 2.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level=5,
n_cells_max=10_000)
n_cells_max=10_000,
periodicity=true)


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


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_lbm_couette.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ initial_condition = initial_condition_couette_unsteady
boundary_conditions = (
x_neg=boundary_condition_periodic,
x_pos=boundary_condition_periodic,
y_neg=boundary_condition_wall_noslip,
y_neg=boundary_condition_noslip_wall,
y_pos=boundary_condition_couette,
)

Expand Down
6 changes: 3 additions & 3 deletions examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ equations = LatticeBoltzmannEquations2D(Ma=0.1, Re=1000)

initial_condition = initial_condition_lid_driven_cavity
boundary_conditions = (
x_neg=boundary_condition_wall_noslip,
x_pos=boundary_condition_wall_noslip,
y_neg=boundary_condition_wall_noslip,
x_neg=boundary_condition_noslip_wall,
x_pos=boundary_condition_noslip_wall,
y_neg=boundary_condition_noslip_wall,
y_pos=boundary_condition_lid_driven_cavity,
)

Expand Down
1 change: 0 additions & 1 deletion examples/unstructured_2d_dgsem/elixir_ape_gauss_wall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ mesh = UnstructuredMesh2D(mesh_file)

initial_condition = initial_condition_gauss_wall

boundary_condition_slip_wall = BoundaryConditionWall(boundary_state_slip_wall)
boundary_conditions = Dict( :OuterCircle => boundary_condition_slip_wall,
:InnerCircle1 => boundary_condition_slip_wall,
:InnerCircle2 => boundary_condition_slip_wall,
Expand Down
1 change: 0 additions & 1 deletion examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ end
initial_condition = uniform_flow_state

boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state)
boundary_condition_slip_wall = BoundaryConditionWall(boundary_state_slip_wall)
boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow,
:Top => boundary_condition_uniform_flow,
:Right => boundary_condition_uniform_flow,
Expand Down
7 changes: 3 additions & 4 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,10 @@ export initial_condition_constant,

export boundary_condition_periodic,
BoundaryConditionDirichlet,
boundary_condition_wall_noslip,
boundary_condition_noslip_wall,
boundary_condition_slip_wall,
boundary_condition_wall,
boundary_condition_zero,
BoundaryConditionWall,
boundary_state_slip_wall
boundary_condition_zero

export initial_condition_convergence_test, source_terms_convergence_test
export initial_condition_harmonic_nonperiodic, source_terms_harmonic
Expand Down
63 changes: 35 additions & 28 deletions src/equations/acoustic_perturbation_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquat
return prim2cons(prim, equations)
end


"""
boundary_condition_wall(u_inner, orientation, direction, x, t, surface_flux_function,
equations::AcousticPerturbationEquations2D)
Expand Down Expand Up @@ -246,6 +247,7 @@ function initial_condition_monopole(x, t, equations::AcousticPerturbationEquatio
return prim2cons(prim, equations)
end


"""
boundary_condition_monopole(u_inner, orientation, direction, x, t, surface_flux_function,
equations::AcousticPerturbationEquations2D)
Expand Down Expand Up @@ -282,6 +284,7 @@ function boundary_condition_monopole(u_inner, orientation, direction, x, t, surf
return flux
end


"""
boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function,
equations::AcousticPerturbationEquations2D)
Expand All @@ -304,6 +307,38 @@ function boundary_condition_zero(u_inner, orientation, direction, x, t, surface_
return flux
end


"""
boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function,
equations::AcousticPerturbationEquations2D)

Use an orthogonal projection of the perturbed velocities to zero out the normal velocity
while retaining the possibility of a tangential velocity in the boundary state.
Further details are available in the paper:
- Marcus Bauer, Jürgen Dierke and Roland Ewert (2011)
Application of a discontinuous Galerkin method to discretize acoustic perturbation equations
[DOI: 10.2514/1.J050333](https://doi.org/10.2514/1.J050333)
"""
function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, x, t,
surface_flux_function, equations::AcousticPerturbationEquations2D)
# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)

# compute the normal perturbed velocity
u_normal = normal[1] * u_inner[1] + normal[2] * u_inner[2]

# create the "external" boundary solution state
u_boundary = SVector(u_inner[1] - 2.0 * u_normal * normal[1],
u_inner[2] - 2.0 * u_normal * normal[2],
u_inner[3], cons2mean(u_inner, equations)...)

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

return flux
end


# Calculate 1D flux for a single point
@inline function flux(u, orientation::Integer, equations::AcousticPerturbationEquations2D)
v1_prime, v2_prime, p_prime_scaled = cons2state(u, equations)
Expand Down Expand Up @@ -385,34 +420,6 @@ end
end


"""
boundary_state_slip_wall(u_inner, normal_direction::AbstractVector,
equations::AcousticPertubationEquations2D)

Idea behind this boundary condition is to use an orthogonal projection of the perturbed velocities
to zero out the normal velocity while retaining the possibility of a tangential velocity
in the boundary state. Further details are available in the paper:
- Marcus Bauer, Jürgen Dierke and Roland Ewert (2011)
Application of a discontinuous Galerkin method to discretize acoustic perturbation equations
[DOI: 10.2514/1.J050333](https://doi.org/10.2514/1.J050333)
"""
function boundary_state_slip_wall(u_inner, normal_direction::AbstractVector,
equations::AcousticPerturbationEquations2D)
# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)

# compute the normal and tangential components of the velocity
u_normal = normal[1] * u_inner[1] + normal[2] * u_inner[2]
u_tangent = (u_inner[1] - u_normal * normal[1], u_inner[2] - u_normal * normal[2])

return SVector(u_tangent[1] - u_normal * normal[1],
u_tangent[2] - u_normal * normal[2],
u_inner[3],
cons2mean(u_inner, equations)...)
end



@inline have_constant_speed(::AcousticPerturbationEquations2D) = Val(false)

@inline function max_abs_speeds(u, equations::AcousticPerturbationEquations2D)
Expand Down
107 changes: 92 additions & 15 deletions src/equations/compressible_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,29 +553,106 @@ end


"""
boundary_state_slip_wall(u_internal, normal_direction::AbstractVector,
equations::CompressibleEulerEquations2D)
boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function,
equations::CompressibleEulerEquations2D)

Determine the boundary numerical surface flux for a slip wall condition.
Imposes a zero normal velocity at the wall.
Density is taken from the internal solution state and pressure is computed as an
exact solution of a 1D Riemann problem. Further details about this boundary state
are available in the paper:
- J. J. W. van der Vegt and H. van der Ven (2002)
Slip flow boundary conditions in discontinuous Galerkin discretizations of
the Euler equations of gas dynamics
[PDF](https://reports.nlr.nl/bitstream/handle/10921/692/TP-2002-300.pdf?sequence=1)

Details about the 1D pressure Riemann solution can be found in Section 6.3.3 of the book
- Eleuterio F. Toro (2009)
Riemann Solvers and Numerical Methods for Fluid Dynamics: A Pratical Introduction
3rd edition
[DOI: 10.1007/b79761](https://doi.org/10.1007/b79761)

Should be used together with [`UnstructuredMesh2D`](@ref).

Determine the external solution value for a slip wall condition. Sets the normal
velocity of the the exterior fictitious element to the negative of the internal value.
!!! warning "Experimental code"
This wall function can change any time.
"""
function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, x, t,
surface_flux_function, equations::CompressibleEulerEquations2D)

norm_ = norm(normal_direction)
# Normalize the vector without using `normalize` since we need to multiply by the `norm_` later
normal = normal_direction / norm_

# rotate the internal solution state
u_local = rotate_to_x(u_inner, normal, equations)

# compute the primitive variables
rho_local, v_normal, v_tangent, p_local = cons2prim(u_local, equations)

# Get the solution of the pressure Riemann problem
# See Section 6.3.3 of
# Eleuterio F. Toro (2009)
# Riemann Solvers and Numerical Methods for Fluid Dynamics: A Pratical Introduction
# [DOI: 10.1007/b79761](https://doi.org/10.1007/b79761)
if v_normal <= 0.0
sound_speed = sqrt(equations.gamma * p_local / rho_local) # local sound speed
p_star = p_local * (1.0 + 0.5 * (equations.gamma - 1) * v_normal / sound_speed)^(2.0 * equations.gamma * equations.inv_gamma_minus_one)
else # v_normal > 0.0
A = 2.0 / ((equations.gamma + 1) * rho_local)
B = p_local * (equations.gamma - 1) / (equations.gamma + 1)
p_star = p_local + 0.5 * v_normal / A * (v_normal + sqrt(v_normal^2 + 4.0 * A * (p_local + B)))
end

# For the slip wall we directly set the flux as the normal velocity is zero
return SVector(zero(eltype(u_inner)),
p_star * normal[1],
p_star * normal[2],
zero(eltype(u_inner))) * norm_
end

"""
boundary_condition_slip_wall(u_inner, orientation, direction, x, t,
surface_flux_function, equations::CompressibleEulerEquations2D)
Should be used together with [`TreeMesh`](@ref).

!!! warning "Experimental code"
This wall function can change any time.
"""
@inline function boundary_state_slip_wall(u_internal, normal_direction::AbstractVector,
equations::CompressibleEulerEquations2D)
function boundary_condition_slip_wall(u_inner, orientation, direction, x, t,
surface_flux_function, equations::CompressibleEulerEquations2D)
# get the appropriate normal vector from the orientation
if orientation == 1
sloede marked this conversation as resolved.
Show resolved Hide resolved
normal = SVector(1, 0)
else # orientation == 2
normal = SVector(0, 1)
end

# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)
# compute and return the flux using `boundary_condition_slip_wall` routine above
return boundary_condition_slip_wall(u_inner, normal, x, t, surface_flux_function, equations)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
end

"""
boundary_condition_slip_wall(u_inner, normal_direction, direction, x, t,
surface_flux_function, equations::CompressibleEulerEquations2D)
Should be used together with [`StructuredMesh`](@ref).

# compute the normal and tangential components of the velocity
u_normal = normal[1] * u_internal[2] + normal[2] * u_internal[3]
u_tangent = (u_internal[2] - u_normal * normal[1], u_internal[3] - u_normal * normal[2])
!!! warning "Experimental code"
This wall function can change any time.
"""
function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, direction, x, t,
surface_flux_function, equations::CompressibleEulerEquations2D)
# flip sign of normal to make it outward pointing, then flip the sign of the normal flux back
# to be inward pointing on the -x and -y sides due to the orientation convention used by StructuredMesh
if isodd(direction)
boundary_flux = -boundary_condition_slip_wall(u_inner, -normal_direction,
x, t, surface_flux_function, equations)
else
boundary_flux = boundary_condition_slip_wall(u_inner, normal_direction,
x, t, surface_flux_function, equations)
end

return SVector(u_internal[1],
u_tangent[1] - u_normal * normal[1],
u_tangent[2] - u_normal * normal[2],
u_internal[4])
return boundary_flux
end


Expand Down
Loading