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

Add IrrotationalBNS Pointwise Functions #5880

Merged

Conversation

isaaclegred
Copy link
Contributor

@isaaclegred isaaclegred commented Mar 21, 2024

Proposed changes

This PR adds the point wise functions necessary to compute the needed quantities for use in solving Irrotational BNS initial data (which will be added in a future pull request)

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

Comment on lines 6 to 7
#include <cmath>
#include <cstddef>

#include "DataStructures/DataVector.hpp"
#include "DataStructures/Tensor/Tensor.hpp"
#include "PointwiseFunctions/GeneralRelativity/Lapse.hpp"
#include "PointwiseFunctions/GeneralRelativity/Shift.hpp"

#include "Utilities/Gsl.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

#include "DataStructures/Tensor/TypeAliases.hpp"
#include "Utilities/Gsl.hpp"

I don't think you need anything else.

Comment on lines 12 to 13
#include "PointwiseFunctions/GeneralRelativity/Lapse.hpp"
#include "PointwiseFunctions/GeneralRelativity/Shift.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Remove these two.

namespace hydro::initial_data {

template <typename DataType>
void rotational_shift(
Copy link
Member

Choose a reason for hiding this comment

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

These all need documentation.

Probably also worth adding an irrotational_bns namespace or something similar.

const Scalar<DataType>& local_angular_velocity_around_z,
const Scalar<DataType>& sqrt_det_spatial_metric) {
// Cross product involves volume element in arbitrary coordinates
result->get(0) = -get(sqrt_det_spatial_metric) * get<1>(x) *
Copy link
Member

Choose a reason for hiding this comment

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

get<0>(*result) and again below.

get(local_angular_velocity_around_z);
result->get(1) = get(sqrt_det_spatial_metric) * get<0>(x) *
get(local_angular_velocity_around_z);
result->get(2) = make_with_value<DataType>(sqrt_det_spatial_metric, 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

For this function, use set_number_of_grid_points(result, sqrt_det_spatial_metric) (from Utilities/SetNumberOfGridPoints.hpp) at the start of the function and just assign a plain 0.0 to this component. Using make_with_value does an extra memory allocation and could break things if result was part of a Variables (and was therefore non-owning). For most of the other functions the tenex code will handle the resizing.

const tnsr::I<DataType, 3>& x,
const Scalar<DataType>& /*local_angular_velocity_around_z*/,
const Scalar<DataType>& /*sqrt_det_spatial_metric*/) {
*result = make_with_value<tnsr::iJ<DataType, 3>>(get<0>(x), 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

Again, set_number_of_grid_points(result, x) and then = 0.0.

@@ -0,0 +1,28 @@
# Distributed under the MIT License.
# See LICENSE.txt for details.
set(LIBRARY "Test_HydroInitialData")
Copy link
Member

Choose a reason for hiding this comment

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

Fix the formatting in this file.

) / lapse - np.outer(deriv_of_lapse / lapse**2, rotational_shift)


def divergence_rotational_shift_stress(
Copy link
Member

Choose a reason for hiding this comment

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

The c++ part of the test for this function is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that function was removed because it became unnecessary, I'll remove it from the python functions, and from the IrrotationalBns.cpp file

Comment on lines 16 to 27
CoordinateMaps
DataStructures
DataStructuresHelpers
Domain
GeneralRelativity
GeneralRelativityHelpers
Hydro
HydroHelpers
LinearOperators
Spectral
IO
Utilities
Copy link
Member

Choose a reason for hiding this comment

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

Fix this list.

Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

Not compiling.

@@ -172,7 +142,8 @@ void derivative_spatial_rotational_killing_vector(
const tnsr::I<DataType, 3>& x,
const Scalar<DataType>& /*local_angular_velocity_around_z*/,
const Scalar<DataType>& /*sqrt_det_spatial_metric*/) {
*result = make_with_value<tnsr::iJ<DataType, 3>>(get<0>(x), 0.0);
set_number_of_grid_points(result, x);
tenex::update<ti::i, ti::J>(result, 0.0 * (*result)(ti::i, ti::J));
Copy link
Member

Choose a reason for hiding this comment

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

The values in result may be uninintialized or NaN, so you can't multiply by them. I don't know if we have a standard way to zero a Tensor, but std::fill(result->begin(), result->end(), 0.0) should work.

/*!
* \ingroup HydroInitialDataGroup
* \brief Items related to solving for irrotational bns initial data
* See e.g. Baumgarte and Shapiro, Ch. 15 (P. 523)
Copy link
Member

Choose a reason for hiding this comment

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

\cite BaumgarteShapiro (It's already in our references file.)

template <typename DataType>
void rotational_shift(
gsl::not_null<tnsr::I<DataType, 3>*> result,
const tnsr::I<DataType, 3>& shift,
const tnsr::I<DataType, 3>& spatial_rotational_killing_vector);
/// @}
Copy link
Member

Choose a reason for hiding this comment

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

Move after the second overload.

/// h^2 \rho^2 = \frac{1}{\alpha^2} \left(C + B^i D_i \Phi\right)^2 - D_i
/// \Phi D^i \Phi
/// \f]
/// Where \f$\Phi \f$ is the velocity potential, andC is the Euler-constant,
Copy link
Member

Choose a reason for hiding this comment

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

Typo "andC" -> "and \f$C\f$"

///
/// The eqn. is identical to B&S 15.76
/// \f[
/// h^2 \rho^2 = \frac{1}{\alpha^2} \left(C + B^i D_i \Phi\right)^2 - D_i
Copy link
Member

Choose a reason for hiding this comment

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

Something is confusing doxygen around here, but I don't know exactly what. You might need to switch to /*! */ comments for multiline math.

/// @{
/// \brief The spatial derivative of the spatial rotational killing vector
///
/// As above, assumes uniform rotation around the z-axis
Copy link
Member

Choose a reason for hiding this comment

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

Doxygen doesn't do a great job of preserving organization, so "As above" ends up being confusing in the rendered documentation. Give the name of the specific thing you are trying to refer to. (I think "spatial_rotational_killing_vector".)

@@ -0,0 +1,28 @@
# Distributed under the MIT License.
# See LICENSE.txt for details.
set(LIBRARY "Test_HydroInitialData")
Copy link
Member

Choose a reason for hiding this comment

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

Add blank line above.

Copy link
Member

Choose a reason for hiding this comment

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

I think this was done before, but it seems to have gotten lost.


set(LIBRARY_SOURCES
Test_IrrotationalBns.cpp
)
Copy link
Member

Choose a reason for hiding this comment

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

Indent two spaces.

add_test_library(${LIBRARY} "${LIBRARY_SOURCES}")



Copy link
Member

Choose a reason for hiding this comment

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

Remove extra blank lines.

Comment on lines 16 to 27
CoordinateMaps
DataStructures
DataStructuresHelpers
Domain
GeneralRelativity
GeneralRelativityHelpers
Hydro
HydroHelpers
IO
LinearOperators
Spectral
Utilities
Copy link
Member

Choose a reason for hiding this comment

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

All you use is

  DataStructures
  Hydro

@wthrowe
Copy link
Member

wthrowe commented Apr 15, 2024

Looks good. Squash.

@isaaclegred
Copy link
Contributor Author

@nilsvu if you'd like to take a look at this!

wthrowe
wthrowe previously approved these changes Apr 16, 2024
@wthrowe wthrowe requested a review from nilsvu April 18, 2024 19:14
@isaaclegred
Copy link
Contributor Author

@nilsvu this is ready to be looked at again when you get a chance!

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

You can squash everything

nilsvu
nilsvu previously approved these changes May 2, 2024
@isaaclegred
Copy link
Contributor Author

@wthrowe if you'd like to take a look at this again, otherwise I think it's ready to merge

/// @{
/// \brief Compute the spatial rotational killing vector associated with uniform
/// rotation around the z-axis.
/// Taking \f$\Omega_j\f$ to be the uniform rotation axis (assumed in the
Copy link
Member

Choose a reason for hiding this comment

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

Empty comment line after the "brief" part.

@@ -0,0 +1,28 @@
# Distributed under the MIT License.
# See LICENSE.txt for details.
set(LIBRARY "Test_HydroInitialData")
Copy link
Member

Choose a reason for hiding this comment

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

I think this was done before, but it seems to have gotten lost.

@isaaclegred
Copy link
Contributor Author

@wthrowe shall I squash?

@wthrowe
Copy link
Member

wthrowe commented May 6, 2024

Yes, looks good.

@isaaclegred
Copy link
Contributor Author

@wthrowe @nilsvu should be ready to go

@nilsvu nilsvu merged commit ebc0098 into sxs-collaboration:develop May 8, 2024
22 checks passed
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.

3 participants