Demonstration of the interpolated derivative of a vector field.
Demonstration of the interpolated derivative of a vector field.
#include <vector/CubicIpol.hpp>
#include <vector/LinearIpol.hpp>
#include <vector/MultiArray.hpp>
#include <vector/Interpolate.hpp>
#include <eagle/Vector.hpp>
#include <eagle/Matrix.hpp>
#include <eagle/QuadraticMatrix.hpp>
#include <time.h>
static int DemonstrateTensorDerivative()
{
enum { x=0, y=1, z=2 };
Tensor TensorStorage[1000];
Tensor InitValue;
InitValue(0,0) = InitValue(1,1) = InitValue(2,2) = 1;
InitValue(0,1) = InitValue(1,2) = InitValue(2,0) = 0;
G.set( InitValue );
I = 5,6,7;
G[ I ] (2,2) = 2;
int Component = Tensor::mem_index(2,2);
Gnm_t Gnm( GnmPtr, G.Size() );
{
Gnm_k(Gnm, point);
for(double fr=0; fr<2; fr+=0.1)
{
point = 5.1, 6.2, 7 + fr;
cout <<
"Cubic interpolated derived tensor component Gmn,k " << point <<
" " << Gnm_k.eval() <<
endl
;
}
}
q = 5.1, 6.8, 5.03;
v = 0.01,0.02,.2;
clock_t start, finish;
start = clock();
for(int is = 0; is<40000; is++)
{
double ds = 0.001;
#ifndef EXPLICIT_CHRISTOFFEL_OPERATIONS
#if 0
TensorDerivative<MultiArray<3, Tensor, Tensor*> > dG(G, q);
dG.eval( g_ij_k );
#elif 0
{for(int j=0; j<3; j++)
for(int i=j; i<3; i++)
{
int Component = Tensor::mem_index(i,j);
Gnm_t Gnm( &G.storage().vec(), Component, G.Size() );
#if 1
D(Gnm, q);
D.eval( g_ij_k(i,j) );
#else
#if 1
#else
#endif
#if 0
g_ij_k[i][j][0] = Gij_0.eval();
g_ij_k[i][j][1] = Gij_1.eval();
g_ij_k[i][j][2] = Gij_2.eval();
#else
g_ij_k(i,j)[0] = Gij_0.eval();
g_ij_k(i,j)[1] = Gij_1.eval();
g_ij_k(i,j)[2] = Gij_2.eval();
#endif
#endif
}
}
#endif
{for(int j=0; j<3; j++)
for(int i=j; i<3; i++)
for(int k=0; k<3; k++)
{
G_ijk(i,j)[k] = g_ij_k(i,k)[j] + g_ij_k(j,k)[i] - g_ij_k(i,j)[k];
}
}
const Tensor&Glocal = Gfield.eval();
{for(int k=0; k<3; k++)
{
dv[k] = 0;
for(int j=0; j<3; j++)
{
double G_ijk_vi = 0;
for(int i=0; i<3; i++)
{
G_ijk_vi += G_ijk(i,j)[k] * v[i];
}
G_ijk_vi *= v[j];
dv[k] += G_ijk_vi;
}
}
}
cout <<
" Coordinate Acceleration:" << a <<
endl;
#else
ChristoffelField<MultiArray<3, Tensor, Tensor*> > Chris(G,q);
Chris.getAcceleration(a, v);
#endif
#pragma message "this next operator should work - CHECK!"
v += a*ds;
if (is %1000 == 0)
}
finish = clock();
printf( "Geodesic computation: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
cout <<
"Final: v="<<v<<
"\t q="<<q<<
endl;
cout <<
"EXPECT v=(0.00628477,0.088151,0.180334) q=(5.3987,9.70163,12.4076)" <<
endl;
return 1;
}
static int DemonstrateGeodesics()
{
enum { x=0, y=1, z=2 };
Tensor TensorStorage[1000];
Tensor 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;
#if 0
ChristoffelField<MultiArray<3, Tensor, Tensor*> > Chris(G,q);
#if 1
{
typedef Tensor metric_type;
typedef Tensor* MetricStorage_t;
typedef double CoordinateType;
metric_type m = MetricField[0];
}
#else
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 );
{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)
}}
cout <<
"q=" << q <<
"\t q0=" << q0 <<
" Diff: " << q-q0 <<
endl;
cout <<
"v=" << v <<
"\t v0=" << v0 <<
" Diff: " << v-v0 <<
endl;
double Qerror =
norm2(q-q0);
assert( Qerror < 1E-8 );
#endif
#endif
return 1;
}
int dVInterpolCheck()
{
int r=0;
return r;
}
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
FixedArray< int, N > PermutationVector_t
bool GaussDecompose(FixedArray< int, N > &perm, double EPSWEIGHT=1E-3)
void GaussSolve(const PermutationVector_t &perm, const Column< N, value > &b, Column< N, value > &x) const
Vectorized vector.
Definition VVector.hpp:288
Cubic interpolation using Hermite polynoms.
Definition CubicIpol.hpp:70
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
Definition MultiArray.hpp:371
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
Definition IpolDelimiter.hpp:38
double norm2(const PhysicalSpace::bivector &v)
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
The interpolator template.
Definition Interpolate.hpp:63