Trixi.jl icon indicating copy to clipboard operation
Trixi.jl copied to clipboard

WIP: Viscous terms from entropy gradients

Open andrewwinters5000 opened this issue 2 years ago • 10 comments

Computation of viscous fluxes in the compressible Navier-Stokes equations computed using the gradients of the entropy variables. New functions are marked with "TODO: parabolic; entropy stable viscous terms".

Currently, the default behavior is to use the entropy gradients for the viscous terms. So tests will not pass. For now it is setup this way for everyone to see how the new functionality works.

andrewwinters5000 avatar Aug 10 '22 13:08 andrewwinters5000

Codecov Report

Merging #1202 (0bf359e) into dev (a6db7a1) will increase coverage by 13.90%. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              dev    #1202       +/-   ##
===========================================
+ Coverage   82.90%   96.81%   +13.90%     
===========================================
  Files         326      326               
  Lines       24996    25047       +51     
===========================================
+ Hits        20722    24247     +3525     
+ Misses       4274      800     -3474     
Flag Coverage Δ
unittests 96.81% <100.00%> (+13.90%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...les/dgmulti_2d/elixir_navier_stokes_convergence.jl 100.00% <ø> (ø)
.../tree_2d_dgsem/elixir_navier_stokes_convergence.jl 100.00% <ø> (ø)
src/Trixi.jl 70.00% <ø> (ø)
src/solvers/dgsem_tree/dg_2d_parabolic.jl 99.54% <ø> (ø)
src/equations/compressible_navier_stokes_2d.jl 98.99% <100.00%> (+10.10%) :arrow_up:
src/equations/shallow_water_2d.jl 99.38% <0.00%> (+0.31%) :arrow_up:
src/equations/acoustic_perturbation_2d.jl 100.00% <0.00%> (+0.78%) :arrow_up:
src/callbacks_step/summary.jl 94.55% <0.00%> (+0.91%) :arrow_up:
src/equations/ideal_glm_mhd_3d.jl 100.00% <0.00%> (+0.92%) :arrow_up:
src/solvers/dgsem/basis_lobatto_legendre.jl 88.89% <0.00%> (+1.01%) :arrow_up:
... and 56 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 10 '22 15:08 codecov[bot]

I am suspicious that the entropy_timederivative analysis computation is working correctly for the hyperbolic + parabolic solver combo. The reason I say this is if I run the elixir from this PR elixir_navier_stokes_es.jl but change the solver to be

volume_flux = flux_ranocha
solver = DGSEM(polydeg=3, surface_flux=flux_ranocha,
               volume_integral=VolumeIntegralFluxDifferencing(volume_flux))

then the output at the final time (as well as during the time integration) says that the entropy time derivative is on the order of double precision roundoff, e.g., at the final time I get

 ∑∂S/∂U ⋅ Uₜ :   1.22496211e-16

This seems wrong because I set the Reynolds number to be 1600 in this elixir. So some dissipation should presumably be happening.

andrewwinters5000 avatar Aug 10 '22 17:08 andrewwinters5000

Yeah, that sounds like the parabolic rhs is getting incorporated...

It looks like the entropy timederivative analyzer is called using https://github.com/trixi-framework/Trixi.jl/blob/db25cc3eaf250d377ffde4f51b9374237f778da8/src/callbacks_step/analysis.jl#L221

I checked with a short example, and the SplitODE integrator cache seems like it is incorporating both RHS terms...

jlchan avatar Aug 10 '22 18:08 jlchan

It looks like the entropy timederivative analyzer is called using

https://github.com/trixi-framework/Trixi.jl/blob/db25cc3eaf250d377ffde4f51b9374237f778da8/src/callbacks_step/analysis.jl#L221

This is just to get some temporary vector to write the RHS to. In the next line, the RHS is computed using https://github.com/trixi-framework/Trixi.jl/blob/db25cc3eaf250d377ffde4f51b9374237f778da8/src/callbacks_step/analysis.jl#L222 I would have expected to get the full hyperbolic+parabolic RHS here...

ranocha avatar Aug 11 '22 05:08 ranocha

But I can reproduce the problem with

trixi_include("examples/tree_2d_dgsem/elixir_advection_diffusion.jl", surface_flux=flux_central)

on dev :disappointed_relieved:

ranocha avatar Aug 11 '22 05:08 ranocha

Okay, understood. I will make a PR to fix this

ranocha avatar Aug 11 '22 05:08 ranocha

Should be fixed once #1205 is merged into main and dev & this branch are updated.

ranocha avatar Aug 11 '22 06:08 ranocha

I checked with a short example, and the SplitODE integrator cache seems like it is incorporating both RHS terms...

Curiouser and curiouser...I will keep experimenting with the implementation. It could just be a bug on my end.

andrewwinters5000 avatar Aug 11 '22 07:08 andrewwinters5000

I checked with a short example, and the SplitODE integrator cache seems like it is incorporating both RHS terms...

Curiouser and curiouser...I will keep experimenting with the implementation. It could just be a bug on my end.

No, it isn't - it will be fixed by #1205

ranocha avatar Aug 11 '22 08:08 ranocha

No, it isn't - it will be fixed by #1205

Sorry, I missed part of the conversation (forgot to refresh the github page). Thanks for the fix!

andrewwinters5000 avatar Aug 11 '22 08:08 andrewwinters5000

I've added a draft of the GradientVariablesPrimitive and GradientVariablesEntropy type parameter in https://github.com/trixi-framework/Trixi.jl/pull/1202/commits/b876b9d4aed38b2aa1b04199be0a0006c2b491c4. The implementation is taken from my paper https://doi.org/10.1016/j.jcp.2021.110723.

I'm hoping to test this before I leave.

jlchan avatar Aug 16 '22 16:08 jlchan

OK, I have the entropy variables with boundary conditions working now. To test, run with

trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navier_stokes_convergence.jl"), gradient_variables=GradientVariablesEntropy())

or

trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navier_stokes_convergence.jl"), gradient_variables=GradientVariablesEntropy())

I introduced some steps which can probably be made more efficient. These are marked with TODO.

jlchan avatar Aug 16 '22 20:08 jlchan

@sloede should be ready to review for merging into dev now

jlchan avatar Aug 24 '22 13:08 jlchan

Thank you all! This looks mostly good to me. Do we have some docs for this functionality?

Only the docstrings - we don't yet have a can add a Literate.jl tutorial. I've added it as an item to https://github.com/trixi-framework/Trixi.jl/issues/1147. Would you be OK if I were to make a separate PR for that?

jlchan avatar Sep 06 '22 15:09 jlchan

Thanks!

jlchan avatar Sep 06 '22 15:09 jlchan