Gyoto
GyotoMetric.h
Go to the documentation of this file.
1 
10 /*
11  Copyright 2011, 2013 Frederic Vincent, Thibaut Paumard
12 
13  This file is part of Gyoto.
14 
15  Gyoto is free software: you can redistribute it and/or modify
16  it under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  Gyoto is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
27  */
28 
29 #ifndef __GyotoMetric_H_
30 #define __GyotoMetric_H_
31 
32 #include <iostream>
33 #include <fstream>
34 #include <string>
35 
36 #include <GyotoSmartPointer.h>
37 #include <GyotoAstrobj.h>
38 #include <GyotoRegister.h>
39 #include <GyotoHooks.h>
40 
41 namespace Gyoto {
42  namespace Metric {
43  class Generic;
44 
46 
55 
56 
65  template<typename T> SmartPointer<Metric::Generic> Subcontractor
67  SmartPointer<T> gg = new T();
68  gg -> setParameters(fmp);
69  return gg;
70  }
71 
73 
85  int errmode=0);
86 
88 
93  extern Register::Entry * Register_;
94 
96 
107  void Register(std::string kind, Gyoto::Metric::Subcontractor_t* scp);
108 
110 
114  void initRegister();
115 
116  }
117 
118  /* Documented elswhere */
119  class Worldline;
120 }
121 
143 : protected Gyoto::SmartPointee,
144  public Gyoto::Hook::Teller
145 {
146  friend class Gyoto::SmartPointer<Gyoto::Metric::Generic>;
147 
148  private:
149  std::string kind_;
150  double mass_;
152 
153  public:
154  const std::string getKind() const;
155  void setKind(const std::string);
156  int getRefCount();
157 
158  // Constructors - Destructor
159  // -------------------------
160  //Metric(const Metric& ) ; ///< Copy constructor
161  Generic();
162  Generic(const int coordkind);
163  Generic(const double mass, const int coordkind);
165 
166  virtual ~Generic() ;
167 
168  // Mutators / assignment
169  // ---------------------
170  virtual Generic * clone() const ;
171 
172  void setMass(const double);
173  void setMass(const double, const std::string &unit);
174 
175  // Accessors
176 
177  int getCoordKind() const;
178  void setCoordKind(int coordkind);
179 
180  double getMass() const;
181  double getMass(const std::string &unit) const;
182 
188  double unitLength() const ;
189  double unitLength(const std::string &unit) const ;
190 
191 
192  virtual void cartesianVelocity(double const coord[8], double vel[3]);
194 
200  virtual double SysPrimeToTdot(const double coord[4], const double v[3]) const;
202 
211  virtual void circularVelocity(double const pos[4], double vel[4],
212  double dir=1.) const ;
213 
224  virtual void nullifyCoord(double coord[8]) const;
226 
237  virtual void nullifyCoord(double coord[8], double& tdot2) const;
239 
240 
249  virtual double ScalarProd(const double pos[4],
250  const double u1[4], const double u2[4]) const;
251 
252  virtual double Norm3D(double* pos) const;
253 
254 
277  virtual void setParameter(std::string name,
278  std::string content,
279  std::string unit);
280 
281  // Outputs
282 #ifdef GYOTO_USE_XERCES
283 
305  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
306 
313  virtual void fillElement(FactoryMessenger *fmp) ;
314 
318  void processGenericParameters(Gyoto::FactoryMessenger *fmp) ;
319 #endif
320 
329  virtual double gmunu(const double * x,
330  int mu, int nu) const
331  = 0 ;
332 
340  virtual double christoffel(const double coord[8],
341  const int alpha, const int mu, const int nu) const = 0;
342 
346  virtual int myrk4(Worldline * line, const double coord[8], double h, double res[8]) const;
347 
351  virtual int myrk4_adaptive(Gyoto::Worldline* line, const double coord[8],
352  double lastnorm, double normref,
353  double coordnew[8], double h0, double& h1) const;
354 
365  virtual int isStopCondition(double const * const coord) const;
366 
370  virtual int diff(const double y[8], double res[8]) const ;
371 
375  virtual void setParticleProperties(Gyoto::Worldline* line,
376  const double * coord) const;
377 
378 
379 };
380 
381 #endif
const std::string getKind() const
Get kind_.
double getMass() const
Get mass used in unitLength()
virtual void nullifyCoord(double coord[8]) const
Set tdot (coord[4]) such that coord is light-like. Everything is in geometrical units.
int coordkind_
Kind of coordinates (cartesian-like, spherical-like, unspecified)
Definition: GyotoMetric.h:151
virtual void circularVelocity(double const pos[4], double vel[4], double dir=1.) const
Yield circular valocity at a given position (projected on equatorial plane).
Gyoto registers.
Astronomical objects (light emitters)
int getCoordKind() const
Get coordinate kind.
Register::Entry * Register_
The Metric register.
virtual Generic * clone() const
Virtual copy constructor.
Tellers tell Listeners when they mutate.
virtual void setParticleProperties(Gyoto::Worldline *line, const double *coord) const
Set Metric-specific constants of motion. Used e.g. in KerrBL.
Base class for metrics.
Definition: GyotoMetric.h:142
Reference-counting pointers.
Gyoto::Metric::Subcontractor_t * getSubcontractor(std::string name, int errmode=0)
Query the Metric register.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:91
virtual double ScalarProd(const double pos[4], const double u1[4], const double u2[4]) const
Scalar product.
double unitLength() const
M * G / c^2, M is in kg, unitLength in meters.
virtual void fillElement(FactoryMessenger *fmp)
called from Factory
virtual double christoffel(const double coord[8], const int alpha, const int mu, const int nu) const =0
Chistoffel symbol.
void setCoordKind(int coordkind)
Set coordinate kind.
std::string kind_
Metric kind name (e.g. &quot;KerrBL&quot;)
Definition: GyotoMetric.h:149
SmartPointer< Metric::Generic > Subcontractor_t(FactoryMessenger *)
A function to build instances of a specific Metric::Generic sub-class.
Definition: GyotoMetric.h:54
virtual int isStopCondition(double const *const coord) const
Check whether integration should stop.
void initRegister()
Empty the Metric register.
virtual int myrk4_adaptive(Gyoto::Worldline *line, const double coord[8], double lastnorm, double normref, double coordnew[8], double h0, double &h1) const
RK4 integrator with adaptive step.
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:66
void setKind(const std::string)
Set kind_.
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
virtual double Norm3D(double *pos) const
not clear
void setMass(const double)
Set mass used in unitLength()
double mass_
Mass yielding geometrical unit (in kg).
Definition: GyotoMetric.h:150
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...
virtual int myrk4(Worldline *line, const double coord[8], double h, double res[8]) const
RK4 integrator.
virtual void setParameter(std::string name, std::string content, std::string unit)
Set parameter by name.
virtual void setParameters(Gyoto::FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
void processGenericParameters(Gyoto::FactoryMessenger *fmp)
Process generic XML parameters.
Listen to me and I&#39;ll warn you when I change.
Definition: GyotoHooks.h:82
virtual double gmunu(const double *x, int mu, int nu) const =0
Metric coefficients.
virtual int diff(const double y[8], double res[8]) const
F function such as dy/dtau=F(y,cst)
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:95