41 if (gamma_tilde.
shape() != std::array<size_t, 2>{3, 3})
42 throw std::invalid_argument(
"gamma_tilde must be 3x3");
43 if (gamma_tilde_inv.
shape() != std::array<size_t, 2>{3, 3})
44 throw std::invalid_argument(
"gamma_tilde_inv must be 3x3");
45 if (dgamma_tilde.
shape() != std::array<size_t, 3>{3, 3, 3})
46 throw std::invalid_argument(
"dgamma_tilde must be 3x3x3");
48 Christoffel.
resize(3, 3, 3);
50 for (
size_t k = 0; k < 3; ++k) {
51 for (
size_t i = 0; i < 3; ++i) {
52 for (
size_t j = 0; j < 3; ++j) {
54 for (
size_t l = 0; l < 3; ++l) {
56 dgamma_tilde(i, l, j) + dgamma_tilde(j, l, i) - dgamma_tilde(l, i, j);
57 sum += gamma_tilde_inv(k, l) * term;
59 Christoffel(k, i, j) = T(0.5) * sum;
72 const size_t NX = gamma_tilde.dim(0);
73 const size_t NY = gamma_tilde.dim(1);
74 const size_t NZ = gamma_tilde.dim(2);
78 for (
size_t x = 0; x <
NX; ++x) {
79 for (
size_t y = 0;
y <
NY; ++
y) {
80 for (
size_t z = 0;
z <
NZ; ++
z) {
86 for (
size_t i = 0; i < 3; ++i)
87 for (
size_t j = 0;
j < 3; ++
j) {
89 ginv(i,
j) = gamma_tilde_inv(x,
y,
z, i,
j);
90 for (
size_t k = 0;
k < 3; ++
k)
91 dg(i,
j,
k) = dgamma_tilde(x,
y,
z, i,
j,
k);
96 for (
size_t i = 0; i < 3; ++i)
97 for (
size_t j = 0;
j < 3; ++
j)
98 for (
size_t k = 0;
k < 3; ++
k)
127 size_t j,
size_t k,
T dx,
T dy,
T dz,
132 auto get = [&](
int ii,
int jj,
int kk,
int a,
int b) ->
T {
137 size_t Nx = dim[0],
Ny = dim[1],
Nz = dim[2];
139 for (
size_t a = 0; a < 3; ++a) {
140 for (
size_t b = 0; b < 3; ++b) {
141 if (i >= 2 && i + 2 <
Nx)
142 dgamma_out(0, a, b) = (-get(i + 2,
j,
k, a, b) + 8 * get(i + 1,
j,
k, a, b) -
143 8 * get(i - 1,
j,
k, a, b) + get(i - 2,
j,
k, a, b)) /
145 else if (i > 0 && i + 1 <
Nx)
146 dgamma_out(0, a, b) = (get(i + 1,
j,
k, a, b) - get(i - 1,
j,
k, a, b)) / (2 * dx);
150 if (
j >= 2 &&
j + 2 <
Ny)
151 dgamma_out(1, a, b) = (-get(i,
j + 2,
k, a, b) + 8 * get(i,
j + 1,
k, a, b) -
152 8 * get(i,
j - 1,
k, a, b) + get(i,
j - 2,
k, a, b)) /
154 else if (
j > 0 &&
j + 1 <
Ny)
155 dgamma_out(1, a, b) = (get(i,
j + 1,
k, a, b) - get(i,
j - 1,
k, a, b)) / (2 * dy);
159 if (
k >= 2 &&
k + 2 <
Nz)
160 dgamma_out(2, a, b) = (-get(i,
j,
k + 2, a, b) + 8 * get(i,
j,
k + 1, a, b) -
161 8 * get(i,
j,
k - 1, a, b) + get(i,
j,
k - 2, a, b)) /
163 else if (
k > 0 &&
k + 1 <
Nz)
164 dgamma_out(2, a, b) = (get(i,
j,
k + 1, a, b) - get(i,
j,
k - 1, a, b)) / (2 * dz);
Multi-dimensional tensor class with fixed rank and SIMD support.
Definition Tensor.hpp:25
void resize(const std::array< size_t, Rank > &dims)
Resize 2D tensor.
Definition Tensor.hpp:70
std::array< size_t, Rank > shape() const
Definition Tensor.hpp:62
Compute the conformal Christoffel symbols .
Definition BSSNChristoffel.hpp:26
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
Definition BSSNAtildeTensor.hpp:10
void compute_partial_derivatives_3D(const tensorium::Tensor< T, 5 > &gamma_field, size_t i, size_t j, size_t k, T dx, T dy, T dz, tensorium::Tensor< T, 3 > &dgamma_out)
Compute the 3D partial derivatives from a 5D field tensor.
Definition BSSNChristoffel.hpp:126
Definition Derivate.hpp:24