Gyoto
GyotoScenery.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011-2015 Thibaut Paumard
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 #ifndef __GyotoScenery_H_
28 #define __GyotoScenery_H_
29 
30 namespace Gyoto{
31  class Scenery;
32 }
33 
34 #include <GyotoDefs.h>
35 #include <GyotoSmartPointer.h>
36 #include <GyotoObject.h>
37 #include <GyotoAstrobj.h>
38 #include <GyotoMetric.h>
39 #include <GyotoScreen.h>
40 #include <GyotoPhoton.h>
41 #include <GyotoConverters.h>
42 
43 #ifdef HAVE_MPI
44 #include "GyotoFactory.h"
45 #include <boost/mpi/environment.hpp>
46 #include <boost/mpi/communicator.hpp>
47 #endif
48 
49 
163 : public Gyoto::SmartPointee,
164  public Gyoto::Object
165 {
166  friend class Gyoto::SmartPointer<Gyoto::Scenery>;
167 
168 
169  // Data :
170  // -----
171  protected:
172 
177 
178 
182  double delta_; // default integration step for the photons
183 
185 
192 
199 
206 
208 
209 # ifdef HAVE_UDUNITS
210  Gyoto::SmartPointer<Gyoto::Units::Converter> intensity_converter_;
213  Gyoto::SmartPointer<Gyoto::Units::Converter> spectrum_converter_;
215  Gyoto::SmartPointer<Gyoto::Units::Converter> binspectrum_converter_;
216 # endif
217 
218  public:
219 # ifdef HAVE_MPI
220 
225  boost::mpi::communicator * mpi_team_;
226 # endif
227  static bool am_worker;
229 
231 
236  void mpiSpawn(int nbchildren);
237 
239  void mpiTerminate ();
240 
242 
245  void mpiClone();
246 
248  enum mpi_tag {give_task, read_scenery, terminate,
249  raytrace, raytrace_done, ready,
250  impactcoords, noimpactcoords};
251 
253  void mpiTask(mpi_tag &tag);
254 
255  // Constructors - Destructor
256  // -------------------------
257  public:
258  GYOTO_OBJECT;
259  GYOTO_WORLDLINE;
260  Scenery();
261  Scenery (const Scenery& o);
262  Scenery * clone() const;
263 
265 
270 
271  ~Scenery();
272 
273  // Mutators / assignment
274  // ---------------------
275  public:
276  // Accessors
277  // ---------
279 
283  SmartPointer<Screen> screen() const;
284 
290 
294 
295 
297  SmartPointer<Photon> clonePhoton(size_t i, size_t j);
298  SmartPointer<Photon> clonePhoton(double a, double d);
299  void updatePhoton();
300 
301  double delta() const ;
302  double delta(const std::string &unit) const ;
303  void delta(double);
304  void delta(double, const std::string &unit);
305 
306  void initCoord(std::vector<double> c);
307  std::vector<double> initCoord() const;
308 
309 
311 
314  void setRequestedQuantities(Quantity_t quant) ;
315 
317 
321  void requestedQuantitiesString(std::string const &squant) ;
322 
325 
327  std::string requestedQuantitiesString() const ;
328 
330 
333  size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const ;
334 
336  double tMin() const ;
338  double tMin(const std::string &unit) const ;
340  void tMin(double);
342  void tMin(double, const std::string &unit);
343 
344  void adaptive (bool mode) ;
345  bool adaptive () const ;
346 
348  void integrator(std::string type);
350  std::string integrator() const;
351 
353  double deltaMin() const;
355  void deltaMin(double h1);
356 
358  double deltaMax() const;
359 
361  void deltaMax(double h1);
362 
364  double deltaMaxOverR() const;
366  void deltaMaxOverR(double t);
367 
369  void absTol(double);
371  double absTol()const;
373  void relTol(double);
375  double relTol()const;
376 
377  void secondary (bool sec) ;
378  bool secondary () const ;
379 
380  void maxiter (size_t miter) ;
381  size_t maxiter () const ;
382 
383  void nThreads(size_t);
384  size_t nThreads() const ;
385 
386  void nProcesses(size_t);
387  size_t nProcesses() const ;
388 
390  void intensityConverter(std::string unit);
392  void spectrumConverter(std::string unit);
394  void binSpectrumConverter(std::string unit);
395 
397 
402 
403  // Worker:
404  public:
406 
455  void rayTrace(
456 #ifdef GYOTO_SWIGIMPORTED
457  Coord2dSet & ij,
458 #else
459  Screen::Coord2dSet & ij,
460 #endif
461  Astrobj::Properties *data,
462  double * impactcoords=NULL);
463 
465 
472  void operator() (size_t i, size_t j, Astrobj::Properties *data,
473  double * impactcoords = NULL, Photon * ph = NULL);
474 
476 
483  void operator() (double alpha, double delta, Astrobj::Properties *data,
484  Photon * ph = NULL);
485 
486 #ifdef GYOTO_USE_XERCES
487  public:
488  // Override fillProperty() to issue InitCoord only if it was set
489  void fillProperty(FactoryMessenger *fmp, Property const &p) const ;
490  // Override fillElement to fill metric, screen and astrobj first
491  void fillElement(FactoryMessenger *fmp) const;
493  static SmartPointer<Scenery> Subcontractor(Gyoto::FactoryMessenger*);
494 
495 #endif
496 
497 };
498 
499 #endif
double deltaMax() const
Passed to ph_.
bool adaptive() const
Get ph_.adaptive_.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:83
void rayTrace(Screen::Coord2dSet &ij, Astrobj::Properties *data, double *impactcoords=NULL)
Perform ray-tracing.
Pointers performing reference counting.
Definition: GyotoProperty.h:41
double relTol() const
Passed to ph_.
void mpiSpawn(int nbchildren)
Spawn gyoto-mpi-worker processes.
double deltaMin() const
Passed to ph_.
Astronomical objects (light emitters)
SmartPointer< Astrobj::Generic > astrobj() const
Get ph_.obj_.
double tMin() const
Get ph_.tmin_.
A null geodesic transporting light.
Definition: GyotoPhoton.h:52
Ray-tracing scene.
Definition: GyotoScenery.h:162
Reference-counting pointers.
void updatePhoton()
Update values in cached Photon.
static SmartPointer< Scenery > Subcontractor(Gyoto::FactoryMessenger *)
Instanciate Scenery from an XML description.
size_t nthreads_
Number of parallel threads to use in rayTrace()
Definition: GyotoScenery.h:205
#define size_t
If not defined in .
Definition: GyotoConfig.h:357
void binSpectrumConverter(std::string unit)
Set Scenery::binspectrum_converter_.
Gyoto::Photon ph_
Template Photon.
Definition: GyotoScenery.h:198
Gyoto::Quantity_t quantities_
Quantities to compute.
Definition: GyotoScenery.h:191
void mpiClone()
Send a copy of self to the mpi workers.
SmartPointer< Photon > clonePhoton() const
Clone the internal Photon.
double absTol() const
Passed to ph_.
void mpiTask(mpi_tag &tag)
Send a tag to workers.
size_t nThreads() const
Get nthreads_;.
double delta() const
Get default step in geometrical units.
void operator()(size_t i, size_t j, Astrobj::Properties *data, double *impactcoords=NULL, Photon *ph=NULL)
Ray-trace a single pixel in Scenery::screen_.
Gyoto::SmartPointer< Gyoto::Units::Converter > binspectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:215
size_t maxiter() const
Get ph_.maxiter_.
Gyoto::SmartPointer< Gyoto::Units::Converter > intensity_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:211
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
int nprocesses_
Number of parallel processes to use in rayTrace()
Definition: GyotoScenery.h:207
Quantity_t getRequestedQuantities() const
Get Scenery::quantities_.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:313
std::string requestedQuantitiesString() const
Get a string representation of Scenery::quantities_.
mpi_tag
Tags that may be sent to communicate with workers using MPI_Send()
Definition: GyotoScenery.h:248
static bool am_worker
True in instance of gyoto-mpi-worker, otherwise false.
Definition: GyotoScenery.h:228
void mpiTerminate()
Terminate gyoto-mpi-worker-processes.
Gyoto::SmartPointer< Gyoto::Units::Converter > spectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:213
Introspectable objects.
void intensityConverter(std::string unit)
Set Scenery::intensity_converter_.
std::string integrator() const
Passed to ph_.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
unsigned int Quantity_t
Type for observabke quantities.
Definition: GyotoDefs.h:73
boost::mpi::communicator * mpi_team_
Team of processes for MPI.
Definition: GyotoScenery.h:225
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:78
void setPropertyConverters(Gyoto::Astrobj::Properties *prop)
Copy converters to Astrobj::Properties instance.
SmartPointer< Screen > screen() const
Get Scenery::screen_.
size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of scalar nature.
SmartPointer< Metric::Generic > metric() const
Get ph_.Worldline::metric_.
Scenery()
Set everything to defaults.
GYOTO converters.
Scenery * clone() const
Cloner.
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:635
Object with properties.
Definition: GyotoObject.h:136
Description of the observer screen.
double deltaMaxOverR() const
Passed to ph_.
double delta_
Definition: GyotoScenery.h:182
bool secondary() const
Get ph_.secondary_.
void setRequestedQuantities(Quantity_t quant)
Set Scenery::quantities_.
SmartPointer< Screen > screen_
Definition: GyotoScenery.h:176
void spectrumConverter(std::string unit)
Set Scenery::spectrum_converter_.
A single light ray.
size_t nProcesses() const
Get nprocesses_;.
Observable properties of an Astronomical object.
Definition: GyotoAstrobj.h:591