Compute geodesics in a 4D tensor field.
Compute geodesics in a 4D tensor field.This example sets up a 10x10x10x10 metric tensor field with the unit metric describing Euclidean space, but sets an artificial anisotropy at a single point within the data field. Then, a geodesic is computed that will be a straight line far from this singular point, but deviated close to it. For demonstration purposes, the geodesic is computed via Euler integration.
This example is similar to NumericalGeodesics3D.cpp, but just extended to four dimensions. In the same manner, geodesics can be computed in arbitrary dimensions. However, the computational increases enormously.
#include <spacetime/Schwarzschild.hpp>
#include <spacetime/Geodesic853.hpp>
#include <spacetime/Acceleration.hpp>
#include <vecal/CartesianChart.hpp>
#include <spacetime/NumericalSpacetime.hpp>
#include <spacetime/IntegrateGeodesic.hpp>
#include <stdio.h>
#include <time.h>
using namespace VecAl;
void NumericalTestField4D()
{
enum { x=0, y=1, z=2, t=3 };
Tensor TensorStorage[10000];
MultiArray<4, Tensor, Tensor*> G(TensorStorage, MIndex(10,10,10,10) );
Tensor InitValue;
InitValue.set(0);
InitValue(0,0) = InitValue(1,1) = InitValue(2,2) = InitValue(3,3) = 1;
G.set( InitValue );
G[ MIndex(5,6,7,3) ] (2,2) = 2;
q = 5.1, 6.8, 5.03, 3;
q0 = q;
v = 0.01,0.02,.2,0;
v0 = v;
ChristoffelField<MultiArray<4, Tensor, Tensor*> > Chris(G,q);
clock_t start, finish;
start = clock();
{for(int is = 0; is<40000; is++)
{
double ds = 0.001;
Chris.getCoordinateAcceleration(a, v);
q += v*ds;
v += a*ds;
if (is %1000 == 0)
}}
finish = clock();
printf( "4D Geodesic computation: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
}
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Vectorized vector.
Definition VVector.hpp:288