50 std::vector<tensorium::Vector<double>>
beta;
51 std::vector<tensorium::Tensor<double, 2>>
gamma_ij;
53 std::vector<double>
chi;
54 std::vector<tensorium::Tensor<double, 2>>
56 std::vector<tensorium::Tensor<double, 2>>
58 std::vector<tensorium::Tensor<double, 3>>
60 std::vector<tensorium::Tensor<double, 3>>
63 std::vector<tensorium::Tensor<double, 2>>
65 std::vector<tensorium::Vector<double>>
67 std::vector<tensorium::Vector<double>>
81template <
typename T>
class BSSN {
104 metric.
BSSN(Xs, a_tmp, b_tmp, g_tmp);
105 T chi_tmp = compute_conformal_factor(metric, g_tmp);
106 return compute_conformal_metric(metric, g_tmp, chi_tmp);
111 compute_christoffel_3D(gamma_tilde, dgamma_tilde, gamma_tilde_inv, christoffel_tilde);
116 auto contracted_Gamma =
125 metric.
BSSN(Xs, a_tmp, b_tmp, g_tmp);
136 metric.
BSSN(Xs, a_tmp, b_tmp, g_tmp);
142 compute_christoffel_3D(gamma_ij, dgamma_phys, gamma_ij_inv, christoffel_phys);
150 const size_t NX = 1, NY = 1, NZ = 1;
154 for (
size_t i = 0; i < NX; ++i) {
155 for (
size_t j = 0; j < NY; ++j) {
156 for (
size_t k = 0; k < NZ; ++k) {
157 for (
int a = 0; a < 3; ++a) {
158 for (
int b = 0; b < 3; ++b) {
159 Atilde_full(std::array<size_t, 5>{i, j, k, (size_t)a, (
size_t)b}) =
161 gtilde_inv_full(std::array<size_t, 5>{i, j, k, (size_t)a, (
size_t)b}) =
162 gamma_tilde_inv(a, b);
172 T psi_000 = std::fmax(psi_full(std::array<size_t, 3>{0, 0, 0}), T(1e-8));
173 T new_chi = T(1) / std::pow(psi_000, T(4));
178 chi_ctx, gamma_tilde_inv, tilde_Gamma, christoffel_tilde, gamma_tilde);
182 chi_ctx, gamma_tilde, gamma_tilde_inv, christoffel_tilde);
185 tilde_Gamma, christoffel_tilde);
201 std::cout << std::setprecision(6) << std::fixed;
202 std::cout <<
"\n========= BSSN Quantities at X =========\n";
204 std::cout <<
"--- alpha ---\n" <<
grid.
alpha[0] <<
"\n";
207 std::cout <<
"dbeta\n";
227 std::cout <<
"--- chi ---\n" <<
grid.
chi[0] <<
"\n";
233 std::cout <<
"========================================\n\n";
Computes the conformal part of the Ricci tensor in the BSSN formalism.
static FrontendPluginRegistry::Add< TensoriumPluginAction > X("tensorium-dispatch", "Handle #pragma tensorium directives")
Register the plugin under the name "tensorium-dispatch".
Multi-dimensional tensor class with fixed rank and SIMD support.
Definition Tensor.hpp:25
Computes the trace-free conformal extrinsic curvature tensor in the BSSN formalism.
Definition BSSNAtildeTensor.hpp:26
tensorium::Tensor< K, 2 > compute_Atilde_tensor(const tensorium::Tensor< K, 2 > &Kij, const tensorium::Tensor< K, 2 > &gamma_inv, const tensorium::Tensor< K, 2 > &gamma, K chi)
Computes from , , and .
Definition BSSNAtildeTensor.hpp:45
static tensorium::Vector< T > compute(const tensorium::Vector< T > &X, const tensorium_RG::Metric< T > &metric, T dx, T dy, T dz, T chi)
Compute the contracted Christoffel symbol .
Definition BSSNContractedChristoffel.hpp:25
Driver class to initialize and store BSSN variables from an input spacetime metric.
Definition BSSNSetup.hpp:81
BSSNGrid grid
Definition BSSNSetup.hpp:83
void init_BSSN(const tensorium::Vector< T > &X, const tensorium_RG::Metric< T > &metric, T dx, T dy, T dz)
Definition BSSNSetup.hpp:85
static tensorium::Tensor< T, 3 > solveLichnerowicz(const tensorium::Tensor< T, 5 > Ã, const tensorium::Tensor< T, 5 > &g_tilde_inv, T dx, T dy, T dz, int max_iter=1000, T tol=T(1e-8))
Solve the Lichnerowicz equation to enforce the Hamiltonian constraint in BSSN.
Definition BSSNConstraintsSolver.hpp:24
Computes the extrinsic curvature tensor from BSSN variables.
Definition BSSNextrinTensor.hpp:46
tensorium::Tensor< T, 2 > compute_Kij(const tensorium::Tensor< T, 2 > &dgt, const tensorium::Tensor< T, 2 > &gamma, const tensorium::Vector< T > &beta, const tensorium::Tensor< T, 2 > &partial_beta, const tensorium::Tensor< T, 3 > &christoffel, const T alpha)
Computes the extrinsic curvature tensor .
Definition BSSNextrinTensor.hpp:73
A callable 4D metric class for general relativity (Minkowski, Schwarzschild, Kerr,...
Definition Metric.hpp:27
T compute_conformal_factor(const tensorium::Tensor< T, 2 > &gamma) const
Definition Metric.hpp:101
void BSSN(const tensorium::Vector< T > &X, T &alpha, tensorium::Vector< T > &beta, tensorium::Tensor< T, 2 > &gamma) const
Extract BSSN 3+1 variables (lapse, shift, and spatial metric)
Definition Metric.hpp:83
static tensorium::Tensor< T, 2 > compute_Ricci_total(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Vector< T > &tilde_Gamma, const tensorium::Tensor< T, 3 > &christoffel_tilde)
Compute the full Ricci tensor as the sum of and .
Definition BSSNRicciComplete.hpp:69
static tensorium::Tensor< T, 2 > compute_Ricci_Tilde_tensor(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Vector< T > &tilde_Gamma, const tensorium::Tensor< T, 3 > &christoffel_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde)
Combine all four contributions to compute the conformal Ricci tensor:
Definition BSSNRicciTildeTensor.hpp:222
static void compute(const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Tensor< T, 3 > &christoffel, tensorium::Vector< T > &tildeGamma)
Computes .
Definition BSSNTildeChristoffel.hpp:57
Definition BSSNAtildeTensor.hpp:10
void print_tensor3(const std::string &name, const tensorium::Tensor< T, 3 > &tensor)
Definition BSSNPrintDebug.hpp:21
void print_vector(const std::string &name, const tensorium::Vector< T > &vec)
Definition BSSNPrintDebug.hpp:34
auto autodiff(const tensorium::Vector< T > &X, T dx, T dy, T dz, FieldFunc &&func, DiffMode mode, const tensorium::Tensor< T, 3 > &christoffel={})
Definition BSSNAutoDiff.hpp:94
void print_tensor2(const std::string &name, const tensorium::Tensor< T, 2 > &tensor)
Definition BSSNPrintDebug.hpp:11
Storage structure for all evolved BSSN variables on a single grid point or patch.
Definition BSSNSetup.hpp:47
std::vector< tensorium::Vector< double > > beta
Shift vector .
Definition BSSNSetup.hpp:50
std::vector< tensorium::Tensor< double, 2 > > gamma_ij
Physical 3-metric .
Definition BSSNSetup.hpp:51
std::vector< double > alpha
Lapse function .
Definition BSSNSetup.hpp:49
std::vector< double > chi
Conformal factor .
Definition BSSNSetup.hpp:53
std::vector< tensorium::Tensor< double, 2 > > gamma_ij_inv
Inverse .
Definition BSSNSetup.hpp:52
std::vector< tensorium::Tensor< double, 2 > > gamma_tilde
Conformal metric .
Definition BSSNSetup.hpp:55
std::vector< tensorium::Tensor< double, 2 > > ExtrinsicTensor
Extrinsic curvature .
Definition BSSNSetup.hpp:62
std::vector< tensorium::Vector< double > > contracted_Gamma
Contracted symbols.
Definition BSSNSetup.hpp:68
std::vector< tensorium::Vector< double > > tilde_Gamma
Conformal contracted symbols .
Definition BSSNSetup.hpp:66
std::vector< tensorium::Tensor< double, 3 > > christoffel_tilde
Christoffel symbols .
Definition BSSNSetup.hpp:61
std::vector< tensorium::Tensor< double, 3 > > dgamma_tilde
Derivatives .
Definition BSSNSetup.hpp:59
std::vector< tensorium::Tensor< double, 2 > > A_tildeTensor
Trace-free extrinsic curvature .
Definition BSSNSetup.hpp:64
std::vector< tensorium::Tensor< double, 2 > > gamma_tilde_inv
Inverse .
Definition BSSNSetup.hpp:57
std::vector< tensorium::Tensor< double, 5 > > ricci_tilde
Definition BSSNSetup.hpp:69
static ChiContext< T > compute(const tensorium::Vector< T > &X_, T dx_, T dy_, T dz_, const tensorium::Tensor< T, 2 > &g_phys, const tensorium::Tensor< T, 3 > &d_g_phys, const Metric< T > &metric_)
Definition BSSNChiContext.hpp:20