-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix & refector: Incorrect v^2 calc in some pgens, and move Reducers out of Driver class. #188
Conversation
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.
Thanks for the catches! LGTM
@@ -78,6 +80,9 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) { | |||
const Real P = y < 0.25 ? P1 : P0; | |||
const Real vel = y < 0.25 ? v1 : v0; | |||
|
|||
Real gcov[4][4]; | |||
geom.SpacetimeMetric(0.0, x, y, 0.0, gcov); |
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.
not that it matters much, but why set z to zero here? Why not use the z from the coords?
@@ -247,7 +247,7 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) { | |||
} | |||
|
|||
Real vsq = 0.; | |||
SPACELOOP2(ii, jj) { vsq += v(ivlo + ii, k, j, i) * v(ivlo + jj, k, j, i); } | |||
SPACELOOP(ii) { vsq += v(ivlo + ii, k, j, i) * v(ivlo + ii, k, j, i); } |
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.
is the metric not needed for this one?
My comments are non-blockers, so I'm just going to merge. But may be wroth revisiting them at some point. |
The name says it all. When I was trying to test tracers with the 2D advection problem, I eventually found that the
vsq
calculation was erroneous, showing the following pattern (psueudocode):Namely, it was either 1) missing the metric (which would collapse the sum in Minkowski or 2) should've been manually collapsed to just
SPACELOOP(ii)
. The result wasvsq > 1
and unphysical Lorentz factors. This PR fixes that by pulling in the metric (opting for the more general solution). I noticed the same pattern in thekh
andlinear_modes
problems.kh
is fixed the same, whilelinear_modes
I replaced the loop with a 1DSPACELOOP
to not fight with the existing metric for when using e.g., snake coordinates.There's a (somewhat) unrelated refactor in this PR. I was working on adding a Parthenon-style advection regression test #187 but ran into an issue: the reducer objects for e.g.,
particle_resolution
in the Driver class would have their destructors called after MPI/Kokkos finalize and Phoebus would exit with an error code, which caused the regression testing to exit with an error, too. So, this PR also refactors those Reducer objects as mutable params intoradiation
andfluid
, where appropriate. I also split off the Driver creation and execution into its own scope. Not necessary with the refactor, but safer and potentially more future-proof. In a separate PR I'll pull in the regression testing (see #187 ).