Gyoto
GyotoMetric.h
Go to the documentation of this file.
1 
12 /*
13  Copyright 2011-2016, 2018-2020, 2022, 2024 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 
71  template<typename T> SmartPointer<Metric::Generic> Subcontractor
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 
105  std::vector<std::string> &plugin,
106  int errmode=0);
107 
109 
114  extern Register::Entry * Register_;
115 
117 
128  void Register(std::string kind, Gyoto::Metric::Subcontractor_t* scp);
129 
131 
135  void initRegister();
136 
137  }
138 
139  /* Documented elswhere */
140  class Worldline;
141 }
142 
164 : public Gyoto::SmartPointee,
165  public Gyoto::Object,
166  public Gyoto::Hook::Teller
167 {
169 
170  public:
172  static std::vector<std::string> registeredPluginsSlashKinds() ;
173 
174  private:
175  double mass_;
177 
186 
187  protected:
188  double delta_min_;
189  double delta_max_;
190 
204 
205  bool keplerian_;
206 
207  protected:
214  void coordKind(int coordkind);
215 
216 
217  public:
218  GYOTO_OBJECT;
219 
220  int getRefCount();
221 
222  // Constructors - Destructor
223  // -------------------------
224  Generic();
225  Generic(const int coordkind, const std::string &name);
226  Generic(Generic const &o);
227  virtual ~Generic() ;
228 
229  // Mutators / assignment
230  // ---------------------
231  virtual Generic * clone() const ;
232 
233  virtual void mass(const double);
234  virtual void mass(const double, const std::string &unit);
235 
236  // Accessors
237 
238  int coordKind() const;
239 
240  double mass() const;
241  double mass(const std::string &unit) const;
242 
248  double unitLength() const ;
249  double unitLength(const std::string &unit) const ;
250 
256  virtual double getRmb() const;
257 
263  virtual double getRms() const;
264 
270  virtual double getSpecificAngularMomentum(double rr) const;
278  virtual double getPotential(double const pos[4], double l_cst) const;
279 
283  double deltaMin() const;
284 
288  void deltaMin(double h1);
289 
293  double deltaMax() const;
294 
305  virtual double deltaMax(double const pos[8], double delta_max_external) const;
306 
310  void deltaMax(double h1);
311 
312  double deltaMaxOverR() const;
313  void deltaMaxOverR(double t);
314 
315  bool keplerian() const;
316  void keplerian(bool);
317 
318  virtual void cartesianVelocity(double const coord[8], double vel[3]);
320 
326  virtual double SysPrimeToTdot(const double coord[4], const double v[3]) const;
328 
349  virtual void circularVelocity(double const pos[4], double vel[4],
350  double dir=1.) const ;
351 
363  virtual void zamoVelocity(double const pos[4], double vel[4]) const ;
364 
375  virtual void nullifyCoord(double coord[8]) const;
377 
388  virtual void nullifyCoord(double coord[8], double& tdot2) const;
390 
401  virtual void normalizeFourVel(double coord[8]) const;
402 
413  virtual void normalizeFourVel(double const pos[4], double fourvel[4]) const;
414 
415 
424  virtual double ScalarProd(const double pos[4],
425  const double u1[4], const double u2[4]) const;
426 
434  double norm(const double pos[4],
435  const double u1[4]) const;
436 
438  void multiplyFourVect(double vect[4], double a) const;
439 
441  void addFourVect(double u1[4], double const u2[4]) const;
442 
444  void projectFourVect(double const pos[4], double u1[4], double const u2[4]) const;
445 
453  void dualOneForm(double const IN_ARRAY1_1[4], double const IN_ARRAY1_2[4], double ARGOUT_ARRAY1[4]) const ;
454 
465  virtual void observerTetrad(obskind_t obskind,
466  double const pos[4], double fourvel[4],
467  double screen1[4], double screen2[4],
468  double screen3[4]) const ;
469 
479  virtual void observerTetrad(double const pos[4], double fourvel[4],
480  double screen1[4], double screen2[4],
481  double screen3[4]) const ;
482 
495  void GramSchmidt(double const pos[4], double u0[4],
496  double u1[4], double u2[4], double u3[4]) const;
497  // Outputs
498 
509  virtual double gmunu(double const x[4], int mu, int nu) const;
510 
520  // Keep argument names for swig!
521  virtual void gmunu(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY1[4]) const;
522 
533  virtual double gmunu_up(double const x[4], int mu, int nu) const;
534 
540  // Keep argument names for swig!
541  virtual void gmunu_up(double ARGOUT_ARRAY2[4][4], const double IN_ARRAY1[4]) const;
542 
550  // Keep argument names for swig!
551  virtual void jacobian(double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const;
552 
556  // Keep argument names for swig!
557  virtual void gmunu_up_and_jacobian(double ARGOUT_ARRAY2[4][4], double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const;
558 
563  virtual void computeNBeta(const double coord[4],double &NN,double beta[3]) const;
564 
572  virtual double christoffel(const double coord[4],
573  const int alpha, const int mu, const int nu) const;
574 
584  virtual int christoffel(double dst[4][4][4], const double coord[4]) const ;
585 
586 
587 
591  virtual int myrk4(Worldline * line, state_t const &coord, double h, state_t &res) const;
593  virtual int myrk4(Worldline * line, const double coord[8], double h, double res[8]) const = delete;
594 
598  virtual int myrk4_adaptive(Gyoto::Worldline* line, state_t const &coord,
599  double lastnorm, double normref,
600  state_t &coordnew, double h0, double& h1,
601  double deltamax=GYOTO_DEFAULT_DELTA_MAX) const;
603  virtual int myrk4_adaptive(Gyoto::Worldline* line, const double coord[8],
604  double lastnorm, double normref,
605  double coordnew[8], double h0, double& h1,
606  double deltamax=GYOTO_DEFAULT_DELTA_MAX) const = delete;
607 
608 
619  virtual int isStopCondition(double const coord[8]) const;
620 
624  virtual int diff(state_t const &x, state_t &dxdt, double mass) const ;
626  virtual int diff(state_t const &x, state_t &dxdt) const = delete;
627  virtual int diff(const double y[8], double res[8]) const = delete ;
628 
632  virtual int diff31(state_t const &x, state_t &dxdt, double mass) const ;
633 
637  virtual void setParticleProperties(Gyoto::Worldline* line,
638  double const coord[8]) const;
639 
640 
641 };
642 
643 #endif
void multiplyFourVect(double vect[4], double a) const
multiply vector by scalar
virtual Generic * clone() const
Virtual copy constructor.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
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
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
int coordkind_
Kind of coordinates (cartesian-like, spherical-like, unspecified)
Definition: GyotoMetric.h:176
Gyoto registers.
double mass() const
Get mass used in unitLength()
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.
Astronomical objects (light emitters)
Register::Entry * Register_
The Metric register.
Tellers tell Listeners when they mutate.
double delta_min_
Minimum integration step for the adaptive integrator.
Definition: GyotoMetric.h:188
virtual int diff(state_t const &x, state_t &dxdt, double mass) const
F function such as dx/dt=F(x,cst)
Base class for metrics.
Definition: GyotoMetric.h:163
Reference-counting pointers.
bool keplerian() const
Get keplerian_.
virtual void zamoVelocity(double const pos[4], double vel[4]) const
Yield ZAMO velocity at a given position.
int coordKind() const
Get coordinate kind.
double delta_max_
Maximum integration step for the adaptive integrator.
Definition: GyotoMetric.h:189
void projectFourVect(double const pos[4], double u1[4], double const u2[4]) const
project u1 orthogonally to u2 at pos
virtual void nullifyCoord(double coord[8]) const
Set tdot (coord[4]) such that coord is light-like. Everything is in geometrical units.
void addFourVect(double u1[4], double const u2[4]) const
add second vector to first one
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
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.
virtual int isStopCondition(double const coord[8]) const
Check whether integration should stop.
virtual double christoffel(const double coord[4], const int alpha, const int mu, const int nu) const
Chistoffel symbol.
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 double getSpecificAngularMomentum(double rr) const
bool keplerian_
1 if circularVelocity should return the Newtonian Keplerian velocity, in r^-3/2
Definition: GyotoMetric.h:205
virtual void normalizeFourVel(double coord[8]) const
Normalize fourvelvel to -1.
virtual double gmunu_up(double const x[4], int mu, int nu) const
Metric contravariant coefficients.
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 double gmunu(double const x[4], int mu, int nu) const
Metric coefficients.
double norm(const double pos[4], const double u1[4]) const
Scalar product.
Gyoto ubiquitous macros and typedefs.
double deltaMaxOverR() const
Get delta_max_over_r_.
void initRegister()
Empty the Metric register Metric::Register_.
static std::vector< std::string > registeredPluginsSlashKinds()
Get list of "plugins/names" of all registered Metrics.
double delta_max_over_r_
Numerical tuning parameter.
Definition: GyotoMetric.h:203
double deltaMin() const
Introspectable objects.
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...
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:46
virtual double ScalarProd(const double pos[4], const double u1[4], const double u2[4]) const
Scalar product.
Gyoto::Metric::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugin, int errmode=0)
Query the Metric register Metric::Register_.
int __defaultfeatures
Whether some virtual methods are implemented.
Definition: GyotoMetric.h:185
virtual void cartesianVelocity(double const coord[8], double vel[3])
Compute xprime, yprime and zprime from 8-coordinates.
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
virtual int myrk4(Worldline *line, state_t const &coord, double h, state_t &res) const
RK4 integrator.
double mass_
Mass yielding geometrical unit (in kg).
Definition: GyotoMetric.h:175
double unitLength() const
M * G / c^2, M is in kg, unitLength in meters.
virtual void computeNBeta(const double coord[4], double &NN, double beta[3]) const
Computes lapse scalar and shift vector at coord.
Object with properties.
Definition: GyotoObject.h:151
virtual void setParticleProperties(Gyoto::Worldline *line, double const coord[8]) const
Set Metric-specific constants of motion. Used e.g. in KerrBL.
SmartPointer< Metric::Generic > Subcontractor(FactoryMessenger *fmp, std::vector< std::string > const &plugins)
Subcontractor template.
Definition: GyotoMetric.h:72
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.
double deltaMax() const
virtual void jacobian(double ARGOUT_ARRAY3[4][4][4], const double IN_ARRAY1[4]) const
Derivatives of the metric covariant coefficients.
virtual double getPotential(double const pos[4], double l_cst) const
Listen to me and I&#39;ll warn you when I change.
Definition: GyotoHooks.h:82
virtual void circularVelocity(double const pos[4], double vel[4], double dir=1.) const
Yield circular velocity at a given position.
virtual double getRms() const
virtual double getRmb() const
void Register(std::string kind, Gyoto::Metric::Subcontractor_t *scp)
Make a Metric kind known to the Factory.
Entry in a register (or a full register)
Definition: GyotoRegister.h:132