Gyoto
GyotoAstrobj.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011-2013 Thibaut Paumard, Frederic Vincent
10 
11  This file is part of Gyoto.
12 
13  Gyoto is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  Gyoto is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 
28 #ifndef __GyotoAstrobj_H_
29 #define __GyotoAstrobj_H_
30 
31 #include "GyotoConfig.h"
32 
33 #include <iostream>
34 #include <fstream>
35 #include <iomanip>
36 #include <string>
37 
38 #include <GyotoDefs.h>
39 #include <GyotoSmartPointer.h>
40 #include <GyotoConverters.h>
41 
42 namespace Gyoto{
43  class Photon;
44  namespace Register { class Entry; }
45  namespace Metric { class Generic; }
46  class FactoryMessenger;
47  namespace Astrobj {
48  class Generic;
49  class Properties;
50 
63 
76  SmartPointer<T> ao = new T();
77  ao -> setParameters(fmp);
78  return ao;
79  }
81 
93  int errmode = 1);
95 
96 #if defined GYOTO_USE_XERCES
97 
104 
108  void initRegister();
110 
122  void Register(std::string name, Gyoto::Astrobj::Subcontractor_t* scp);
124 #endif
125  }
126 }
127 
188  friend class Gyoto::SmartPointer<Gyoto::Astrobj::Generic>;
189 
190 
191  // Data :
192  // -----
193  protected:
194 
198  SmartPointer<Gyoto::Metric::Generic> gg_;
199 
200 
214  double rmax_;
215 
224  int rmax_set_;
225 
230  const std::string kind_;
231 
233 
234  // Constructors - Destructor
235  // -------------------------
236  public:
240  Generic();
241 
245  Generic(double radmax);
246 
250  Generic(std::string kind);
251 
255  Generic(const Generic& ) ;
256 
273  virtual Generic* clone() const = 0 ;
274 
275  virtual ~Generic() ;
276 
277  // Accessors
278  // ---------
279  public:
283  virtual SmartPointer<Metric::Generic> getMetric() const;
284 
288  virtual void setMetric(SmartPointer<Metric::Generic>) ;
289 
301  virtual double getRmax();
302 
309  virtual double getRmax(std::string unit);
310 
311  const std::string getKind() const;
312 
320  virtual void setRmax(double val);
321 
329  virtual void setRmax(double val, std::string unit);
330 
336  virtual void unsetRmax() ;
337 
343  void setFlag_radtransf(int flag);
345 
348  int getFlag_radtransf() const ;
350 
359 
360  //XML I/O
361  public:
388  virtual int setParameter(std::string name,
389  std::string content,
390  std::string unit) ;
391 
392 #ifdef GYOTO_USE_XERCES
393 
400  virtual void fillElement(FactoryMessenger *fmp) const ;
401 
423  virtual void setParameters(FactoryMessenger *fmp);
424 
425 
426 #endif
427 
428  // Outputs
429  // -------
430  public:
462  virtual int Impact(Gyoto::Photon* ph, size_t index,
463  Astrobj::Properties *data=NULL) = 0 ;
465 
478  virtual void processHitQuantities(Photon* ph, double* coord_ph_hit,
479  double* coord_obj_hit, double dt,
480  Astrobj::Properties* data) const;
481 
531  virtual double emission(double nu_em, double dsem, double coord_ph[8],
532  double coord_obj[8]=NULL)
533  const ;
534 
557  virtual void emission(double Inu[], double nu_em[], size_t nbnu,
558  double dsem, double coord_ph[8],
559  double coord_obj[8]=NULL) const ;
560 
572  virtual double integrateEmission(double nu1, double nu2, double dsem,
573  double c_ph[8], double c_obj[8]=NULL) const;
575 
581  virtual void integrateEmission(double * I, double const * boundaries,
582  size_t const * chaninds, size_t nbnu,
583  double dsem, double *cph, double *co) const;
585 
595  virtual double transmission(double nuem, double dsem, double coord[8]) const ;
597 
598 };
599 
629  friend class Gyoto::SmartPointer<Gyoto::Astrobj::Properties>;
630  public:
631  double *intensity;
632  double *time;
633 
639  double *distance;
640 
644  double * first_dmin;
645 
651  int first_dmin_found;
652 
657  double *redshift;
658 
662  double *spectrum;
663 
669  double *binspectrum;
670 
675  int offset;
676 
680  double * impactcoords;
681 
686  double *user1;
687 
692  double *user2;
693 
698  double *user3;
699 
704  double *user4;
705 
710  double *user5;
711 # ifdef HAVE_UDUNITS
712 
715  Gyoto::SmartPointer<Gyoto::Units::Converter> intensity_converter_ ;
719  Gyoto::SmartPointer<Gyoto::Units::Converter> spectrum_converter_ ;
723  Gyoto::SmartPointer<Gyoto::Units::Converter> binspectrum_converter_ ;
724 # endif
725  public:
726  Properties();
727  Properties (double*, double*);
728 
740  void init(size_t nbnuobs=0);
741 
748  Properties operator++();
749 # ifdef HAVE_UDUNITS
750  void setIntensityConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
752  void setIntensityConverter(std::string);
754  void setSpectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
756  void setSpectrumConverter(std::string);
758  void setBinSpectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
760  void setBinSpectrumConverter(std::string);
762 # endif
763 };
764 
765 #endif
int rmax_set_
Never recompute rmax: it was externally set.
Definition: GyotoAstrobj.h:224
int flag_radtransf_
1 if radiative transfer inside Astrobj, else 0
Definition: GyotoAstrobj.h:232
virtual double integrateEmission(double nu1, double nu2, double dsem, double c_ph[8], double c_obj[8]=NULL) const
∫ν1ν2 Iν dν (or jν)
virtual void processHitQuantities(Photon *ph, double *coord_ph_hit, double *coord_obj_hit, double dt, Astrobj::Properties *data) const
Fills Astrobj::Properties.
void setFlag_radtransf(int flag)
Set whether the object is optically thin.
A null geodesic transporting light.
Definition: GyotoPhoton.h:51
Base class for metrics.
Definition: GyotoMetric.h:142
Reference-counting pointers.
int getFlag_radtransf() const
Query whether object is optically thin.
void Register(std::string name, Gyoto::Astrobj::Subcontractor_t *scp)
Make an Astrobj kind known to the Factory.
virtual double emission(double nu_em, double dsem, double coord_ph[8], double coord_obj[8]=NULL) const
Specific intensity Iν
virtual void unsetRmax()
Set rmax_set_ to 0.
SmartPointer< Astrobj::Generic > Subcontractor(FactoryMessenger *fmp)
A template for Subcontractor_t functions.
Definition: GyotoAstrobj.h:75
virtual void setMetric(SmartPointer< Metric::Generic >)
Set the Metric Generic::gg_.
SmartPointer< Gyoto::Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoAstrobj.h:198
virtual void fillElement(FactoryMessenger *fmp) const
Fill XML section.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:91
void init(char const *pluglist=NULL)
Initialise the various registers.
virtual double transmission(double nuem, double dsem, double coord[8]) const
Transmission: exp( αν * dsem )
const std::string kind_
Kind of object (e.g. "Star"...)
Definition: GyotoAstrobj.h:230
double rmax_
Maximum distance to the center of the coordinate system [geometrical units].
Definition: GyotoAstrobj.h:214
Gyoto ubiquitous macros and typedefs.
Compile-time configuration.
Gyoto::Register::Entry * Register_
The Astrobj register.
void initRegister()
Empty the Astrobj register.
virtual void setParameters(FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
unsigned int Quantity_t
Type for observabke quantities.
Definition: GyotoDefs.h:72
SmartPointer< Gyoto::Astrobj::Generic > Subcontractor_t(Gyoto::FactoryMessenger *)
A function to build instances of a specific Astrobj::Generic sub-class.
Definition: GyotoAstrobj.h:61
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
virtual double getRmax()
Get maximal distance from center of coordinate system.
const std::string getKind() const
Get the kind of the Astrobj (e.g. "Star")
virtual SmartPointer< Metric::Generic > getMetric() const
Get the Metric Generic::gg_.
virtual int Impact(Gyoto::Photon *ph, size_t index, Astrobj::Properties *data=NULL)=0
Does a photon at these coordinates impact the object?
GYOTO converters.
virtual Generic * clone() const =0
Cloner.
Base class for astronomical object.
Definition: GyotoAstrobj.h:187
virtual Quantity_t getDefaultQuantities()
Which quantities to compute if know was requested.
virtual void setRmax(double val)
Set maximal distance from center of coordinate system.
Gyoto::Astrobj::Subcontractor_t * getSubcontractor(std::string name, int errmode=1)
Query the Astrobj register.
Observable properties of an Astronomical object.
Definition: GyotoAstrobj.h:628
virtual int setParameter(std::string name, std::string content, std::string unit)
Set parameter by name.
Entry in a register (or a full register)
Definition: GyotoRegister.h:95