Tensorium
Loading...
Searching...
No Matches
FunctionnalRG.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Core/Vector.hpp"
4#include "../Core/Tensor.hpp"
12
13namespace tensorium {
14
15
16 template <typename T>
22
23 template <typename T>
25 const size_t d0 = tensor.dimensions[0];
26 const size_t d1 = tensor.dimensions[1];
27 Matrix<T> mat({d0, d1});
28 for (size_t i = 0; i < d0; ++i)
29 for (size_t j = 0; j < d1; ++j)
30 mat(i, j) = tensor(i, j);
31 return mat;
32 }
33
34 template <typename T>
36 const size_t d0 = mat.rows;
37 const size_t d1 = mat.cols;
38
40 for (size_t i = 0; i < d0; ++i)
41 for (size_t j = 0; j < d1; ++j)
42 tensor(i, j) = mat(i, j);
43 return tensor;
44 }
45
46 /*
47 * @brief Compute Christoffel symbols Γ^λ_{μν}
48 * @param X 4-position
49 * @param h Finite difference step
50 * @param g Metric tensor g_{μν}
51 * @param g_inv Inverse metric g^{μν}
52 * @param metric_generator Callable: X ↦ g_{μν}
53 * @return Christoffel symbol tensor Γ^λ_{μν}
54 */
55
56 template <typename T, typename MetricFunc>
65
66 /*
67 * @brief Generate a metric tensor g_{μν} at position X using a Metric<T> object
68 * @param metric Metric object (Minkowski, Schwarzschild, Kerr)
69 * @param X Point at which to evaluate
70 * @param g Output tensor g_{μν}
71 */
72 template <typename T>
74 const Vector<T>& X,
75 Tensor<T, 2>& g) {
76 metric(X, g);
77 }
78
79 template <typename T>
87
88 template <typename T>
93
94
95 template<typename T>
99
100 template<typename T>
104
105 template<typename T>
109
110 template<typename T>
114 template<typename T>
116 const Tensor<T, 2>& gamma) {
117 return metric.compute_conformal_factor(gamma);
118 }
119
120 template<typename T>
122 const Tensor<T, 2>& gamma,
123 T chi) {
124 Tensor<T, 2> gamma_tilde({3, 3});
125 metric.compute_conformal_metric(gamma, chi, gamma_tilde);
126 return gamma_tilde;
127 }
128
129
130 template<typename T>
131 inline void compute_christoffel_3D(const Tensor<T, 2>& gamma_tilde,
132 const Tensor<T, 3>& dgamma_tilde,
133 const Tensor<T, 2>& gamma_tilde_inv,
135 tensorium_RG::BSSNChristoffel<T>::compute(gamma_tilde, dgamma_tilde, gamma_tilde_inv, Christoffel);
136 }
137
138 template<typename T>
139 inline void compute_christoffel_3D_Grid(const Tensor<T, 5>& gamma_tilde,
140 const Tensor<T, 6>& dgamma_tilde,
141 const Tensor<T, 5>& gamma_tilde_inv,
143 tensorium_RG::BSSNChristoffel<T>::compute3D(gamma_tilde, dgamma_tilde, gamma_tilde_inv, Christoffel);
144 }
145
146 template<typename T>
148 const tensorium_RG::Metric<T>& metric,
149 T dx, T dy, T dz) {
151 bssn.init_BSSN(X, metric, dx, dy, dz);
152 return bssn;
153 }
154
155}
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
std::array< size_t, Rank > dimensions
Dimensions of the tensor (e.g., {4,4,4,4})
Definition Tensor.hpp:29
static void compute3D(const tensorium::Tensor< T, 5 > &gamma_tilde, const tensorium::Tensor< T, 6 > &dgamma_tilde, const tensorium::Tensor< T, 5 > &gamma_tilde_inv, tensorium::Tensor< T, 6 > &Christoffel)
Definition BSSNChristoffel.hpp:65
static void compute(const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 3 > &dgamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, tensorium::Tensor< T, 3 > &Christoffel)
Compute the conformal Christoffel symbols .
Definition BSSNChristoffel.hpp:36
Driver class to initialize and store BSSN variables from an input spacetime metric.
Definition BSSNSetup.hpp:81
Stores and computes Christoffel symbols .
Definition ChristoffelSymbol.hpp:40
A callable 4D metric class for general relativity (Minkowski, Schwarzschild, Kerr,...
Definition Metric.hpp:27
void compute_conformal_metric(const tensorium::Tensor< T, 2 > &gamma, T chi, tensorium::Tensor< T, 2 > &gamma_tilde) const
Definition Metric.hpp:109
T compute_conformal_factor(const tensorium::Tensor< T, 2 > &gamma) const
Definition Metric.hpp:101
static void print_ricci_scalar(const Tensor2D &Ricci, const tensorium::Tensor< T, 2 > &g_inv)
Computes and prints the Ricci scalar from the tensor and metric.
Definition RicciTensor.hpp:141
static void print_componentwise(const Tensor2D &R, T threshold=1e-12)
Prints the Ricci tensor components with optional zero threshold.
Definition RicciTensor.hpp:84
static double compute_ricci_scalar(const Tensor2D &Ricci, const tensorium::Tensor< T, 2 > &g_inv)
Computes the Ricci scalar curvature.
Definition RicciTensor.hpp:67
static tensorium::Tensor< T, 2 > contract_to_ricci(const Tensor4D &Riemann, const tensorium::Tensor< T, 2 > &g_inv)
Contracts a 4D Riemann tensor into the 2D Ricci tensor.
Definition RicciTensor.hpp:40
static Tensor4D compute(const VectorT &X, T h, const Metric< T > &metric)
Computes the 4D Riemann curvature tensor .
Definition RiemannTensor.hpp:90
static void print_componentwise(const Tensor4D &R, T threshold=1e-12)
Definition RiemannTensor.hpp:30
Definition Derivate.hpp:24
void generate_metric(const tensorium_RG::Metric< T > &metric, const Vector< T > &X, Tensor< T, 2 > &g)
Definition FunctionnalRG.hpp:73
void compute_christoffel_3D_Grid(const Tensor< T, 5 > &gamma_tilde, const Tensor< T, 6 > &dgamma_tilde, const Tensor< T, 5 > &gamma_tilde_inv, Tensor< T, 6 > &Christoffel)
Definition FunctionnalRG.hpp:139
tensorium_RG::BSSN< T > setup_BSSN(const Vector< T > &X, const tensorium_RG::Metric< T > &metric, T dx, T dy, T dz)
Definition FunctionnalRG.hpp:147
T compute_ricci_scalar(const Tensor< T, 2 > &Ricci, const Tensor< T, 2 > &ginv)
Definition FunctionnalRG.hpp:101
void print_ricci_scalar(const Tensor< T, 2 > &Ricci, const Tensor< T, 2 > &g_inv)
Definition FunctionnalRG.hpp:111
tensorium::Tensor< T, 4 > compute_riemann_tensor(const tensorium::Vector< T > &X, T h, const tensorium_RG::Metric< T > &metric)
Definition FunctionnalRG.hpp:80
T compute_conformal_factor(const tensorium_RG::Metric< T > &metric, const Tensor< T, 2 > &gamma)
Definition FunctionnalRG.hpp:115
tensorium_RG::ChristoffelSym< T > compute_christoffel(const tensorium::Vector< T > &X, T h, const tensorium::Tensor< T, 2 > &g, const tensorium::Tensor< T, 2 > &g_inv, MetricFunc &&metric_generator)
Definition FunctionnalRG.hpp:57
Tensor< T, 2 > contract_riemann_to_ricci(const Tensor< T, 4 > &R, const Tensor< T, 2 > &ginv)
Definition FunctionnalRG.hpp:96
void print_riemann_tensor(const tensorium::Tensor< T, 4 > &R)
Definition FunctionnalRG.hpp:89
Tensor< T, 2 > compute_conformal_metric(const tensorium_RG::Metric< T > &metric, const Tensor< T, 2 > &gamma, T chi)
Definition FunctionnalRG.hpp:121
Matrix< T > tensor_to_matrix(const Tensor< T, 2 > &tensor)
Definition FunctionnalRG.hpp:24
tensorium::Tensor< T, 2 > inv_mat_tensor(const tensorium::Tensor< T, 2 > &g)
Definition FunctionnalRG.hpp:17
void compute_christoffel_3D(const Tensor< T, 2 > &gamma_tilde, const Tensor< T, 3 > &dgamma_tilde, const Tensor< T, 2 > &gamma_tilde_inv, Tensor< T, 3 > &Christoffel)
Definition FunctionnalRG.hpp:131
void print_ricci_tensor(const Tensor< T, 2 > &R)
Definition FunctionnalRG.hpp:106
Tensor< T, 2 > matrix_to_tensor(const Matrix< T > &mat)
Definition FunctionnalRG.hpp:35