Gyoto
GyotoMetric.h
Go to the documentation of this file.
1 
12 /*
13  Copyright 2011-2016, 2018-2020 Frederic Vincent, Thibaut Paumard
14 
15  This file is part of Gyoto.
16 
17  Gyoto is free software: you can redistribute it and/or modify
18  it under the terms of the GNU General Public License as published by
19  the Free Software Foundation, either version 3 of the License, or
20  (at your option) any later version.
21 
22  Gyoto is distributed in the hope that it will be useful,
23  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  GNU General Public License for more details.
26 
27  You should have received a copy of the GNU General Public License
28  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #ifndef __GyotoMetric_H_
32 #define __GyotoMetric_H_
33 
34 #include <iostream>
35 #include <fstream>
36 #include <string>
37 #include <vector>
38 
39 #include <GyotoSmartPointer.h>
40 #include <GyotoObject.h>
41 #include <GyotoAstrobj.h>
42 #include <GyotoRegister.h>
43 #include <GyotoHooks.h>
44 #include <GyotoDefs.h>
45 
46 namespace Gyoto {
47  namespace Metric {
48 
49  class Generic;
50 
52 
60  typedef SmartPointer<Metric::Generic> Subcontractor_t(FactoryMessenger*, std::vector<std::string> const &);
61 
62 
72  (FactoryMessenger* fmp, std::vector<std::string> const &plugins) {
73  SmartPointer<T> gg = new T();
74  gg -> plugins(plugins);
75 #ifdef GYOTO_USE_XERCES
76  if (fmp) gg -> setParameters(fmp);
77 #endif
78  return gg;
79  }
80 
82 
100  std::vector<std::string> &plugin,
101  int errmode=0);
102 
104 
109  extern Register::Entry * Register_;
110 
112 
123  void Register(std::string kind, Gyoto::Metric::Subcontractor_t* scp);
124 
126 
130  void initRegister();
131 
132  }
133 
134  /* Documented elswhere */
135  class Worldline;
136 }
137 
159 : public Gyoto::SmartPointee,
160  public Gyoto::Object,
161  public Gyoto::Hook::Teller
162 {
164 
165  private:
166  double mass_;
168 
177 
178  protected:
179  double delta_min_;
180  double delta_max_;
181 
195 
196  bool keplerian_;
197 
198  protected:
205  void coordKind(int coordkind);
206 
207 
208  public:
210 
211  int getRefCount();
212 
213  // Constructors - Destructor
214  // -------------------------
215  Generic();
216  Generic(const int coordkind, const std::string &name);
217  Generic(Generic const &o);
218  virtual ~Generic() ;
219 
220  // Mutators / assignment
221  // ---------------------
222  virtual Generic * clone() const ;
223 
224  virtual void mass(const double);
225  virtual void mass(const double, const std::string &unit);
226 
227  // Accessors
228 
229  int coordKind() const;
230 
231  double mass() const;
232  double mass(const std::string &unit) const;
233 
239  double unitLength() const ;
240  double unitLength(const std::string &unit) const ;
241 
247  virtual double getRmb() const;
248 
254  virtual double getRms() const;
255 
261  virtual double getSpecificAngularMomentum(double rr) const;
262 
268  virtual double getPotential(double const pos[4], double l_cst) const;
269 
273  double deltaMin() const;
274 
278  void deltaMin(double h1);
279 
283  double deltaMax() const;
284 
295  virtual double deltaMax(double const pos[8], double delta_max_external) const;
296 
300  void deltaMax(double h1);
301 
302  double deltaMaxOverR() const;
303  void deltaMaxOverR(double t);
304 
305  bool keplerian() const;
306  void keplerian(bool);
307 
308  virtual void cartesianVelocity(double const coord[8], double vel[3]);
310 
316  virtual double SysPrimeToTdot(const double coord[4], const double v[3]) const;
318 
339  virtual void circularVelocity(double const pos[4], double vel[4],
340  double dir=1.) const ;
341 
353  virtual void zamoVelocity(double const pos[4], double vel[4]) const ;
354 
365  virtual void nullifyCoord(double coord[8]) const;
367 
378  virtual void nullifyCoord(double coord[8], double& tdot2) const;
380 
391  virtual void normalizeFourVel(double coord[8]) const;
392 
403  virtual void normalizeFourVel(double const pos[4], double fourvel[4]) const;
404 
405 
414  virtual double ScalarProd(const double pos[4],
415  const double u1[4], const double u2[4]) const;
416 
424  double norm(const double pos[4],
425  const double u1[4]) const;
426 
428  void multiplyFourVect(double vect[4], double a) const;
429 
431  void addFourVect(double u1[4], double const u2[4]) const;
432 
434  void projectFourVect(double const pos[4], double u1[4], double const u2[4]) const;
435 
443  void dualOneForm(double const IN_ARRAY1_1[4], double const IN_ARRAY1_2[4], double ARGOUT_ARRAY1[4]) const ;
444 
455  virtual void observerTetrad(obskind_t obskind,
456  double const pos[4], double fourvel[4],
457  double screen1[4], double screen2[4],
458  double screen3[4]) const ;
459 
469  virtual void observerTetrad(double const pos[4], double fourvel[4],
470  double screen1[4], double screen2[4],
471  double screen3[4]) const ;
472 
485  void GramSchmidt(double const pos[4], double u0[4],
486  double u1[4], double u2[4], double u3[4]) const;
487  // Outputs
488 
499  virtual double gmunu(double const x[4], int mu, int nu) const;
500 
510  // Keep argument names for swig!
511  virtual void gmunu(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY1[4]) const;
512 
523  virtual double gmunu_up(double const x[4], int mu, int nu) const;
524 
530  // Keep argument names for swig!
531  virtual void gmunu_up(double ARGOUT_ARRAY2[4][4], const double IN_ARRAY1[4]) const;
532 
540  // Keep argument names for swig!
541  virtual void jacobian(double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const;
542 
546  // Keep argument names for swig!
547  virtual void gmunu_up_and_jacobian(double ARGOUT_ARRAY2[4][4], double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const;
548 
553  virtual void computeNBeta(const double coord[4],double &NN,double beta[3]) const;
554 
562  virtual double christoffel(const double coord[4],
563  const int alpha, const int mu, const int nu) const;
564 
574  virtual int christoffel(double dst[4][4][4], const double coord[4]) const ;
575 
576 
577 
581  virtual int myrk4(Worldline * line, state_t const &coord, double h, state_t &res) const;
583  virtual int myrk4(Worldline * line, const double coord[8], double h, double res[8]) const = delete;
584 
588  virtual int myrk4_adaptive(Gyoto::Worldline* line, state_t const &coord,
589  double lastnorm, double normref,
590  state_t &coordnew, double h0, double& h1,
591  double deltamax=GYOTO_DEFAULT_DELTA_MAX) const;
593  virtual int myrk4_adaptive(Gyoto::Worldline* line, const double coord[8],
594  double lastnorm, double normref,
595  double coordnew[8], double h0, double& h1,
596  double deltamax=GYOTO_DEFAULT_DELTA_MAX) const = delete;
597 
598 
609  virtual int isStopCondition(double const coord[8]) const;
610 
614  virtual int diff(state_t const &x, state_t &dxdt, double mass) const ;
616  virtual int diff(state_t const &x, state_t &dxdt) const = delete;
617  virtual int diff(const double y[8], double res[8]) const = delete ;
618 
622  virtual int diff31(state_t const &x, state_t &dxdt, double mass) const ;
623 
627  virtual void setParticleProperties(Gyoto::Worldline* line,
628  double const coord[8]) const;
629 
630 
631 };
632 
633 #endif
Astronomical objects (light emitters)
Gyoto ubiquitous macros and typedefs.
Tellers tell Listeners when they mutate.
Introspectable objects.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
Gyoto registers.
Reference-counting pointers.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
Listen to me and I'll warn you when I change.
Definition: GyotoHooks.h:82
Base class for metrics.
Definition: GyotoMetric.h:162
virtual double SysPrimeToTdot(const double coord[4], const double v[3]) const
Compute tdot as a function of dr/dt, dtheta/dt and dphi/dt. Everything is in geometrical units.
double deltaMax() const
virtual void observerTetrad(obskind_t obskind, double const pos[4], double fourvel[4], double screen1[4], double screen2[4], double screen3[4]) const
Computes the orthonormal local tetrad of the observer.
virtual Generic * clone() const
Virtual copy constructor.
virtual void zamoVelocity(double const pos[4], double vel[4]) const
Yield ZAMO velocity at a given position.
void dualOneForm(double const IN_ARRAY1_1[4], double const IN_ARRAY1_2[4], double ARGOUT_ARRAY1[4]) const
Computes dual 1-form Compute the dual 1-form of 4-vector.
bool keplerian_
1 if circularVelocity should return the Newtonian Keplerian velocity, in r^-3/2
Definition: GyotoMetric.h:196
bool keplerian() const
Get keplerian_.
double norm(const double pos[4], const double u1[4]) const
Scalar product.
virtual double getRms() const
double delta_max_
Maximum integration step for the adaptive integrator.
Definition: GyotoMetric.h:180
double delta_min_
Minimum integration step for the adaptive integrator.
Definition: GyotoMetric.h:179
virtual double christoffel(const double coord[4], const int alpha, const int mu, const int nu) const
Chistoffel symbol.
void addFourVect(double u1[4], double const u2[4]) const
add second vector to first one
virtual void computeNBeta(const double coord[4], double &NN, double beta[3]) const
Computes lapse scalar and shift vector at coord.
virtual int isStopCondition(double const coord[8]) const
Check whether integration should stop.
int coordkind_
Kind of coordinates (cartesian-like, spherical-like, unspecified)
Definition: GyotoMetric.h:167
virtual void setParticleProperties(Gyoto::Worldline *line, double const coord[8]) const
Set Metric-specific constants of motion. Used e.g. in KerrBL.
void multiplyFourVect(double vect[4], double a) const
multiply vector by scalar
virtual double getSpecificAngularMomentum(double rr) const
virtual double gmunu(double const x[4], int mu, int nu) const
Metric coefficients.
void projectFourVect(double const pos[4], double u1[4], double const u2[4]) const
project u1 orthogonally to u2 at pos
double deltaMin() const
double delta_max_over_r_
Numerical tuning parameter.
Definition: GyotoMetric.h:194
virtual int diff31(state_t const &x, state_t &dxdt, double mass) const
F function such as dx/dt=F(x,cst) for 3+1 case.
double mass() const
Get mass used in unitLength()
virtual int diff(state_t const &x, state_t &dxdt, double mass) const
F function such as dx/dt=F(x,cst)
virtual double getRmb() const
int __defaultfeatures
Whether some virtual methods are implemented.
Definition: GyotoMetric.h:176
virtual void normalizeFourVel(double coord[8]) const
Normalize fourvelvel to -1.
virtual int myrk4(Worldline *line, state_t const &coord, double h, state_t &res) const
RK4 integrator.
virtual double getPotential(double const pos[4], double l_cst) const
virtual void cartesianVelocity(double const coord[8], double vel[3])
Compute xprime, yprime and zprime from 8-coordinates.
double unitLength() const
M * G / c^2, M is in kg, unitLength in meters.
double deltaMaxOverR() const
Get delta_max_over_r_.
virtual int myrk4_adaptive(Gyoto::Worldline *line, state_t const &coord, double lastnorm, double normref, state_t &coordnew, double h0, double &h1, double deltamax=GYOTO_DEFAULT_DELTA_MAX) const
RK4 integrator with adaptive step.
virtual void gmunu_up_and_jacobian(double ARGOUT_ARRAY2[4][4], double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const
gmunu_up() and jacobian() in one go
virtual double ScalarProd(const double pos[4], const double u1[4], const double u2[4]) const
Scalar product.
virtual double gmunu_up(double const x[4], int mu, int nu) const
Metric contravariant coefficients.
void GramSchmidt(double const pos[4], double u0[4], double u1[4], double u2[4], double u3[4]) const
Apply Gram-Schmidt orthonormalization to a basis.
virtual void nullifyCoord(double coord[8]) const
Set tdot (coord[4]) such that coord is light-like. Everything is in geometrical units.
double mass_
Mass yielding geometrical unit (in kg).
Definition: GyotoMetric.h:166
virtual void jacobian(double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const
Derivatives of the metric covariant coefficients.
int coordKind() const
Get coordinate kind.
virtual void circularVelocity(double const pos[4], double vel[4], double dir=1.) const
Yield circular velocity at a given position.
Object with properties.
Definition: GyotoObject.h:152
Entry in a register (or a full register)
Definition: GyotoRegister.h:117
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:81
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:135
Timelike or null geodesics.
Definition: GyotoWorldline.h:240
SmartPointer< Metric::Generic > Subcontractor(FactoryMessenger *fmp, std::vector< std::string > const &plugins)
Subcontractor template.
Definition: GyotoMetric.h:72
void Register(std::string kind, Gyoto::Metric::Subcontractor_t *scp)
Make a Metric kind known to the Factory.
Register::Entry * Register_
The Metric register.
void initRegister()
Empty the Metric register.
Gyoto::Metric::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugin, int errmode=0)
Query the Metric register.
SmartPointer< Metric::Generic > Subcontractor_t(FactoryMessenger *, std::vector< std::string > const &)
A function to build instances of a specific Metric::Generic sub-class.
Definition: GyotoMetric.h:60
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:44