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 
61  Subcontractor_t(Gyoto::FactoryMessenger*);
63 
75  (FactoryMessenger* fmp) {
76  SmartPointer<T> ao = new T();
77 #ifdef GYOTO_USE_XERCES
78  ao -> setParameters(fmp);
79 #endif
80  return ao;
81  }
83 
95  int errmode = 0);
97 
105 
109  void initRegister();
111 
123  void Register(std::string name, Gyoto::Astrobj::Subcontractor_t* scp);
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  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> metric() const;
284 
288  virtual void metric(SmartPointer<Metric::Generic>) ;
289 
301  virtual double rMax();
302 
309  virtual double rMax(std::string unit);
310 
312 
316  virtual double deltaMax(double coord[8]);
317 
318  const std::string kind() const;
319 
327  virtual void rMax(double val);
328 
336  virtual void rMax(double val, std::string unit);
337 
343  virtual void unsetRmax() ;
344 
350  void opticallyThin(int flag);
352 
355  int opticallyThin() const ;
357 
366 
367  //XML I/O
368  public:
395  virtual int setParameter(std::string name,
396  std::string content,
397  std::string unit) ;
398 
399 #ifdef GYOTO_USE_XERCES
400 
407  virtual void fillElement(FactoryMessenger *fmp) const ;
408 
430  virtual void setParameters(FactoryMessenger *fmp);
431 
432 
433 #endif
434 
435  // Outputs
436  // -------
437  public:
469  virtual int Impact(Gyoto::Photon* ph, size_t index,
470  Astrobj::Properties *data=NULL) = 0 ;
472 
485  virtual void processHitQuantities(Photon* ph, double* coord_ph_hit,
486  double* coord_obj_hit, double dt,
487  Astrobj::Properties* data) const;
488 
538  virtual double emission(double nu_em, double dsem, double coord_ph[8],
539  double coord_obj[8]=NULL)
540  const ;
541 
564  virtual void emission(double Inu[], double nu_em[], size_t nbnu,
565  double dsem, double coord_ph[8],
566  double coord_obj[8]=NULL) const ;
567 
579  virtual double integrateEmission(double nu1, double nu2, double dsem,
580  double c_ph[8], double c_obj[8]=NULL) const;
582 
588  virtual void integrateEmission(double * I, double const * boundaries,
589  size_t const * chaninds, size_t nbnu,
590  double dsem, double *cph, double *co) const;
592 
602  virtual double transmission(double nuem, double dsem, double coord[8]) const ;
604 
605 };
606 
636  friend class Gyoto::SmartPointer<Gyoto::Astrobj::Properties>;
637  public:
638  double *intensity;
639  double *time;
640 
646  double *distance;
647 
651  double * first_dmin;
652 
658  int first_dmin_found;
659 
664  double *redshift;
665 
669  double *spectrum;
670 
676  double *binspectrum;
677 
682  ptrdiff_t offset;
683 
687  double * impactcoords;
688 
693  double *user1;
694 
699  double *user2;
700 
705  double *user3;
706 
711  double *user4;
712 
717  double *user5;
718 # ifdef HAVE_UDUNITS
719 
722  Gyoto::SmartPointer<Gyoto::Units::Converter> intensity_converter_ ;
726  Gyoto::SmartPointer<Gyoto::Units::Converter> spectrum_converter_ ;
730  Gyoto::SmartPointer<Gyoto::Units::Converter> binspectrum_converter_ ;
731 # endif
732  public:
733  Properties();
734  Properties (double*, double*);
735 
747  void init(size_t nbnuobs=0);
748 
755  Properties operator++();
756 
763  Properties operator+=(ptrdiff_t offset);
764 
765 # ifdef HAVE_UDUNITS
766  void intensityConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
768  void intensityConverter(std::string);
770  void spectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
772  void spectrumConverter(std::string);
774  void binSpectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
776  void binSpectrumConverter(std::string);
778 # endif
779 };
780 
781 #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 deltaMax(double coord[8])
Get max step constraint for adaptive integration.
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.
A null geodesic transporting light.
Definition: GyotoPhoton.h:51
Base class for metrics.
Definition: GyotoMetric.h:147
Reference-counting pointers.
std::string kind_
Kind of object (e.g. "Star"...)
Definition: GyotoAstrobj.h:230
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
SmartPointer< Gyoto::Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoAstrobj.h:198
const std::string kind() const
Get the kind of the Astrobj (e.g. "Star")
virtual void fillElement(FactoryMessenger *fmp) const
Fill XML section.
void init(char const *pluglist=NULL)
Initialise the various registers.
virtual double rMax()
Get maximal distance from center of coordinate system.
virtual double transmission(double nuem, double dsem, double coord[8]) const
Transmission: exp( αν * dsem )
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.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:42
virtual void setParameters(FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
unsigned int Quantity_t
Type for observabke quantities.
Definition: GyotoDefs.h:73
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 int Impact(Gyoto::Photon *ph, size_t index, Astrobj::Properties *data=NULL)=0
Does a photon at these coordinates impact the object?
int opticallyThin() const
Query whether object is optically thin.
GYOTO converters.
virtual Generic * clone() const =0
Cloner.
Base class for astronomical object.
Definition: GyotoAstrobj.h:187
virtual SmartPointer< Metric::Generic > metric() const
Get the Metric gg_.
virtual Quantity_t getDefaultQuantities()
Which quantities to compute if know was requested.
Gyoto::Astrobj::Subcontractor_t * getSubcontractor(std::string name, int errmode=0)
Query the Astrobj register.
Observable properties of an Astronomical object.
Definition: GyotoAstrobj.h:635
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:92