Tensorium
Loading...
Searching...
No Matches
BSSNRicciConformalTensor.hpp
Go to the documentation of this file.
1
6#pragma once
7
10#include "../../Core/Vector.hpp"
11#include "../Metric.hpp"
12#include "BSSNAutoDiff.hpp"
13#include "BSSNChiContext.hpp"
14#include "BSSNChristoffel.hpp"
16#include "BSSNDerivatives.hpp"
17
18namespace tensorium_RG {
19
45template <typename T> class RicciConformalTensor {
46 public:
55 const tensorium::Tensor<T, 2> &gamma_tilde,
56 const tensorium::Tensor<T, 2> &gamma_tilde_inv,
57 const tensorium::Tensor<T, 3> &christoffel_tilde) {
58 using namespace tensorium;
59 Tensor<T, 2> result({3, 3});
60
61 for (int i = 0; i < 3; ++i) {
62 for (int j = 0; j < 3; ++j) {
63 T corrected_hessian = chi_context.hessian_chi(i, j);
64 for (int k = 0; k < 3; ++k)
65 corrected_hessian -= christoffel_tilde(k, i, j) * chi_context.grad_chi(k);
66 result(i, j) = corrected_hessian / chi_context.chi;
67 }
68 }
69
70 for (int i = 0; i < 3; ++i)
71 for (int j = i + 1; j < 3; ++j) {
72 T avg = 0.5 * (result(i, j) + result(j, i));
73 result(i, j) = result(j, i) = avg;
74 }
75
76 return result;
77 }
86 const tensorium::Tensor<T, 2> &gamma_tilde,
87 const tensorium::Tensor<T, 2> &gamma_tilde_inv,
88 const tensorium::Tensor<T, 3> &christoffel_tilde) {
89 using namespace tensorium;
90
91 Tensor<T, 2> result({3, 3});
92
93 const auto &grad_chi = chi_context.grad_chi;
94 const auto &hessian_chi = chi_context.hessian_chi;
95 const T chi = chi_context.chi;
96
97 T laplacian_chi = 0.0;
98 for (int k = 0; k < 3; ++k) {
99 for (int l = 0; l < 3; ++l) {
100 T term = hessian_chi(k, l);
101 for (int m = 0; m < 3; ++m)
102 term -= christoffel_tilde(m, k, l) * grad_chi(m);
103 laplacian_chi += gamma_tilde_inv(k, l) * term;
104 }
105 }
106
107 for (int i = 0; i < 3; ++i)
108 for (int j = 0; j < 3; ++j)
109 result(i, j) = 0.5 * gamma_tilde(i, j) * laplacian_chi / chi;
110
111 return result;
112 }
113
121 using namespace tensorium;
122
123 Tensor<T, 2> result({3, 3});
124
125 const auto &grad_chi = chi_context.grad_chi;
126 const T chi = chi_context.chi;
127
128 const T inv_chi2 = 1.0 / (chi * chi);
129 const T coeff = -1.5 * inv_chi2;
130
131 for (int i = 0; i < 3; ++i)
132 for (int j = 0; j < 3; ++j)
133 result(i, j) = coeff * grad_chi(i) * grad_chi(j);
134
135 return result;
136 }
145 const tensorium::Tensor<T, 2> &gamma_tilde,
146 const tensorium::Tensor<T, 2> &gamma_tilde_inv) {
147 using namespace tensorium;
148
149 Tensor<T, 2> result({3, 3});
150
151 const auto &grad_chi = chi_context.grad_chi;
152 const T chi = chi_context.chi;
153 const T inv_chi2 = 1.0 / (chi * chi);
154
155 T grad_norm = 0.0;
156 for (int k = 0; k < 3; ++k)
157 for (int l = 0; l < 3; ++l)
158 grad_norm += gamma_tilde_inv(k, l) * grad_chi(k) * grad_chi(l);
159
160 for (int i = 0; i < 3; ++i)
161 for (int j = 0; j < 3; ++j)
162 result(i, j) = 0.5 * inv_chi2 * gamma_tilde(i, j) * grad_norm;
163
164 return result;
165 }
174 const tensorium::Tensor<T, 2> &gamma_tilde,
175 const tensorium::Tensor<T, 2> &gamma_tilde_inv,
176 const tensorium::Tensor<T, 3> &christoffel_tilde) {
177 using namespace tensorium;
178
180 compute_Ricci_chi_Hessian(chi_context, gamma_tilde, gamma_tilde_inv, christoffel_tilde);
181 Tensor<T, 2> term2 = compute_Ricci_chi_Laplacian(chi_context, gamma_tilde, gamma_tilde_inv,
182 christoffel_tilde);
184 Tensor<T, 2> term4 = compute_Ricci_chi_GradNorm(chi_context, gamma_tilde, gamma_tilde_inv);
185
186 Tensor<T, 2> result({3, 3});
187 for (int i = 0; i < 3; ++i)
188 for (int j = 0; j < 3; ++j)
189 result(i, j) = term1(i, j) + term2(i, j) + term3(i, j) + term4(i, j);
190
191 return result;
192 }
193};
194} // namespace tensorium_RG
Multi-dimensional tensor class with fixed rank and SIMD support.
Definition Tensor.hpp:25
Provides methods to compute the -dependent part of the Ricci tensor in the BSSN formalism.
Definition BSSNRicciConformalTensor.hpp:45
static tensorium::Tensor< T, 2 > compute_Ricci_chi_total(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Tensor< T, 3 > &christoffel_tilde)
Computes the total contribution as:
Definition BSSNRicciConformalTensor.hpp:173
static tensorium::Tensor< T, 2 > compute_Ricci_chi_Hessian(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Tensor< T, 3 > &christoffel_tilde)
Computes the Hessian contribution:
Definition BSSNRicciConformalTensor.hpp:54
static tensorium::Tensor< T, 2 > compute_Ricci_chi_GradGrad(const ChiContext< T > &chi_context)
Computes the squared gradient term:
Definition BSSNRicciConformalTensor.hpp:120
static tensorium::Tensor< T, 2 > compute_Ricci_chi_Laplacian(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv, const tensorium::Tensor< T, 3 > &christoffel_tilde)
Computes the Laplacian contribution:
Definition BSSNRicciConformalTensor.hpp:85
static tensorium::Tensor< T, 2 > compute_Ricci_chi_GradNorm(const ChiContext< T > &chi_context, const tensorium::Tensor< T, 2 > &gamma_tilde, const tensorium::Tensor< T, 2 > &gamma_tilde_inv)
Computes the gradient norm term:
Definition BSSNRicciConformalTensor.hpp:144
Definition BSSNAtildeTensor.hpp:10
Definition Derivate.hpp:24
Definition BSSNChiContext.hpp:10