-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add flexibility to nonconservative BCs #2200
base: main
Are you sure you want to change the base?
Changes from 26 commits
e2e2c20
1e925fc
31f1e0a
eb1ccdd
e4bc181
8c5d2fc
c2b44ae
b60eaf1
d7dce5e
840fa9e
2baa52a
cd2186b
7a326fe
f9b19c3
c35cff9
26a756a
307197d
8a1a3d5
5068717
06b881e
4d112a4
ecaf306
1bd0184
51505aa
d26925e
9b4e384
8332bbe
53d8a14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -74,13 +74,37 @@ struct BoundaryConditionDoNothing end | |||||||||
return surface_flux(u_inner, u_inner, orientation_or_normal_direction, equations) | ||||||||||
end | ||||||||||
|
||||||||||
# This version can be called by hyperbolic solvers on logically Cartesian meshes | ||||||||||
@inline function (::BoundaryConditionDoNothing)(u_inner, | ||||||||||
orientation_or_normal_direction, | ||||||||||
direction::Integer, x, t, | ||||||||||
surface_flux_functions::Tuple, | ||||||||||
equations) | ||||||||||
surface_flux_function, nonconservative_flux_function = surface_flux_functions | ||||||||||
return surface_flux_function(u_inner, u_inner, orientation_or_normal_direction, | ||||||||||
equations), | ||||||||||
Comment on lines
+84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For nicer/unified formatting? |
||||||||||
nonconservative_flux_function(u_inner, u_inner, | ||||||||||
orientation_or_normal_direction, equations) | ||||||||||
end | ||||||||||
|
||||||||||
# This version can be called by hyperbolic solvers on unstructured, curved meshes | ||||||||||
@inline function (::BoundaryConditionDoNothing)(u_inner, | ||||||||||
outward_direction::AbstractVector, | ||||||||||
x, t, surface_flux, equations) | ||||||||||
return surface_flux(u_inner, u_inner, outward_direction, equations) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
see comment above |
||||||||||
end | ||||||||||
|
||||||||||
@inline function (::BoundaryConditionDoNothing)(u_inner, | ||||||||||
outward_direction::AbstractVector, | ||||||||||
x, t, surface_flux_functions::Tuple, | ||||||||||
equations) | ||||||||||
surface_flux_function, nonconservative_flux_function = surface_flux_functions | ||||||||||
|
||||||||||
return surface_flux_function(u_inner, u_inner, outward_direction, equations), | ||||||||||
nonconservative_flux_function(u_inner, u_inner, outward_direction, | ||||||||||
equations) | ||||||||||
end | ||||||||||
|
||||||||||
# This version can be called by parabolic solvers | ||||||||||
@inline function (::BoundaryConditionDoNothing)(inner_flux_or_state, other_args...) | ||||||||||
return inner_flux_or_state | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -349,7 +349,6 @@ end | |||||||||
boundary_index) | ||||||||||
@unpack boundaries = cache | ||||||||||
@unpack node_coordinates, contravariant_vectors = cache.elements | ||||||||||
surface_flux, nonconservative_flux = surface_integral.surface_flux | ||||||||||
|
||||||||||
# Extract solution data from boundary container | ||||||||||
u_inner = get_node_vars(boundaries.u, equations, dg, node_index, boundary_index) | ||||||||||
|
@@ -364,20 +363,17 @@ end | |||||||||
|
||||||||||
# Call pointwise numerical flux function for the conservative part | ||||||||||
# in the normal direction on the boundary | ||||||||||
Comment on lines
364
to
365
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
flux_ = boundary_condition(u_inner, normal_direction, x, t, surface_flux, equations) | ||||||||||
|
||||||||||
# Compute pointwise nonconservative numerical flux at the boundary. | ||||||||||
noncons_ = boundary_condition(u_inner, normal_direction, x, t, nonconservative_flux, | ||||||||||
equations) | ||||||||||
flux, noncons_flux = boundary_condition(u_inner, normal_direction, x, t, | ||||||||||
surface_integral.surface_flux, equations) | ||||||||||
|
||||||||||
# Copy flux to element storage in the correct orientation | ||||||||||
for v in eachvariable(equations) | ||||||||||
DanielDoehring marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
# Note the factor 0.5 necessary for the nonconservative fluxes based on | ||||||||||
# the interpretation of global SBP operators coupled discontinuously via | ||||||||||
# central fluxes/SATs | ||||||||||
Comment on lines
371
to
373
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment would possibly need added to where the factor of 0.5 scaling occurs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am also not very content that we have to expose this to the user in order to specify the boundary condition, but I don't see a better way to accomplish this. I definitely think that we should comment this to give some explanation where the factor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with all of you. I'm also not a huge fan of the factor
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this idea, since it doesn't require knowledge about the implementation aspect of adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also like this idea with the documentation of how it would work in practice from Patrick's comment above. That is, for something like the standard shallow water equations the jump in the bottom topography is zero at the physical boundary (typically) so one's new boundary condition could compute the conservative flux pieces and then have return flux_, SVector(0,0,0,0) # flux, noncons |
||||||||||
surface_flux_values[v, node_index, direction_index, element_index] = flux_[v] + | ||||||||||
surface_flux_values[v, node_index, direction_index, element_index] = flux[v] + | ||||||||||
0.5f0 * | ||||||||||
noncons_[v] | ||||||||||
noncons_flux[v] | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -426,7 +426,6 @@ end | |||||||||
surface_integral, dg::DG, cache, | ||||||||||
node_index, side_index, element_index, | ||||||||||
boundary_index) | ||||||||||
surface_flux, nonconservative_flux = surface_integral.surface_flux | ||||||||||
@unpack normal_directions = cache.elements | ||||||||||
@unpack u, node_coordinates = cache.boundaries | ||||||||||
|
||||||||||
|
@@ -442,11 +441,10 @@ end | |||||||||
|
||||||||||
# Call pointwise numerical flux function for the conservative part | ||||||||||
# in the normal direction on the boundary | ||||||||||
Comment on lines
442
to
443
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
flux = boundary_condition(u_inner, outward_direction, x, t, surface_flux, equations) | ||||||||||
flux, noncons_flux = boundary_condition(u_inner, outward_direction, x, t, | ||||||||||
surface_integral.surface_flux, equations) | ||||||||||
|
||||||||||
# Compute pointwise nonconservative numerical flux at the boundary. | ||||||||||
Comment on lines
446
to
447
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This comment can be removed. |
||||||||||
noncons_flux = boundary_condition(u_inner, outward_direction, x, t, | ||||||||||
nonconservative_flux, equations) | ||||||||||
|
||||||||||
for v in eachvariable(equations) | ||||||||||
# Note the factor 0.5 necessary for the nonconservative fluxes based on | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a previous PR (https://github.com/trixi-framework/Trixi.jl/pull/2062/files#r1768020588) I changed this from
flux
tosurface_flux
. such that the BC works for both conservative and nonconservative systems. Now that we treat them separately, we should be able to only use theflux
-function in the conservative case.