Skip to content

Commit

Permalink
Merge pull request #5918 from nilsvu/xcts_christoffel
Browse files Browse the repository at this point in the history
XCTS: output spatial Christoffels
  • Loading branch information
knelli2 authored Apr 23, 2024
2 parents 7bf9ea3 + 665ec43 commit 9b01d30
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Elliptic/Executables/Xcts/SolveXcts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct Metavariables {
gr::Tags::HamiltonianConstraint<DataVector>,
gr::Tags::MomentumConstraint<DataVector, 3>,
gr::Tags::SpatialMetric<DataVector, 3>,
gr::Tags::InverseSpatialMetric<DataVector, 3>,
gr::Tags::SpatialChristoffelSecondKind<DataVector, 3>,
gr::Tags::Lapse<DataVector>, gr::Tags::Shift<DataVector, 3>,
gr::Tags::ExtrinsicCurvature<DataVector, 3>>>;
using hydro_quantities_compute = Xcts::Tags::HydroQuantitiesCompute<
Expand Down
33 changes: 33 additions & 0 deletions src/PointwiseFunctions/Xcts/SpacetimeQuantities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,39 @@ void SpacetimeQuantitiesComputer::operator()(
inv_jacobian);
}

void SpacetimeQuantitiesComputer::operator()(
const gsl::not_null<tnsr::Ijj<DataVector, 3>*>
spatial_christoffel_second_kind,
const gsl::not_null<Cache*> cache,
gr::Tags::SpatialChristoffelSecondKind<DataVector, 3> /*meta*/) const {
// Eq. (3.7) in Baumgarte/Shapiro
const auto& conformal_factor =
cache->get_var(*this, Tags::ConformalFactor<DataVector>{});
const auto& deriv_conformal_factor =
cache->get_var(*this, ::Tags::deriv<Tags::ConformalFactor<DataVector>,
tmpl::size_t<3>, Frame::Inertial>{});
*spatial_christoffel_second_kind = conformal_christoffel_second_kind;
for (size_t i = 0; i < 3; ++i) {
for (size_t j = 0; j < 3; ++j) {
for (size_t k = 0; k <= j; ++k) {
if (i == j) {
spatial_christoffel_second_kind->get(i, j, k) +=
2. * deriv_conformal_factor.get(k) / get(conformal_factor);
}
if (i == k) {
spatial_christoffel_second_kind->get(i, j, k) +=
2. * deriv_conformal_factor.get(j) / get(conformal_factor);
}
for (size_t l = 0; l < 3; ++l) {
spatial_christoffel_second_kind->get(i, j, k) -=
2. * conformal_metric.get(j, k) * inv_conformal_metric.get(i, l) *
deriv_conformal_factor.get(l) / get(conformal_factor);
}
}
}
}
}

void SpacetimeQuantitiesComputer::operator()(
const gsl::not_null<Scalar<DataVector>*>
conformal_laplacian_of_conformal_factor,
Expand Down
5 changes: 5 additions & 0 deletions src/PointwiseFunctions/Xcts/SpacetimeQuantities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ using SpacetimeQuantities = CachedTempBuffer<
gr::Tags::SpatialMetric<DataVector, 3>,
gr::Tags::InverseSpatialMetric<DataVector, 3>, gr::Tags::Lapse<DataVector>,
gr::Tags::Shift<DataVector, 3>, gr::Tags::ExtrinsicCurvature<DataVector, 3>,
gr::Tags::SpatialChristoffelSecondKind<DataVector, 3>,
// Constraints
gr::Tags::HamiltonianConstraint<DataVector>,
gr::Tags::MomentumConstraint<DataVector, 3>>;
Expand Down Expand Up @@ -80,6 +81,10 @@ struct SpacetimeQuantitiesComputer {
gsl::not_null<Cache*> cache,
::Tags::deriv<Tags::ConformalFactor<DataVector>, tmpl::size_t<3>,
Frame::Inertial> /*meta*/) const;
void operator()(
gsl::not_null<tnsr::Ijj<DataVector, 3>*> spatial_christoffel_second_kind,
gsl::not_null<Cache*> cache,
gr::Tags::SpatialChristoffelSecondKind<DataVector, 3> /*meta*/) const;
void operator()(
gsl::not_null<Scalar<DataVector>*>
conformal_laplacian_of_conformal_factor,
Expand Down
2 changes: 2 additions & 0 deletions support/Pipelines/Bbh/InitialData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ EventsAndTriggers:
- Shift
- ShiftExcess
- SpatialMetric
- InverseSpatialMetric
- SpatialChristoffelSecondKind
- ExtrinsicCurvature
- RadiallyCompressedCoordinates
InterpolateToMesh: None
Expand Down
23 changes: 23 additions & 0 deletions tests/Unit/PointwiseFunctions/Xcts/SpacetimeQuantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ def inv_spatial_metric(conformal_factor, inv_conformal_metric):
return conformal_factor ** (-4) * inv_conformal_metric


def spatial_christoffel_second_kind(
conformal_factor,
deriv_conformal_factor,
conformal_metric,
inv_conformal_metric,
conformal_christoffel_second_kind,
):
# Eq. (3.7) in Baumgarte/Shapiro
krond = np.eye(3)
return conformal_christoffel_second_kind + 2.0 * (
np.einsum("ij,k->ijk", krond, deriv_conformal_factor / conformal_factor)
+ np.einsum(
"ik,j->ijk", krond, deriv_conformal_factor / conformal_factor
)
- np.einsum(
"jk,il,l->ijk",
conformal_metric,
inv_conformal_metric,
deriv_conformal_factor / conformal_factor,
)
)


def lapse(conformal_factor, lapse_times_conformal_factor):
return lapse_times_conformal_factor / conformal_factor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.Xcts.SpacetimeQuantities",
check_with_python(get<gr::Tags::InverseSpatialMetric<DataVector, 3>>(vars),
"inv_spatial_metric", conformal_factor,
inv_conformal_metric);
check_with_python(
get<gr::Tags::SpatialChristoffelSecondKind<DataVector, 3>>(vars),
"spatial_christoffel_second_kind", conformal_factor,
get<::Tags::deriv<Tags::ConformalFactor<DataVector>, tmpl::size_t<3>,
Frame::Inertial>>(vars),
conformal_metric, inv_conformal_metric,
conformal_christoffel_second_kind);
check_with_python(get<gr::Tags::Lapse<DataVector>>(vars), "lapse",
conformal_factor, lapse_times_conformal_factor);
check_with_python(get<gr::Tags::Shift<DataVector, 3>>(vars), "shift",
Expand Down

0 comments on commit 9b01d30

Please sign in to comment.