Compute geodesics in a 3D tensor field.
Compute geodesics in a 3D tensor field.This example sets up a 10x10x10 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.
#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 NumericalTestField3D()
{
enum { x=0, y=1, z=2 };
myMetric TensorStorage[1000];
MultiArray<3, myMetric, myMetric*> G(TensorStorage, MIndex(10,10,10) );
myMetric InitValue;
InitValue(0,0) = InitValue(1,1) = InitValue(2,2) = 1;
InitValue(0,1) = InitValue(1,2) = InitValue(2,0) = 0;
G.set( InitValue );
G[ MIndex(5,6,7) ] (2,2) = 2;
q = 5.1, 6.8, 5.03;
q0 = q;
v = 0.01,0.02,.2;
v0 = v;
ChristoffelField<MultiArray<3, myMetric, myMetric*> > 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( "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