Gyoto
GyotoWorldline.h
Go to the documentation of this file.
1 
6 /*
7  Copyright 2011 Frederic Vincent, Thibaut Paumard
8 
9  This file is part of Gyoto.
10 
11  Gyoto is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  Gyoto is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef __GyotoWorldline_H_
26 #define __GyotoWorldline_H_
27 
28 #include <iostream>
29 #include <fstream>
30 #include <string>
31 #include <GyotoDefs.h>
32 
33 namespace Gyoto {
34  class Worldline;
35 }
36 
37 #include <GyotoSmartPointer.h>
38 #include <GyotoMetric.h>
40 #include <GyotoScreen.h>
41 
48 
49  // Data :
50  // -----
51  protected:
53  double* x0_;
54  double* x1_;
55  double* x2_;
56  double* x3_;
57  double* x0dot_;
58  double* x1dot_;
59  double* x2dot_;
60  double* x3dot_;
61  size_t x_size_;
62  size_t imin_;
63  size_t i0_;
64  size_t imax_;
65  double delta_;
66  double tlim_;
67  double * cst_;
68  size_t cst_n_;
69 
70  // Constructors - Destructor
71  // -------------------------
72  public:
73  Worldline() ;
74  Worldline(const size_t sz) ;
75 
76  Worldline(const Worldline& ) ;
77 
78  Worldline(Worldline* orig, size_t i0, int dir, double step_max) ;
80 
82  //Worldline(FILE *) ;
83 
84  virtual ~Worldline() ;
85 
86  int getImin() const;
87  int getImax() const;
88  int getI0() const;
89 
90  virtual double getMass() const = 0;
93  void setInitCoord(const double coord[8], int dir = 0);
94  void reset() ;
95 
96  virtual std::string className() const ;
97  virtual std::string className_l() const ;
98 
99  // Memory management
100  // -----------------
101  protected:
105  void xAllocate();
106 
110  void xAllocate(size_t size);
111 
123  size_t xExpand(int dir);
124 
125  // Mutators / assignment
126  // ---------------------
127  public:
129  void operator=(const Worldline&) ;
130  void setDelta(const double delta);
131  double getTlim() const ;
132  void setTlim(double tlim);
133 
138  double const * getCst() const ;
139 
142  void setCst(double const * cst, size_t const ncsts) ;
143 
157  const double coord[8],
158  const int dir) ;
160 
161  void getInitialCoord(double dest[8]) const;
162  void getCoord(size_t index, double dest[8]) const;
163  void getCartesianPos(size_t index, double dest[4]) const;
164 
165  void xFill(double tlim) ;
166 
167  // Accessors
168  // ---------
169  public:
170  //virtual void position(double t, double* res) = 0 ;
171  int get_nelements() const;
172  void get_t(double *dest) const;
173 
190  void getCartesian(double const * const dates, size_t const n_dates,
191  double * const x, double * const y,
192  double * const z, double * const xprime=NULL,
193  double * const yprime=NULL, double * const zprime=NULL) ;
194 
195  void get_xyz(double* x, double *y, double *z) const;
196 
215  void getCoord(double const * const dates, size_t const n_dates,
216  double * const x1dest,
217  double * const x2dest, double * const x3dest,
218  double * const x0dot=NULL, double * const x1dot=NULL,
219  double * const x2dot=NULL, double * const x3dot=NULL) ;
220 
225  void getCoord(double *x0, double *x1, double *x2, double *x3) const ;
226  void getSkyPos(SmartPointer<Screen> screen, double *dalpha, double *ddellta, double *dD) const;
227  void get_dot(double *x0dot, double *x1dot, double *x2dot, double *x3dot) const ;
228  void get_prime(double *x1prime, double *x2prime, double *x3prime) const ;
229 
230  // Outputs
231  // -------
232  public:
233  //virtual void sauve(FILE *) const ; ///< Save in a file
234  void save_txyz(char * fichierxyz) const ;
235  void save_txyz(char* const filename, double const t1, double const mass_sun,
236  double const distance_kpc, std::string const unit, SmartPointer<Screen> sc = NULL);
237 
239  friend std::ostream& operator<<(std::ostream& , const Worldline& ) ;
240 
241 
242 };
243 
244 #endif