1#ifndef __GEODESCICS_HPP_
2#define __GEODESCICS_HPP_
4#include <fish/fiber/vector/CubicIpol.hpp>
5#include <fish/fiber/vector/LinearIpol.hpp>
6#include <eagle/QuadraticMatrix.hpp>
7#include <eagle/Coordinates.hpp>
8#include <fish/fiber/baseop/LocalFromWorldPoint.hpp>
9#include <ode/dop853.hpp>
79 typedef typename T::Chart_t Chart_t;
80 typedef typename Eagle::Coordinates<Chart_t>::point point;
91 bool ok, normalizeInversion, doInversion;
99 const double dxP,
const double dyP,
const double dzP,
107 std::cout <<
"aber jetzt nit im ersnst!!!";
113 for(
unsigned i = 0; i < T::SIZE; i++)
114 g_diff[
X][i] = (
g_xP[i] - g[i] ) /
dxP;
117 for(
unsigned i = 0; i < T::SIZE; i++)
118 g_diff[
Y][i] = (
g_yP[i] - g[i] ) /
dyP;
121 for(
unsigned i = 0; i < T::SIZE; i++)
122 g_diff[
Z][i] = (
g_zP[i] - g[i] ) /
dzP;
134 for(
unsigned i = 0; i < T::SIZE; i++)
135 g_diff[
X][i] = (
g_xP[i] - g[i] ) /
dxP;
138 for(
unsigned i = 0; i < T::SIZE; i++)
139 g_diff[
Y][i] = (
g_yP[i] - g[i] ) /
dyP;
142 for(
unsigned i = 0; i < T::SIZE; i++)
143 g_diff[
Z][i] = (
g_zP[i] - g[i] ) /
dzP;
181 double fac = q[0][0];
183 if( normalizeInversion )
185 for(
size_t i = 0; i < T::Dims; i++ )
186 for(
size_t j = 0; j < T::Dims; j++ )
187 q[i][j] = q[i][j] /
fac;
191 Eagle::ComputeInverse(g_inv, q);
200 if( normalizeInversion )
202 for(
size_t i = 0; i < T::Dims; i++ )
203 for(
size_t j = 0; j < T::Dims; j++ )
204 g_inv[i][j] = g_inv[i][j] /
fac;
211 puts(
"ChristoffelXYZ<>::ChristoffelXYZ ERROR Degenerated Matrix in inversion.");
fflush(
stdout);
249 double fac = q[0][0];
251 if( normalizeInversion )
253 for(
size_t i = 0; i < T::Dims; i++ )
254 for(
size_t j = 0; j < T::Dims; j++ )
255 q[i][j] = q[i][j] /
fac;
259 Eagle::ComputeInverse(g_inv, q);
268 if( normalizeInversion )
270 for(
size_t i = 0; i < T::Dims; i++ )
271 for(
size_t j = 0; j < T::Dims; j++ )
272 g_inv[i][j] = g_inv[i][j] /
fac;
279 puts(
"ChristoffelXYZ<>::ChristoffelXYZ ERROR Degenerated Matrix in inversion.");
fflush(
stdout);
284 bool isOk(){
return ok;}
288 for(
unsigned i = 0; T::SIZE; i++)
296 const double operator()(
const unsigned mu,
const unsigned nu,
const unsigned lambda)
const
300 if(
mu > T::Dims-1 ||
nu > T::Dims-1 || lambda > T::Dims-1)
304 for(
unsigned i = 0; i < T::Dims; i++)
305 gamma += g_inv(lambda, i) * ( g_diff[
nu](
mu,i) + g_diff[
mu](
nu,i) - g_diff[i](
mu,
nu) );
307 for(
unsigned i = 0; i < T::Dims; i++)
308 gamma += g(lambda, i) * ( g_diff[
nu](
mu,i) + g_diff[
mu](
nu,i) - g_diff[i](
mu,
nu) );
315 const double gammaDebug(
const unsigned mu,
const unsigned nu,
const unsigned lambda)
const
319 if(
mu > T::Dims-1 ||
nu > T::Dims-1 || lambda > T::Dims-1)
321 printf(
"mu nu lam %d %d %d",
mu,
nu, lambda);
322 for(
unsigned i = 0; i < T::Dims; i++)
325 double tmp = g_inv(lambda, i) * ( g_diff[
nu](
mu,i) + g_diff[
mu](
nu,i) - g_diff[i](
mu,
nu) );
327 printf(
"g_inv: %f, g1: %f, g2:% f, g3: %f, term: %f\n", g_inv(lambda, i), g_diff[
nu](
mu,i), g_diff[
mu](
nu,i), g_diff[i](
mu,
nu),
tmp);
330 printf(
"gamma: %f\n", gamma);
335 const T& getG() {
return g; }
337 const T& getGDiff(
unsigned iP ) {
return g_diff[
iP]; }
342 std::cout <<
"Christoffel content:\n" <<
"g " <<
endl << g <<
"g_inv: " <<
endl << g_inv;
357 cout <<
"Gamma (T)|X|Y|Z|:" <<
endl;
359 for(
unsigned lam = 0;
lam < T::Dims;
lam++)
361 for(
unsigned mu = 0;
mu < T::Dims;
mu++)
363 for(
unsigned nu = 0;
nu < T::Dims;
nu++)
365 printf(
"%f ", (*
this)(
mu,
nu,
lam));
369 printf(
"-----------------------------\n");
394 typename Eagle::Coordinates<typename T::Chart_t >::vector&
q_dot )
396typename Eagle::Coordinates<typename T::Chart_t >::vector
q_ddot;
404 for(
index_t lambda = 0; lambda < T::Dims; lambda++)
416typename Eagle::Coordinates<typename TT::Chart_t >::vector getQdot(
const typename Eagle::Coordinates<typename TT::Chart_t >::vector&
q_dot,
417 const TT&g,
const bool big =
true)
427const double eps = 1.0e-4;
431typename Eagle::Coordinates<typename TT::Chart_t >::vector v =
q_dot;
442 puts(
"Creating Initial Condition for falling geodesic.");
449 puts(
"getQdot::Error g(T,T) == 0! Division by 0.");
455double A = 2 * ( g(
X,T)*v[
X] + g(
Y,T)*v[
Y] + g(
Z,T)*v[
Z] );
456double B = g(
X,
X)*v[
X]*v[
X] + g(
Y,
Y)*v[
Y]*v[
Y] + g(
Z,
Z)*v[
Z]*v[
Z]+
457 2*( g(
X,
Y)*v[
X]*v[
Y] + g(
X,
Z)*v[
X]*v[
Z] + g(
Y,
Z)*v[
Y]*v[
Z] );
466 puts(
"getQdot::Error direction initialization srqt < 0!!!!");
472 double v1 = -p/2 +
sw;
473 double v2 = -p/2 -
sw;
476 v[T] = (v1 >
v2)? v1 :
v2;
478 v[T] = (v1 >
v2)?
v2 : v1;
487bool getChristoffelXYZ(
const typename Eagle::Coordinates<typename T::Chart_t >::point&
CurrentPoint,
493 bool normalizeInversion,
bool doInversion )
496 puts(
"getChristoffelXYZ<class T>() enter" );
497 cout <<
"AtomicIntegrator::doEuler() invNorm: " << normalizeInversion <<
endl;
498 cout <<
"AtomicIntegrator::doEuler() invEnable: " << doInversion <<
endl;
500 typedef typename T::Chart_t Chart_t;
508 puts(
"getChristoffelXYZ<class T>() getting local point" );
510 bool test = LocalPointFinder->get( current, localPoint );
514 puts(
"getChristoffelXYZ()1 error finding local point at:");
532 cout <<
"in Fragment:" << FragName->Name() <<
endl;
537 puts(
"AtomicIntegrator<metric33, Geodesic>doit2(); ERROR: No Field0 found in Time iteration");
559 cout <<
"getChristoffelXYZ<T> dims:" << T::Dims <<
endl;
560 mBase.speak(
"getChristoffelXYZ<T> ------>");
562 puts(
"getChristoffelXYZ()<T>:ERROR retrieving matching field. Maybe Dims of instantiated metric and Dims of field data does not match. 33 44?");
622 Eagle::point3 delta =
FData->Delta();
630 if(
det < 0.0 && T::Dims == 3)
634 puts(
"getChristoffelXYZ()<T>:warning, Det of G < 0.");
671 puts(
"getChristoffelXYZ()<T>:warning, christoffels probably degenerated matrix.");
689bool getChristoffelXYZ(
const typename Eagle::Coordinates<typename T::Chart_t >::point&
current_pointP,
699 puts(
"getChristoffelXYZ<class T>() enter" );
700 cout <<
"AtomicIntegrator::doEuler() invNorm: " << normalizeInversion <<
endl;
701 cout <<
"AtomicIntegrator::doEuler() invEnable: " << doInversion <<
endl;
703 typedef typename T::Chart_t Chart_t;
709 if(
det < 0.0 && T::Dims == 3)
713 puts(
"getChristoffelXYZ()<T>:warning, Det of G < 0.");
721 puts(
"getChristoffelXYZ<class T>() getting local point" );
733 puts(
"AtomicIntegrator<metric33, Geodesic>doit2(); ERROR: No Field0 found in Time iteration");
762 Eagle::point3 delta =
FData->Delta();
767 if(
det < 0.0 && T::Dims == 3)
771 puts(
"getChristoffelXYZ()<T>:warning, Det of G < 0.");
807 puts(
"getChristoffelXYZ()<T>:warning, christoffels probably degenerated matrix.");
830 puts(
"getChristoffelXYZ()<T>:warning, local point not found for x+h");
853 puts(
"getChristoffelXYZ()<T>:warning, local point not found for x-h");
885 puts(
"getChristoffelXYZ()<T>:warning, christoffels probably degenerated matrix.");
907typedef typename T::Chart_t Chart_t;
908typedef typename Eagle::Coordinates<Chart_t>::point point;
909typedef typename Eagle::Coordinates<Chart_t>::vector tvector;
927bool normalizeInversion, doInversion;
929 enum { N = T::Dims * 2 };
957 void Accel(real s,
const real *x,
const real *v, real *
d2x_ds2)
962 for(
int k=0; k < point::Dims; k++)
971 bool test = FieldLines::getChristoffelXYZ<T>(
Q, LocalPointFinder,
FieldSelection, step_size,
974 localPoint, normalizeInversion, doInversion );
977 puts(
"GeodesicDifferentialEquation::DifferentialEquation::Accel() No valid point found!");
fflush(
stdout);
983 for(
int k=0; k < point::Dims; k++)
complex< _Tp > sqrt(const complex< _Tp > &)
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
An abstract selection of fields, that is given by names of fields and possible types for each field.
Definition FieldSelection.hpp:23
string getFieldName() const
Retrieve the name of a unique field, if only one is stored here.
Definition FieldSelection.cpp:68
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
RefPtr< CreativeArrayBase > getCreator(const RefPtr< FragmentID > &=nullptr) const
Get the creator of an unfragmented field.
Definition Field.cpp:603
void set(const T &Value)
Set all elements to the same value.
Definition vector/Iterator.hpp:724
Use this class to compute a local cell index and fragment ID (if neccessary) of any coordinate field ...
Definition LocalFromWorldPoint.hpp:71
Definition Geodesics.hpp:78
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Helper class (type trait) for class LinerIpol, which for a given type T provides a static member func...
Definition LinearIpol.hpp:25
Definition LocalFromWorldPoint.hpp:39
Definition Geodesics.hpp:943
Definition Geodesics.hpp:938
Definition Geodesics.hpp:906
Definition Geodesics.hpp:68
Definition Geodesics.hpp:66