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

Covariant formulation of the shallow water equations #58

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

tristanmontoya
Copy link
Member

@tristanmontoya tristanmontoya commented Dec 23, 2024

New version of #37 with entropy-stable split forms and auxiliary variables. Requires Trixi.jl v0.9.9 (see #59). The following new features are implemented:

  • New equation type CovariantShallowWaterEquations2D which implements the split formulation of the covariant derivative using non-conservative terms, but does not use non-conservative terms for the standard formulation. The split formulation conserves total energy when no interface dissipation is added.
  • Non-conservative flux-differencing and interface flux kernels for the covariant form using auxiliary variables.
  • Auxiliary variables expanded to include more geometric information, including Christoffel symbols (which, for the moment, are computed by applying the LGL collocation derivative operator to the analytical metric tensor components). Note that the split formulation is provably stable regardless of how these geometric terms are computed, although in the future, I plan to add the exact computation of the Christoffel symbols.
  • Analysis routines for covariant-form equations take integrals of functions of the form func(u, aux_vars, equations) rather than just func(u, equations), which is needed since entropy is a function of auxiliary variables in this case.
  • Standardized initial conditions with automatic conversions to the chosen global coordinate system (i.e. Cartesian or spherical) and set of conservative variables. Currently, we have the Gaussian solid-body rotation, steady geostrophic balance, and Rossby-Haurwitz wave, based on Cases 1, 2, and 6 of the Williamson et al. test suite, respectively.
  • Notation is changed to consistently use J rather than sqrtG for the area element.

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

Attention: Patch coverage is 95.42857% with 16 lines in your changes missing coverage. Please review.

Project coverage is 90.37%. Comparing base (1c05c56) to head (0b7bbc1).

Files with missing lines Patch % Lines
src/equations/covariant_advection.jl 72.22% 5 Missing ⚠️
src/equations/covariant_shallow_water.jl 95.45% 5 Missing ⚠️
src/equations/shallow_water_3d.jl 0.00% 4 Missing ⚠️
src/equations/equations.jl 97.36% 1 Missing ⚠️
...vers/dgsem_p4est/dg_2d_manifold_in_3d_covariant.jl 98.48% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   89.45%   90.37%   +0.92%     
==========================================
  Files          20       21       +1     
  Lines        1802     2099     +297     
==========================================
+ Hits         1612     1897     +285     
- Misses        190      202      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tristanmontoya tristanmontoya marked this pull request as ready for review January 3, 2025 21:20
@tristanmontoya tristanmontoya changed the title WIP: Covariant formulation of the shallow water equations Covariant formulation of the shallow water equations Jan 3, 2025
Copy link
Collaborator

@amrueda amrueda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, @tristanmontoya! great work!
I have not checked the math thoroughly, but I leave a couple of comments below.
BTW, thanks for improving the documentation of my elixirs as well!

Comment on lines +116 to +124
# Since the standard weak form for CovariantShallowWaterEquations2D has no nonconservative
# terms, but the equation type has have_nonconservative_terms = True(), we must define
# an appropriate kernel that just calls the standard weak form
@inline function Trixi.weak_form_kernel!(du, u, element, mesh::P4estMesh{2},
nonconservative_terms::True,
equations::AbstractCovariantEquations{2},
dg::DGSEM, cache, alpha = true)
Trixi.weak_form_kernel!(du, u, element, mesh, False(), equations, dg, cache, alpha)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you need this function (I am having the same problem in PR #53), but I think that we should include a computation of the non-conservative terms here. Otherwise, someone might try to use a non-conservative equation with the weak form kernel in the future and get a wrong result, but no dispatch error..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could use the flux_differencing_kernel! with a central flux. I think this won't be equivalent to the weak-form kernel, but maybe similar(?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I want to have a formulation that is exactly equivalent to the weak form as a baseline. This can be done using an equivalent flux-differencing form, but the nonconservative flux will return zero unless there is bottom topography. That's probably a better solution (and it won't return zero once we add the bottom topography).

src/equations/covariant_shallow_water.jl Outdated Show resolved Hide resolved
src/equations/covariant_shallow_water.jl Outdated Show resolved Hide resolved
src/equations/covariant_shallow_water.jl Outdated Show resolved Hide resolved
Comment on lines +72 to +75
# Our implementation of flux-differencing formulation uses nonconservative terms, but the
# standard weak form does not. To handle both options, we have defined a dummy kernel for
# the nonconservative terms that does nothing when VolumeIntegralWeakForm is used with a
# nonconservative system.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Modify this comment if the weak-form kernel changes.

src/equations/covariant_shallow_water.jl Outdated Show resolved Hide resolved
Comment on lines +195 to +197
# Entropy-conservative flux with local Lax-Friedrichs dissipation
const flux_ec_llf = FluxPlusDissipation(flux_ec,
DissipationLocalLaxFriedrichs(max_abs_speed_naive))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this provably ES or has any special property? For the Cartesian SW or Euler equations, we typically use the "standard" LLF with flux_central and DissipationLocalLaxFriedrichs, or the EC-LLF with flux_ec and a dissipation operator in terms of the Jump in entropy variables (only recently implemented in Trixi: trixi-framework/Trixi.jl#2204). Would the latter approach be better here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me realize that the "standard" (flux_central) approach does not work here as flux_ec is not consistent with flux... Can that be a problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure if it's provably entropy stable with this dissipation term, but I am also not sure about the standard LLF for this problem (we would have to do the theoretical analysis). The entropy variable jump approach would be my preference, but haven't looked into how straightforward the implementation would be. I will also look into what needs to be done to use the standard LLF here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants