Skip to content

Commit 7cf2402

Browse files
committed
Christoffel contraction
1 parent d150ff0 commit 7cf2402

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
3+
#include "../Metric.hpp"
4+
#include "BSSNDerivatives.hpp"
5+
6+
namespace tensorium_RG {
7+
8+
template<typename T>
9+
class BSSNContractedGamma {
10+
public:
11+
/**
12+
* @brief Compute the contracted Christoffel symbol \f$ \Gamma^i_{ij} = -\frac{3}{2} \partial_j \ln \chi \f$
13+
*
14+
* This uses the relation:
15+
* \f[
16+
* \Gamma^i_{ij} = -\frac{3}{2} \frac{\partial_j \chi}{\chi}
17+
* \f]
18+
*
19+
* @param X Spatial coordinates
20+
* @param metric Metric object implementing `BSSN(X, alpha, beta, gamma)`
21+
* @param dx,dy,dz Grid spacing
22+
* @param chi Conformal factor \f$ \chi \f$
23+
* @return Vector containing \f$ \Gamma^i_{ij} \f$ for each j
24+
*/
25+
static tensorium::Vector<T> compute(
26+
const tensorium::Vector<T>& X,
27+
const tensorium_RG::Metric<T>& metric,
28+
T dx, T dy, T dz,
29+
T chi)
30+
{
31+
tensorium::Vector<T> d_chi(3);
32+
33+
tensorium_RG::compute_partial_derivatives_scalar<T>(
34+
X, dx, dy, dz,
35+
[&](const tensorium::Vector<T>& Xs) {
36+
T a_tmp;
37+
tensorium::Vector<T> b_tmp(3);
38+
tensorium::Tensor<T, 2> g_tmp({3, 3});
39+
metric.BSSN(Xs, a_tmp, b_tmp, g_tmp);
40+
return compute_conformal_factor(metric, g_tmp);
41+
},
42+
d_chi
43+
);
44+
45+
tensorium::Vector<T> out(3);
46+
for (size_t j = 0; j < 3; ++j)
47+
out[j] = -1.5 * d_chi[j] / chi;
48+
49+
return out;
50+
}
51+
};
52+
53+
} // namespace tensorium_RG

includes/Tensorium/DiffGeometry/BSSN/BSSNDerivatives.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,41 @@ namespace tensorium_RG {
8686
}
8787
}
8888

89+
template<typename T, typename ScalarFunc>
90+
void compute_partial_derivatives_scalar(
91+
const tensorium::Vector<T>& X,
92+
T dx, T dy, T dz,
93+
ScalarFunc&& func,
94+
tensorium::Vector<T>& out) {
95+
96+
out.resize(3);
97+
98+
auto shifted = [&](T dx_, T dy_, T dz_) {
99+
tensorium::Vector<T> Xs = X;
100+
Xs(0) += dx_; Xs(1) += dy_; Xs(2) += dz_;
101+
return func(Xs);
102+
};
103+
104+
// ∂/∂x
105+
T gm2 = shifted(-2 * dx, 0, 0);
106+
T gm1 = shifted(-dx, 0, 0);
107+
T gp1 = shifted(dx, 0, 0);
108+
T gp2 = shifted(2 * dx, 0, 0);
109+
out[0] = (-gp2 + 8 * gp1 - 8 * gm1 + gm2) / (12 * dx);
110+
111+
// ∂/∂y
112+
gm2 = shifted(0, -2 * dy, 0);
113+
gm1 = shifted(0, -dy, 0);
114+
gp1 = shifted(0, dy, 0);
115+
gp2 = shifted(0, 2 * dy, 0);
116+
out[1] = (-gp2 + 8 * gp1 - 8 * gm1 + gm2) / (12 * dy);
117+
118+
// ∂/∂z
119+
gm2 = shifted(0, 0, -2 * dz);
120+
gm1 = shifted(0, 0, -dz);
121+
gp1 = shifted(0, 0, dz);
122+
gp2 = shifted(0, 0, 2 * dz);
123+
out[2] = (-gp2 + 8 * gp1 - 8 * gm1 + gm2) / (12 * dz);
124+
}
89125
}
90126

includes/Tensorium/DiffGeometry/BSSN/BSSNSetup.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "BSSNDerivatives.hpp"
1818
#include "BSSNextrinTensor.hpp"
1919
#include "BSSNAtildeTensor.hpp"
20+
#include "BSSNTildeChristoffel.hpp"
21+
#include "BSSNContractedChristoffel.hpp"
2022

2123
namespace tensorium_RG {
2224
/**
@@ -47,6 +49,8 @@ namespace tensorium_RG {
4749
std::vector<tensorium::Tensor<double, 3>> christoffel_tilde; ///< Christoffel symbols \f$\tilde{\Gamma}^k_{ij}\f$
4850
std::vector<tensorium::Tensor<double, 2>> ExtrinsicTensor; ///< Extrinsic curvature \f$K_{ij}\f$
4951
std::vector<tensorium::Tensor<double, 2>> A_tildeTensor; ///< Trace-free extrinsic curvature \f$\tilde{A}_{ij}\f$
52+
std::vector<tensorium::Vector<double>> tilde_Gamma; ///< Conformal contracted symbols \f$\tilde{\Gamma}^i\f$
53+
std::vector<tensorium::Vector<double>> contracted_Gamma; ///< Contracted symbols \f$\Gamma^i_{ij} = -\frac{3}{2} \partial_j \ln \chi\f$
5054
};
5155
/**
5256
* @class BSSN
@@ -112,8 +116,12 @@ namespace tensorium_RG {
112116
},
113117
dgamma_tilde
114118
);
115-
119+
116120
compute_christoffel_3D(gamma_tilde, dgamma_tilde, gamma_tilde_inv, christoffel);
121+
auto contracted_Gamma = tensorium_RG::BSSNContractedGamma<T>::compute(X, metric, dx, dy, dz, chi);
122+
123+
tensorium::Vector<T> tilde_Gamma(3);
124+
TildeGamma<T>::compute(gamma_tilde_inv, christoffel, tilde_Gamma);
117125

118126
tensorium_RG::compute_partial_derivatives_vector<T>(
119127
X, dx, dy, dz,
@@ -137,7 +145,10 @@ namespace tensorium_RG {
137145

138146
auto Kij = extr.compute_Kij(dgt, gammaj, beta, partial_beta, christoffel, alpha);
139147
auto AtildeTensor = Aij.compute_Atilde_tensor(Kij, gammaj_inv, gammaj, chi);
148+
140149

150+
grid.tilde_Gamma = {tilde_Gamma};
151+
grid.contracted_Gamma = {contracted_Gamma};
141152
grid.ExtrinsicTensor = {Kij};
142153
grid.A_tildeTensor = {AtildeTensor};
143154
grid.alpha = {alpha};

0 commit comments

Comments
 (0)