-
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 boost to KerrSchild #5610
Add boost to KerrSchild #5610
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
#include "PointwiseFunctions/SpecialRelativity/LorentzBoostMatrix.hpp" | ||
|
||
#include <array> | ||
#include <cmath> | ||
#include <cstddef> | ||
#include <limits> | ||
|
@@ -58,6 +59,75 @@ void lorentz_boost_matrix( | |
(*boost_matrix).get(i + 1, i + 1) += 1.0; | ||
} | ||
} | ||
|
||
template <size_t SpatialDim> | ||
tnsr::Ab<double, SpatialDim, Frame::NoFrame> lorentz_boost_matrix( | ||
const std::array<double, SpatialDim>& velocity) { | ||
tnsr::I<double, SpatialDim, Frame::NoFrame> velocity_as_tensor(velocity); | ||
return lorentz_boost_matrix(velocity_as_tensor); | ||
} | ||
|
||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost( | ||
const gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::I<DataType, SpatialDim, Frame>& vector, | ||
const double vector_component_0, | ||
const std::array<double, SpatialDim>& velocity) { | ||
if (velocity == make_array<SpatialDim>(0.)) { | ||
*result = vector; | ||
return; | ||
} | ||
// Inverse matrix with respect to the boost applied to one forms | ||
const auto boost_matrix = lorentz_boost_matrix(-velocity); | ||
for (size_t i = 0; i < SpatialDim; ++i) { | ||
result->get(i) = boost_matrix.get(i + 1, 0) * vector_component_0; | ||
for (size_t j = 0; j < SpatialDim; ++j) { | ||
result->get(i) += boost_matrix.get(i + 1, j + 1) * vector.get(j); | ||
} | ||
} | ||
} | ||
|
||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost( | ||
const gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::a<DataType, SpatialDim, Frame>& one_form, | ||
const std::array<double, SpatialDim>& velocity) { | ||
if (velocity == make_array<SpatialDim>(0.)) { | ||
*result = one_form; | ||
return; | ||
} | ||
const auto boost_matrix = lorentz_boost_matrix(velocity); | ||
for (size_t i = 0; i < SpatialDim + 1; ++i) { | ||
result->get(i) = 0.; | ||
for (size_t j = 0; j < SpatialDim + 1; ++j) { | ||
result->get(i) += boost_matrix.get(i, j) * one_form.get(j); | ||
} | ||
} | ||
} | ||
|
||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a sensible situation where different indices of a tensor would be boosted with different velocities? Is this generalization necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also inherited from the implementation in SpEC, maybe to save overloads when boosting tensors with mixed up/down indices. Then one just changes the sign of the velocity in the relevant entry. |
||
const gsl::not_null<tnsr::ab<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::ab<DataType, SpatialDim, Frame>& tensor, | ||
const std::array<double, SpatialDim>& velocity) { | ||
if (velocity == make_array<SpatialDim>(0.)) { | ||
*result = tensor; | ||
return; | ||
} | ||
const auto boost_matrix = lorentz_boost_matrix(velocity); | ||
for (size_t i = 0; i < SpatialDim + 1; ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [optional] |
||
for (size_t k = 0; k < SpatialDim + 1; ++k) { | ||
result->get(i, k) = 0.; | ||
for (size_t j = 0; j < SpatialDim + 1; ++j) { | ||
for (size_t l = 0; l < SpatialDim + 1; ++l) { | ||
result->get(i, k) += boost_matrix.get(i, j) * boost_matrix.get(k, l) * | ||
tensor.get(j, l); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace sr | ||
|
||
// Explicit Instantiations | ||
|
@@ -70,10 +140,40 @@ void lorentz_boost_matrix( | |
template void sr::lorentz_boost_matrix( \ | ||
gsl::not_null<tnsr::Ab<double, DIM(data), Frame::NoFrame>*> \ | ||
boost_matrix, \ | ||
const tnsr::I<double, DIM(data), Frame::NoFrame>& velocity); | ||
const tnsr::I<double, DIM(data), Frame::NoFrame>& velocity); \ | ||
template tnsr::Ab<double, DIM(data), Frame::NoFrame> \ | ||
sr::lorentz_boost_matrix(const std::array<double, DIM(data)>& velocity); | ||
|
||
GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3)) | ||
|
||
#undef DIM | ||
#undef INSTANTIATE | ||
|
||
#define DIM(data) BOOST_PP_TUPLE_ELEM(0, data) | ||
#define DTYPE(data) BOOST_PP_TUPLE_ELEM(1, data) | ||
#define FRAME(data) BOOST_PP_TUPLE_ELEM(2, data) | ||
|
||
#define INSTANTIATE(_, data) \ | ||
template void sr::lorentz_boost( \ | ||
const gsl::not_null<tnsr::I<DTYPE(data), DIM(data), FRAME(data)>*> \ | ||
result, \ | ||
const tnsr::I<DTYPE(data), DIM(data), FRAME(data)>& one_form, \ | ||
const double one_form_component_0, \ | ||
const std::array<double, DIM(data)>& velocity); \ | ||
template void sr::lorentz_boost( \ | ||
const gsl::not_null<tnsr::a<DTYPE(data), DIM(data), FRAME(data)>*> \ | ||
result, \ | ||
const tnsr::a<DTYPE(data), DIM(data), FRAME(data)>& one_form, \ | ||
const std::array<double, DIM(data)>& velocity); \ | ||
template void sr::lorentz_boost( \ | ||
const gsl::not_null<tnsr::ab<DTYPE(data), DIM(data), FRAME(data)>*> \ | ||
result, \ | ||
const tnsr::ab<DTYPE(data), DIM(data), FRAME(data)>& tensor, \ | ||
const std::array<double, DIM(data)>& velocity); | ||
|
||
GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3), (double, DataVector), | ||
(Frame::Grid, Frame::Distorted, Frame::Inertial)) | ||
|
||
#undef DIM | ||
#undef DTYPE | ||
#undef FRAME | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,12 @@ | |
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <cstddef> | ||
|
||
#include "DataStructures/Tensor/TypeAliases.hpp" | ||
#include "DataStructures/Tensor/Tensor.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
#include "Utilities/MakeArray.hpp" | ||
|
||
/// \cond | ||
namespace gsl { | ||
|
@@ -53,5 +56,43 @@ template <size_t SpatialDim> | |
void lorentz_boost_matrix( | ||
gsl::not_null<tnsr::Ab<double, SpatialDim, Frame::NoFrame>*> boost_matrix, | ||
const tnsr::I<double, SpatialDim, Frame::NoFrame>& velocity); | ||
|
||
template <size_t SpatialDim> | ||
tnsr::Ab<double, SpatialDim, Frame::NoFrame> lorentz_boost_matrix( | ||
const std::array<double, SpatialDim>& velocity); | ||
/// @} | ||
|
||
/// @{ | ||
/*! | ||
* \ingroup SpecialRelativityGroup | ||
* \brief Apply a Lorentz boost to the spatial part of a vector. | ||
* \details This requires passing the 0th component of the vector as an | ||
* additional argument. | ||
*/ | ||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost(gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::I<DataType, SpatialDim, Frame>& vector, | ||
double vector_component_0, | ||
const std::array<double, SpatialDim>& velocity); | ||
|
||
/*! | ||
* \brief Apply a Lorentz boost to a one form. | ||
*/ | ||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, there would be one implementation that works for a generic tensor type so do not have all of these overloads. If you think that would be overkill for now, maybe just add a comment that this can be done in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I wouldn't want to delay this anymore. Added comment. |
||
gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::a<DataType, SpatialDim, Frame>& one_form, | ||
const std::array<double, SpatialDim>& velocity); | ||
|
||
/*! | ||
* \brief Apply a Lorentz boost to each component of a rank-2 tensor with | ||
* lower or covariant indices. | ||
* \note In the future we might want to write a single function capable to boost | ||
* a tensor of arbitrary rank. | ||
*/ | ||
template <typename DataType, size_t SpatialDim, typename Frame> | ||
void lorentz_boost(gsl::not_null<tnsr::ab<DataType, SpatialDim, Frame>*> result, | ||
const tnsr::ab<DataType, SpatialDim, Frame>& tensor, | ||
const std::array<double, SpatialDim>& velocity); | ||
/// @} | ||
} // namespace sr |
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.
can you make this a symmetric tensor?
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.
Can I? This has one upper and one lower index
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 currently supported.