Skip to content

Commit

Permalink
Combine time and spatial derivative in spacetime_deriv_of_goth_g into…
Browse files Browse the repository at this point in the history
… a spacetime derivative in function input.
  • Loading branch information
ncorsobh committed Dec 15, 2023
1 parent 633a609 commit 4a7b828
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,11 @@ void spacetime_deriv_of_goth_g(
const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
const tnsr::abb<DataType, SpatialDim, Frame>& da_spacetime_metric,
const Scalar<DataType>& lapse,
const Scalar<DataType>& dt_lapse,
const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
const tnsr::a<DataType, SpatialDim, Frame>& da_lapse,
const Scalar<DataType>& sqrt_det_spatial_metric,
const tnsr::a<DataType, SpatialDim, Frame>& da_det_spatial_metric) {
set_number_of_grid_points(da_goth_g, da_spacetime_metric);

tnsr::a<DataType, SpatialDim, Frame> da_lapse{};
if constexpr (std::is_same_v<DataType, DataVector>) {
make_const_view(make_not_null(&std::as_const(da_lapse.get(0))),
get(dt_lapse), 0, get(dt_lapse).size());
for (size_t i = 0; i < SpatialDim; ++i) {
make_const_view(make_not_null(&std::as_const(da_lapse.get(i + 1))),
deriv_lapse.get(i), 0, deriv_lapse.get(0).size());
}
}
else {
da_lapse.get(0) = get(dt_lapse);
for (size_t i = 0; i < SpatialDim; ++i) {
da_lapse.get(i + 1) = deriv_lapse.get(i);
}
}

tenex::evaluate<ti::a, ti::B, ti::C>(da_goth_g,
(da_lapse(ti::a) * sqrt_det_spatial_metric()
+ 0.5 * lapse() * da_det_spatial_metric(ti::a)
Expand All @@ -57,14 +40,13 @@ tnsr::aBB<DataType, SpatialDim, Frame> spacetime_deriv_of_goth_g(
const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
const tnsr::abb<DataType, SpatialDim, Frame>& da_spacetime_metric,
const Scalar<DataType>& lapse,
const Scalar<DataType>& dt_lapse,
const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
const tnsr::a<DataType, SpatialDim, Frame>& da_lapse,
const Scalar<DataType>& sqrt_det_spatial_metric,
const tnsr::a<DataType, SpatialDim, Frame>& da_det_spatial_metric) {
tnsr::aBB<DataType, SpatialDim, Frame> da_goth_g{};
gr::spacetime_deriv_of_goth_g(make_not_null(&da_goth_g),
inverse_spacetime_metric, da_spacetime_metric, lapse, dt_lapse,
deriv_lapse, sqrt_det_spatial_metric, da_det_spatial_metric);
inverse_spacetime_metric, da_spacetime_metric, lapse, da_lapse,
sqrt_det_spatial_metric, da_det_spatial_metric);
return da_goth_g;
}
} // namespace gr
Expand All @@ -82,8 +64,7 @@ tnsr::aBB<DataType, SpatialDim, Frame> spacetime_deriv_of_goth_g(
const tnsr::abb<DTYPE(data), DIM(data), FRAME(data)>& \
da_spacetime_metric, \
const Scalar<DTYPE(data)>& lapse, \
const Scalar<DTYPE(data)>& dt_lapse, \
const tnsr::i<DTYPE(data), DIM(data), FRAME(data)>& deriv_lapse, \
const tnsr::a<DTYPE(data), DIM(data), FRAME(data)>& da_lapse, \
const Scalar<DTYPE(data)>& sqrt_det_spatial_metric, \
const tnsr::a<DTYPE(data), DIM(data), FRAME(data)>& \
da_det_spatial_metric); \
Expand All @@ -94,8 +75,7 @@ tnsr::aBB<DataType, SpatialDim, Frame> spacetime_deriv_of_goth_g(
const tnsr::abb<DTYPE(data), DIM(data), FRAME(data)>& \
da_spacetime_metric, \
const Scalar<DTYPE(data)>& lapse, \
const Scalar<DTYPE(data)>& dt_lapse, \
const tnsr::i<DTYPE(data), DIM(data), FRAME(data)>& deriv_lapse, \
const tnsr::a<DTYPE(data), DIM(data), FRAME(data)>& da_lapse, \
const Scalar<DTYPE(data)>& sqrt_det_spatial_metric, \
const tnsr::a<DTYPE(data), DIM(data), FRAME(data)>& \
da_det_spatial_metric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ void spacetime_deriv_of_goth_g(
const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
const tnsr::abb<DataType, SpatialDim, Frame>& da_spacetime_metric,
const Scalar<DataType>& lapse,
const Scalar<DataType>& dt_lapse,
const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
const tnsr::a<DataType, SpatialDim, Frame>& da_lapse,
const Scalar<DataType>& sqrt_det_spatial_metric,
const tnsr::a<DataType, SpatialDim, Frame>& da_det_spatial_metric);

Expand All @@ -45,8 +44,7 @@ tnsr::aBB<DataType, SpatialDim, Frame> spacetime_deriv_of_goth_g(
const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
const tnsr::abb<DataType, SpatialDim, Frame>& da_spacetime_metric,
const Scalar<DataType>& lapse,
const Scalar<DataType>& dt_lapse,
const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
const tnsr::a<DataType, SpatialDim, Frame>& da_lapse,
const Scalar<DataType>& sqrt_det_spatial_metric,
const tnsr::a<DataType, SpatialDim, Frame>& da_det_spatial_metric);
/// @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ def spacetime_deriv_of_goth_g(
inverse_spacetime_metric,
da_spacetime_metric,
lapse,
dt_lapse,
deriv_lapse,
da_lapse,
sqrt_det_spatial_metric,
da_det_spatial_metric,
):
da_lapse = np.array([dt_lapse])
for d_lapse in deriv_lapse:
da_lapse = np.append(da_lapse, d_lapse)
return np.tensordot(
da_lapse * sqrt_det_spatial_metric
+ 0.5 * lapse * da_det_spatial_metric / sqrt_det_spatial_metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ void test_compute_spacetime_deriv_of_goth_g(const DataType& used_for_size) {
const tnsr::AA<DataType, SpatialDim, Frame::Inertial>&,
const tnsr::abb<DataType, SpatialDim, Frame::Inertial>&,
const Scalar<DataType>&,
const Scalar<DataType>&,
const tnsr::i<DataType, SpatialDim, Frame::Inertial>&,
const tnsr::a<DataType, SpatialDim, Frame::Inertial>&,
const Scalar<DataType>&,
const tnsr::a<DataType, SpatialDim, Frame::Inertial>&)>(
&spacetime_deriv_of_goth_g<DataType, SpatialDim, Frame::Inertial>),
Expand Down

0 comments on commit 4a7b828

Please sign in to comment.