-
Notifications
You must be signed in to change notification settings - Fork 192
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 StressEnergyTensor free function #6457
base: develop
Are you sure you want to change the base?
Conversation
Can you please put in a comment about the purpose of this PR? What's new? Thanks. |
const auto rho_h_star = | ||
(get(rest_mass_density) + | ||
get(rest_mass_density) * get(specific_internal_energy)) + | ||
get(pressure) + square(get(comoving_magnetic_field_magnitude)); | ||
|
||
const auto p_star = | ||
get(pressure) + square(get(comoving_magnetic_field_magnitude)) / 2.; |
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 don't want auto here because this creates an expression tree that gets evaluated many times in the loop below. Specify the type
void comoving_magnetic_field( | ||
gsl::not_null<tnsr::A<DataType, 3>*> result, | ||
const tnsr::I<DataType, 3>& spatial_velocity, | ||
const tnsr::I<DataType, 3>& magnetic_field, | ||
const Scalar<DataType>& magnetic_field_dot_spatial_velocity, | ||
const Scalar<DataType>& lorentz_factor, const tnsr::I<DataType, 3>& shift, | ||
const Scalar<DataType>& lapse); | ||
|
||
template <typename DataType> | ||
tnsr::A<DataType, 3> comoving_magnetic_field( | ||
const tnsr::I<DataType, 3>& spatial_velocity, | ||
const tnsr::I<DataType, 3>& magnetic_field, | ||
const Scalar<DataType>& magnetic_field_dot_spatial_velocity, | ||
const Scalar<DataType>& lorentz_factor, const tnsr::I<DataType, 3>& shift, | ||
const Scalar<DataType>& lapse); | ||
|
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.
Factor this function into its own commit and add a test
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.
done.
@@ -70,23 +99,78 @@ void stress_trace(gsl::not_null<Scalar<DataType>*> result, | |||
(square(get(lorentz_factor)) * get(spatial_velocity_squared) + 1.); | |||
} | |||
|
|||
template <typename DataType> | |||
void stress_energy_tensor( | |||
gsl::not_null<tnsr::AA<DataType, 3>*> result, |
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.
const
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.
done.
get(pressure) + square(get(comoving_magnetic_field_magnitude)); | ||
|
||
const auto p_star = | ||
get(pressure) + square(get(comoving_magnetic_field_magnitude)) / 2.; |
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.
don't divide by two, multiply by 0.5 on the left
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.
done.
const tnsr::I<DataType, 3>& magnetic_field, | ||
const tnsr::ii<DataType, 3>& spatial_metric, | ||
const tnsr::II<DataType, 3>& inverse_spatial_metric) { | ||
const auto inverse_spacetime_metric = |
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'm generally unhappy about the large number of allocations in this function. It would be good to switch to the not_null versions and preallocate in a Variables
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.
done.
4046b96
to
175779d
Compare
Proposed changes
Adding a function to evaluate the stress-energy tensor, which currently does not exist in StressEnergy.cpp
This will be mainly used for evaluating diagnostics for accretion disk simulations.
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