-
Notifications
You must be signed in to change notification settings - Fork 1
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 form as variable-coefficient problem using auxiliary variables #47
Conversation
…tion in Trixi.jl (cherry-picked from f45378e) Co-authored-by: Tristan Montoya <[email protected]>
…ltype() and ndims() functions for new struct
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 84.71% 87.49% +2.78%
==========================================
Files 11 17 +6
Lines 1125 1423 +298
==========================================
+ Hits 953 1245 +292
- Misses 172 178 +6 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
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.
Great work, Tristan!
I think that the use of the auxiliary variables makes the implementation cleaner!
Here a couple of comments and questions.
src/solvers/dgsem_p4est/containers_2d_manifold_in_3d_covariant.jl
Outdated
Show resolved
Hide resolved
src/solvers/dgsem_p4est/containers_2d_manifold_in_3d_covariant.jl
Outdated
Show resolved
Hide resolved
# Analytically compute the transformation matrix A, such that G = AᵀA is the | ||
# covariant metric tensor and a_i = A[1,i] * e_lon + A[2,i] * e_lat denotes | ||
# the covariant tangent basis, where e_lon and e_lat are the unit basis vectors | ||
# in the longitudinal and latitudinal directions, respectively. |
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.
Does the use of e_lon
and e_lat
imply a problem in (the vicinity of) the pole singularities? if it does, it should be properly stated. Moreover, is this the standard way to do this? Wouldn't it be a bit more general to use Cartesian unit vectors to store the covariant basis vectors?
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.
This is the standard way of doing things, and does not introduce any pole problem. This matrix is, in my opinion at least, more convenient than one using Cartesian coordinates, because it converts to/from spherical velocity components, which are typically more meaningful than Cartesian ones in a geophysical context (e.g. initial conditions are commonly defined in terms of zonal and meridional components, not Cartesian ones). It also is 2x2 instead of 3x2 and thus (marginally) cheaper for 2D manifolds.
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.
You are right, the initial conditions are commonly defined in terms of zonal and meridional components. However my concern is the following:
When I run the code above with
v1 = [0.0, 0.0, 1.0]
v2 = [1.0, 0.0, 0.0]
v3 = [0.0, 1.0, 0.0]
v4 = [0.0, sqrt(2.0) * 0.5, sqrt(2.0) * 0.5]
xi1, xi2 = -1.0, -1.0
then I get the covariant basis
julia> basis_covariant
2×2 SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
0.0 0.353553
-0.5 -8.96727e-18
However, if I run the code with
v1 = [eps(1.0), eps(1.0), 1.0]
v2 = [1.0, 0.0, 0.0]
v3 = [0.0, 1.0, 0.0]
v4 = [0.0, sqrt(2.0) * 0.5, sqrt(2.0) * 0.5]
xi1, xi2 = -1.0, -1.0
then I get the matrix
julia> basis_covariant
2×2 SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
-0.353553 0.25
-0.353553 -0.25
Very different(!!). Isn't that problematic?... This transformation matrix is used very often to transform the state quantities at the interfaces. What happens if some interface nodes are directly at / in the vicinity of the pole singularity?
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.
Interesting, I will have to investigate. I see this is used in several other codes, but I don't know if it's something that could cause problems or not.
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.
If we let
where
If the matrices
https://github.com/E3SM-Project/E3SM/blob/master/components/homme/src/share/cube_mod.F90#L696-L761
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.
The risk, in my opinion, is that the global coordinate system might be differently defined for two elements at different sides of the interface due to machine precision errors.
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.
I see. Could it be that even if
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.
I wonder if we should make a separate PR for improvements to this pole issue, as in my opinion, this is more of a scientific problem to be investigated, rather than an implementation error.
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.
I opened the issue #49
I suggest that we merge this PR but leave this conversation "unresolved" for the moment.
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.
LGTM! Thank you Tristan!
This potentially replaces #31 by implementing the strategy described in #46, where the geometric information needed by covariant-form fluxes and source terms is passed in as auxiliary variables. The
cache
is not passed around anymore.