Skip to content

Commit

Permalink
WIP: Sc/polytropic 2d wave speed (#1816)
Browse files Browse the repository at this point in the history
* Added coupling converters.

* Added generic converter_function for structured 2d meshes.

* Added example elixir for coupling converters.

* Cleaned up converter coupling elixir.

* Added equations in coupling converters.

* Added converter  functions.

* Added identity converter function.

* Autoformat for converter coupling implementation.

* Added coupled converter elixir.

* Corrected file name of coupled converters test.

* Removed redundant doc string.

* Added function signature in doc string.

* Removed coverage_override in coupled tests.

* Removed old commented code.

* Update make.jl

Added interface coupling docs to the main menu.

* Update make.jl

Moved converter coupling section.

* Create coupling.md

* Update coupling.md

Added some documentation on coupling converters.

* Removed troublesome AnalysisCallbackCoupled from test.

* Chenged coupling converter function.

* Changed coupling converter function and updated tests.

* Sepcialized coupling function call.

* Removed volume coupling from documentation to avoit confusion.

* Update src/coupling_converters/coupling_converters.jl

Co-authored-by: Hendrik Ranocha <[email protected]>

* Removed redundant converter function for coupling.

* Removed redundant coupling converter file mentioned in some files.

* Autoreformatted.

* Removed old coupled elixir and replaced it with one using converter functions.

* Updated errors for coupled tests.

* Corrected test results for coupled equations.

* Corrected comment.

* Removed coupled test from special tests.

* Removed coupled test from specials.

* Chaned the coupling function to the identity.

* Updated coupling tests.

* Updated errors for coupled test.

* Added advice about binary compatability for coupled equations in the documentation.

* Typo.

* Added numerical fluxes.

* Corrected rs copy routine. Now loop over this semi's components.

* Reformatted equations source file.

* Removed problemating include of time_integration.jl.

* Removed export of deleted methods.

* Reverted to old version of compressible Euler multicomponent with no support for structured grid.

* Renamed documentation file for multi-physics coupling.

* Renamed doc reference.

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Update docs/src/multi-physics_coupling.md

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Update docs/src/multi-physics_coupling.md

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Update docs/src/multi-physics_coupling.md

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Reinstated structured_2d_dgsem coupled in special tests.

* Update examples/structured_2d_dgsem/elixir_advection_coupled.jl

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Renamed CouplingFunction to CouplingConverter.

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

* Cleaned the copy of coupled boundary values.

* Reduced time span for example coupling elixir.

* Removed redundant loop.

* Applied formatter.

* Removed default coupling covnerter function.

* Moved coupling converter function into elixir.

* Apply suggestions from code review

Co-authored-by: Joshua Lampert <[email protected]>

* Update docs/make.jl

Co-authored-by: Joshua Lampert <[email protected]>

* Removed coupling_converters.jl from the include.

* Corrected introduced issue with coupling boundary copy.

The latest change to clean up the boundary copying
introduced a bug related to the determination of the wrong
node indices. This is now corrected.

* Corrected comment on final simulation time.

* Updated errors for coupled test to reflect changed final simulation time.

* Added miladd.

* Corrected coordinate finding in semidiscretization_coupled.

* Fixed issued related to memory allocation.

* Corrected loop over semidiscretization.

* Removed commented out code.

* Fixed type instability with loops over semidiscretizations using
lispy tuple programming.

* Removed obsolete code.

* Fixed another typa instability in coupled semidiscretization.

* Cleaning up of the coupled semidiscretization.

* Autoformatted coupled semidiscretization.

* Fixed last type instability in coupling.

* Autoformatter on semidiscretization.

* Fixed bug in boundary values copy that arose when coupling multiple systems.

* aplpied autoformatter on coupled semidiscretization.

* Extended the structured 2d example elixir for the coupled advection
to 4 semidiscretizations.

This hase two purpuses:
1. Users are given an example fro 2d coupling avoiding common pitfalls.
2. This increases the code coverege for the test.

* Updated test results for coupled advection in 2d to reflect
the 4 semidiscretizations that are now used.

* Added correct errors for tests for the coupled adveciton equations in structured 2d.

* Update examples/structured_2d_dgsem/elixir_advection_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update examples/structured_2d_dgsem/elixir_advection_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Update src/semidiscretization/semidiscretization_coupled.jl

Co-authored-by: Erik Faulhaber <[email protected]>

* Corrected foreach_enumerate implementation.

* Fix closing parens

* Remove unused recursive rhs!

* Pass equations to converter function

* Apply formatting

* Reverted copy_to_coupled_boundary to previou version
to avoid type instability.

* Corrected computation of coupled semidiscretizations and fixed memory issue.

* Removed redundant nelements function, as it is no longer used.

* Applied autoformatter.

* Added max_abs_speed_naive( and max_abs_speed_naive for PolytropicEulerEquations2D.

* Reverted coupling elixir to main branch version.
The modified version should be part of a different PR.

* Removed some modified coupling code as this should be part of a different PR.

* Reverted changes on ooupling semidiscretization as this should be part of a different PR.

* Reverted changes partaining the coupling PR.

* Removed changes partaining coupling PR.

* REverted to version including elixir_euler_warm_bubble.jl tests.

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrew Winters <[email protected]>

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrew Winters <[email protected]>

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrew Winters <[email protected]>

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrés Rueda-Ramírez <[email protected]>

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrés Rueda-Ramírez <[email protected]>

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Daniel Doehring <[email protected]>

* Added consistency and rotation test for LAx-friedrich fluxes for polytropic equations in 2d.

* Applied auto-formatter on polytropic 2d equation.

* Update src/equations/polytropic_euler_2d.jl

Co-authored-by: Andrew Winters <[email protected]>

---------

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
Co-authored-by: Hendrik Ranocha <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Erik Faulhaber <[email protected]>
Co-authored-by: Andrew Winters <[email protected]>
Co-authored-by: Andrés Rueda-Ramírez <[email protected]>
Co-authored-by: Daniel Doehring <[email protected]>
Co-authored-by: iomsn <[email protected]>
  • Loading branch information
9 people authored Feb 20, 2024
1 parent 3c9374b commit c5e743a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/equations/polytropic_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,46 @@ end
return abs(v1) + c, abs(v2) + c
end

# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the
# maximum velocity magnitude plus the maximum speed of sound
@inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer,
equations::PolytropicEulerEquations2D)
rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations)

# Get the velocity value in the appropriate direction
if orientation == 1
v_ll = v1_ll
v_rr = v1_rr
else # orientation == 2
v_ll = v2_ll
v_rr = v2_rr
end
# Calculate sound speeds (we have p = kappa * rho^gamma)
c_ll = sqrt(equations.gamma * equations.kappa * rho_ll^(equations.gamma - 1))
c_rr = sqrt(equations.gamma * equations.kappa * rho_rr^(equations.gamma - 1))

λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr)
end

@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector,
equations::PolytropicEulerEquations2D)
rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations)

# Calculate normal velocities and sound speed (we have p = kappa * rho^gamma)
# left
v_ll = (v1_ll * normal_direction[1] +
v2_ll * normal_direction[2])
c_ll = sqrt(equations.gamma * equations.kappa * rho_ll^(equations.gamma - 1))
# right
v_rr = (v1_rr * normal_direction[1] +
v2_rr * normal_direction[2])
c_rr = sqrt(equations.gamma * equations.kappa * rho_rr^(equations.gamma - 1))

return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction)
end

# Convert conservative variables to primitive
@inline function cons2prim(u, equations::PolytropicEulerEquations2D)
rho, rho_v1, rho_v2 = u
Expand Down
24 changes: 24 additions & 0 deletions test/test_unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,30 @@ end
end
end

@timed_testset "Consistency check for Lax-Friedrich flux: Polytropic CEE" begin
for gamma in [1.4, 1.0, 5 / 3]
kappa = 0.5 # Scaling factor for the pressure.
equations = PolytropicEulerEquations2D(gamma, kappa)
u = SVector(1.1, -0.5, 2.34)

orientations = [1, 2]
for orientation in orientations
@test flux_lax_friedrichs(u, u, orientation, equations)
flux(u, orientation, equations)
end

normal_directions = [SVector(1.0, 0.0),
SVector(0.0, 1.0),
SVector(0.5, -0.5),
SVector(-1.2, 0.3)]

for normal_direction in normal_directions
@test flux_lax_friedrichs(u, u, normal_direction, equations)
flux(u, normal_direction, equations)
end
end
end

@timed_testset "Consistency check for HLL flux with Davis wave speed estimates: LEE" begin
flux_hll = FluxHLL(min_max_speed_davis)

Expand Down

0 comments on commit c5e743a

Please sign in to comment.