-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add InverseJacobianInertialToFluidCompute #5811
Add InverseJacobianInertialToFluidCompute #5811
Conversation
c2a263b
to
9304927
Compare
Changed the accuracy required in the test; the default worked in Release mode on wheeler (at least every time I tried it) but consistently failed in Debug mode and for many of the configurations run by Jenkins. |
gr::Tags::SpatialMetric<DataVector, 3> >; | ||
|
||
static void function(gsl::not_null<return_type*> inv_jacobian, | ||
const tnsr::I<DataVector, 3>& spatial_velocity, |
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.
Fix formatting.
(spatial_velocity.get(d) - shift.get(d) / get(lapse)); | ||
} | ||
|
||
// Then, the other members of the tetrad are constructed using Gram-Shmidt |
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.
"Schmidt"
// Temporary memory allocation | ||
DataVector temp_dot_product = get(lapse) * 0.0; | ||
std::array<DataVector, 4> tetrad_vector{temp_dot_product, temp_dot_product, | ||
temp_dot_product, temp_dot_product}; |
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.
Instead of using this temporary, write the result directly into the inv_jacobian
matrix. That saves four memory allocations, which is good for both speed and memory use.
// Then, the other members of the tetrad are constructed using Gram-Shmidt | ||
|
||
// Temporary memory allocation | ||
DataVector temp_dot_product = get(lapse) * 0.0; |
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.
auto temp_dot_product = make_with_value<DataVector>(lapse, 0.0);
f315183
to
78bb9f6
Compare
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.
Other changes look good. Squash, including this last request.
|
||
// d = 1,2,3 for tetrad components built from x,y,z | ||
for (size_t d = 1; d < 4; d++) { | ||
// Base vector for Gram-Shmidt | ||
for (size_t i = 0; i < 4; i++) { | ||
gsl::at(tetrad_vector, i) = (i == d ? 1.0 : 0.0); | ||
inv_jacobian->get(i, d) = make_with_value<DataVector>(lapse, 0.0); |
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.
Do set_number_of_grid_points(&inv_jacobian->get(i, d), lapse)
(from Utilities/SetNumberOfGridPoints.hpp
) and then = 0.0
(or the ?:
expression you had before). This avoids a DataVector allocation. Might need a make_not_null
.
78bb9f6
to
76e8d92
Compare
Squashed with last requested change. |
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.
Test failed in CI:
2024-02-29T23:23:33.9252167Z Unit.Evolution.Particles.MonteCarlo.InverseJacobianInertialToFluid
2024-02-29T23:23:33.9253216Z -------------------------------------------------------------------------------
2024-02-29T23:23:33.9255545Z ../../../../../../tests/Unit/Evolution/Particles/MonteCarlo/Test_InverseJacobianInertialToFluid.cpp:22
2024-02-29T23:23:33.9256689Z ...............................................................................
2024-02-29T23:23:33.9257210Z
2024-02-29T23:23:33.9257566Z ../../../../../../tests/Unit/Framework/TestingFramework.hpp:116: FAILED:
2024-02-29T23:23:33.9258285Z CHECK( a == appx(b) )
2024-02-29T23:23:33.9258704Z with expansion:
2024-02-29T23:23:33.9259514Z -0.00000000000212888 == Approx( 0.0 )
2024-02-29T23:23:33.9260039Z with messages:
2024-02-29T23:23:33.9260650Z Seed is: 2708572239 from ../../../../../../tests/Unit/Evolution/Particles/
2024-02-29T23:23:33.9261452Z MonteCarlo/Test_InverseJacobianInertialToFluid.cpp:26
2024-02-29T23:23:33.9262207Z ../../../../../../tests/Unit/Evolution/Particles/MonteCarlo/
2024-02-29T23:23:33.9263027Z Test_InverseJacobianInertialToFluid.cpp:88: dot_product ==
2024-02-29T23:23:33.9263727Z expected_dot_product
2024-02-29T23:23:33.9264480Z a := (-1.55761e-14,3.35154e-17,1.85832e-16,-1.83013e-16,-2.12888e-12)
2024-02-29T23:23:33.9265165Z b := (0,0,0,0,0)
2024-02-29T23:23:33.9265402Z
2024-02-29T23:23:33.9265916Z 0.001 s: Unit.Evolution.Particles.MonteCarlo.InverseJacobianInertialToFluid
2024-02-29T23:23:33.9266854Z ===============================================================================
2024-02-29T23:23:33.9267485Z test cases: 1 | 0 passed | 1 failed
2024-02-29T23:23:33.9268385Z assertions: 127 | 126 passed | 1 failed
Is there a way to force the use of that seed in the test locally? |
That line should have a |
76e8d92
to
e8242e3
Compare
I changed the epsilon from 1e-12 to 5e-12. |
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.
OK, sounds good.
Proposed changes
Implement a ComputeTag that calculates the inverse jacobian of the map between the inertial frame and an orthonormal tetrad comoving with the fluid.
Upgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments
I needed to add a new frame (Frame::Fluid) -- should it be in the same file as the other frames, or defined separately in the MC code?