Gyoto
GyotoMetric.h
Go to the documentation of this file.
1 
12 /*
13  Copyright 2011, 2013 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 
38 #include <GyotoSmartPointer.h>
39 #include <GyotoObject.h>
40 #include <GyotoAstrobj.h>
41 #include <GyotoRegister.h>
42 #include <GyotoHooks.h>
43 #include <GyotoDefs.h>
44 
45 namespace Gyoto {
46  namespace Metric {
47  class Generic;
48 
50 
59 
60 
69  template<typename T> SmartPointer<Metric::Generic> Subcontractor
71  SmartPointer<T> gg = new T();
72 #ifdef GYOTO_USE_XERCES
73  if (fmp) gg -> setParameters(fmp);
74 #endif
75  return gg;
76  }
77 
79 
91  int errmode=0);
92 
94 
99  extern Register::Entry * Register_;
100 
102 
113  void Register(std::string kind, Gyoto::Metric::Subcontractor_t* scp);
114 
116 
120  void initRegister();
121 
122  }
123 
124  /* Documented elswhere */
125  class Worldline;
126 }
127 
149 : public Gyoto::SmartPointee,
150  public Gyoto::Object,
151  public Gyoto::Hook::Teller
152 {
153  friend class Gyoto::SmartPointer<Gyoto::Metric::Generic>;
154 
155  private:
156  double mass_;
158 
159  protected:
160  double delta_min_;
161  double delta_max_;
162 
176 
177  bool keplerian_;
178 
179  protected:
186  void kind(const std::string);
187 
194  void coordKind(int coordkind);
195 
196 
197  public:
198  GYOTO_OBJECT;
199 
200  const std::string kind() const;
201  int getRefCount();
202 
203  // Constructors - Destructor
204  // -------------------------
205  Generic(const int coordkind, const std::string &name);
206  Generic(Generic const &o);
207  virtual ~Generic() ;
208 
209  // Mutators / assignment
210  // ---------------------
211  virtual Generic * clone() const ;
212 
213  void mass(const double);
214  void mass(const double, const std::string &unit);
215 
216  // Accessors
217 
218  int coordKind() const;
219 
220  double mass() const;
221  double mass(const std::string &unit) const;
222 
228  double unitLength() const ;
229  double unitLength(const std::string &unit) const ;
230 
236  virtual double getRmb() const;
237 
243  virtual double getRms() const;
244 
250  virtual double getSpecificAngularMomentum(double rr) const;
251 
257  virtual double getPotential(double const pos[4], double l_cst) const;
258 
262  double deltaMin() const;
263 
267  void deltaMin(double h1);
268 
272  double deltaMax() const;
273 
284  virtual double deltaMax(double const pos[8], double delta_max_external) const;
285 
289  void deltaMax(double h1);
290 
291  double deltaMaxOverR() const;
292  void deltaMaxOverR(double t);
293 
294  bool keplerian() const;
295  void keplerian(bool);
296 
297  virtual void cartesianVelocity(double const coord[8], double vel[3]);
299 
305  virtual double SysPrimeToTdot(const double coord[4], const double v[3]) const;
307 
328  virtual void circularVelocity(double const pos[4], double vel[4],
329  double dir=1.) const ;
330 
341  virtual void nullifyCoord(double coord[8]) const;
343 
354  virtual void nullifyCoord(double coord[8], double& tdot2) const;
356 
357 
366  virtual double ScalarProd(const double pos[4],
367  const double u1[4], const double u2[4]) const;
368 
369 
380  virtual void observerTetrad(std::string const obskind,
381  double const pos[4], double fourvel[4],
382  double screen1[4], double screen2[4],
383  double screen3[4]) const ;
384 
385  // Outputs
386 
397  virtual double gmunu(double const x[4], int mu, int nu) const;
398 
408  virtual void gmunu(double g[4][4], double const pos[4]) const;
409 
410 
411 
419  virtual double christoffel(const double coord[4],
420  const int alpha, const int mu, const int nu) const;
421 
431  virtual int christoffel(double dst[4][4][4], const double coord[4]) const ;
432 
433 
434 
438  virtual int myrk4(Worldline * line, const double coord[8], double h, double res[8]) const;
439 
443  virtual int myrk4_adaptive(Gyoto::Worldline* line, const double coord[8],
444  double lastnorm, double normref,
445  double coordnew[8], double h0, double& h1,
446  double deltamax=GYOTO_DEFAULT_DELTA_MAX) const;
447 
458  virtual int isStopCondition(double const coord[8]) const;
459 
463  virtual int diff(const double y[8], double res[8]) const ;
464 
468  virtual void setParticleProperties(Gyoto::Worldline* line,
469  double const coord[8]) const;
470 
471 
472 };
473 
474 #endif
virtual Generic * clone() const
Virtual copy constructor.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:83
int coordkind_
Kind of coordinates (cartesian-like, spherical-like, unspecified)
Definition: GyotoMetric.h:157
Timelike or null geodesics.
Definition: GyotoWorldline.h:219
Gyoto registers.
double mass() const
Get mass used in unitLength()
Astronomical objects (light emitters)
virtual int diff(const double y[8], double res[8]) const
F function such as dy/dtau=F(y,cst)
virtual void observerTetrad(std::string const 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.
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:160
virtual int myrk4(Worldline *line, const double coord[8], double h, double res[8]) const
RK4 integrator.
Base class for metrics.
Definition: GyotoMetric.h:148
Reference-counting pointers.
bool keplerian() const
Get keplerian_.
int coordKind() const
Get coordinate kind.
double delta_max_
Maximum integration step for the adaptive integrator.
Definition: GyotoMetric.h:161
virtual void nullifyCoord(double coord[8]) const
Set tdot (coord[4]) such that coord is light-like. Everything is in geometrical units.
Gyoto::Metric::Subcontractor_t * getSubcontractor(std::string name, int errmode=0)
Query the Metric register.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
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 double getSpecificAngularMomentum(double rr) const
bool keplerian_
1 if circularVelocity should return the Newtonian Keplerian velocity, in r^-3/2
Definition: GyotoMetric.h:177
virtual double gmunu(double const x[4], int mu, int nu) const
Metric coefficients.
Gyoto ubiquitous macros and typedefs.
double deltaMaxOverR() const
Get delta_max_over_r_.
SmartPointer< Metric::Generic > Subcontractor_t(FactoryMessenger *)
A function to build instances of a specific Metric::Generic sub-class.
Definition: GyotoMetric.h:58
void initRegister()
Empty the Metric register.
double delta_max_over_r_
Numerical tuning parameter.
Definition: GyotoMetric.h:175
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:43
virtual double ScalarProd(const double pos[4], const double u1[4], const double u2[4]) const
Scalar product.
virtual void cartesianVelocity(double const coord[8], double vel[3])
Compute xprime, yprime and zprime from 8-coordinates.
SmartPointer< Metric::Generic > Subcontractor(FactoryMessenger *fmp)
Subcontractor template.
Definition: GyotoMetric.h:70
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:78
const std::string kind() const
Get kind_.
double mass_
Mass yielding geometrical unit (in kg).
Definition: GyotoMetric.h:156
double unitLength() const
M * G / c^2, M is in kg, unitLength in meters.
Object with properties.
Definition: GyotoObject.h:136
virtual int myrk4_adaptive(Gyoto::Worldline *line, const double coord[8], double lastnorm, double normref, double coordnew[8], double h0, double &h1, double deltamax=GYOTO_DEFAULT_DELTA_MAX) const
RK4 integrator with adaptive step.
virtual void setParticleProperties(Gyoto::Worldline *line, double const coord[8]) const
Set Metric-specific constants of motion. Used e.g. in KerrBL.
double deltaMax() const
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:92