Gyoto
GyotoScenery.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011-2016, 2018-2019 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:
220 # ifdef HAVE_MPI
221 
226  boost::mpi::communicator * mpi_team_;
227 # endif
228  static bool am_worker;
230 
232 
252  void mpiSpawn(int nbchildren);
253 
255  void mpiTerminate ();
256 
258 
261  void mpiClone();
262 
264  enum mpi_tag {give_task, read_scenery, terminate,
265  raytrace, raytrace_done, ready,
266  impactcoords, noimpactcoords};
267 
269  void mpiTask(mpi_tag &tag);
270 
272 
276  static void mpiWorker();
277 
278  // Constructors - Destructor
279  // -------------------------
280  public:
282  GYOTO_WORLDLINE;
284  Scenery (const Scenery& o);
285  Scenery * clone() const;
286 
288 
293 
294  ~Scenery();
295 
296  // Mutators / assignment
297  // ---------------------
298  public:
299  // Accessors
300  // ---------
302 
307 
313 
317 
318 
320  SmartPointer<Photon> clonePhoton(size_t i, size_t j);
321  SmartPointer<Photon> clonePhoton(double a, double d);
322  void updatePhoton();
323 
324  double delta() const ;
325  double delta(const std::string &unit) const ;
326  void delta(double);
327  void delta(double, const std::string &unit);
328 
329  void initCoord(std::vector<double> c);
330  std::vector<double> initCoord() const;
331 
332 
334 
338 
340 
344  void requestedQuantitiesString(std::string const &squant) ;
345 
348 
350  std::string requestedQuantitiesString() const ;
351 
353 
356  size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const ;
357 
359 
362  size_t getSpectralQuantitiesCount(Quantity_t *q=NULL) const ;
363 
365  double tMin() const ;
367  double tMin(const std::string &unit) const ;
369  void tMin(double);
371  void tMin(double, const std::string &unit);
372 
373  void adaptive (bool mode) ;
374  bool adaptive () const ;
375 
377  void integrator(std::string type);
379  std::string integrator() const;
380 
382  double deltaMin() const;
384  void deltaMin(double h1);
385 
387  double deltaMax() const;
388 
390  void deltaMax(double h1);
391 
393  double deltaMaxOverR() const;
395  void deltaMaxOverR(double t);
396 
398  void absTol(double);
400  double absTol()const;
402  void relTol(double);
404  double relTol()const;
405 
406  void secondary (bool sec) ;
407  bool secondary () const ;
408 
409  void parallelTransport (bool pt) ;
410  bool parallelTransport () const ;
411 
412  void maxiter (size_t miter) ;
413  size_t maxiter () const ;
414 
415  void nThreads(size_t);
416  size_t nThreads() const ;
417 
418  void nProcesses(size_t);
419  size_t nProcesses() const ;
420 
422  void intensityConverter(std::string unit);
424  void spectrumConverter(std::string unit);
426  void binSpectrumConverter(std::string unit);
427 
429 
434 
435  // Worker:
436  public:
438 
487  void rayTrace(
488 #ifdef GYOTO_SWIGIMPORTED
489  Coord2dSet & ij,
490 #else
491  Screen::Coord2dSet & ij,
492 #endif
493  Astrobj::Properties *data,
494  double * impactcoords=NULL);
495 
497 
504  void operator() (size_t i, size_t j, Astrobj::Properties *data,
505  double * impactcoords = NULL, Photon * ph = NULL);
506 
508 
515  void operator() (double alpha, double delta, Astrobj::Properties *data,
516  Photon * ph = NULL);
517 
518 #ifdef GYOTO_USE_XERCES
519  public:
520  // Override fillProperty() to issue InitCoord only if it was set
521  void fillProperty(FactoryMessenger *fmp, Property const &p) const ;
522  // Override fillElement to fill metric, screen and astrobj first
523  void fillElement(FactoryMessenger *fmp) const;
526 
527 #endif
528 
529 };
530 
531 #endif
Gyoto::Scenery::nProcesses
void nProcesses(size_t)
Set nprocesses_;.
Gyoto::Scenery::nprocesses_
int nprocesses_
Number of parallel processes to use in rayTrace()
Definition: GyotoScenery.h:207
Gyoto::Scenery::spectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > spectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:213
Gyoto::Scenery::mpiTerminate
void mpiTerminate()
Terminate worker processes.
Gyoto::Scenery::nProcesses
size_t nProcesses() const
Get nprocesses_;.
GYOTO_OBJECT
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
Gyoto::Scenery::metric
SmartPointer< Metric::Generic > metric() const
Get ph_.Worldline::metric_.
Gyoto::Scenery::delta
void delta(double)
set default step in geometrical units
Gyoto::Scenery::requestedQuantitiesString
std::string requestedQuantitiesString() const
Get a string representation of Scenery::quantities_.
Gyoto::Scenery::requestedQuantitiesString
void requestedQuantitiesString(std::string const &squant)
Set Scenery::quantities_ from string.
size_t
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:390
Gyoto::Scenery::secondary
void secondary(bool sec)
Set ph_.secondary_.
GyotoSmartPointer.h
Reference-counting pointers.
Gyoto::Scenery::binSpectrumConverter
void binSpectrumConverter(std::string unit)
Set Scenery::binspectrum_converter_.
Gyoto::Scenery::Scenery
Scenery(SmartPointer< Metric::Generic >, SmartPointer< Screen >, SmartPointer< Astrobj::Generic >)
Constructor setting Scenery::gg_, Scenery::screen_, and Scenery::obj_.
Gyoto::Scenery::mpiWorker
static void mpiWorker()
Become an MPI worker.
Gyoto::Object
Object with properties.
Definition: GyotoObject.h:152
GYOTO_OBJECT_THREAD_SAFETY
#define GYOTO_OBJECT_THREAD_SAFETY
Declare virtual bool isThreadSafe() const.
Definition: GyotoObject.h:99
Gyoto::Scenery::parallelTransport
void parallelTransport(bool pt)
Set ph_.parallel_transport_.
Gyoto::Scenery::mpi_team_
boost::mpi::communicator * mpi_team_
Team of processes for MPI.
Definition: GyotoScenery.h:226
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
Gyoto::Scenery::nThreads
size_t nThreads() const
Get nthreads_;.
Gyoto::Scenery::fillProperty
void fillProperty(FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
Gyoto::Scenery
Ray-tracing scene.
Definition: GyotoScenery.h:165
GyotoAstrobj.h
Astronomical objects (light emitters)
GyotoFactory.h
XML I/O.
Gyoto::Scenery::setPropertyConverters
void setPropertyConverters(Gyoto::Astrobj::Properties *prop)
Copy converters to Astrobj::Properties instance.
Gyoto::Scenery::rayTrace
void rayTrace(Screen::Coord2dSet &ij, Astrobj::Properties *data, double *impactcoords=NULL)
Perform ray-tracing.
Gyoto::Scenery::binspectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > binspectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:215
Gyoto::Scenery::clone
Scenery * clone() const
Cloner.
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton() const
Clone the internal Photon.
Gyoto::Scenery::getScalarQuantitiesCount
size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of scalar nature.
GyotoPhoton.h
A single light ray.
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton(size_t i, size_t j)
Clone the internal Photon.
Gyoto::Scenery::delta
double delta(const std::string &unit) const
Get default step in specified units.
Gyoto::Scenery::integrator
void integrator(std::string type)
Passed to ph_.
Gyoto::Scenery::deltaMin
void deltaMin(double h1)
Passed to ph_.
Gyoto::Scenery::adaptive
bool adaptive() const
Get ph_.adaptive_.
Gyoto::Scenery::updatePhoton
void updatePhoton()
Update values in cached Photon.
Gyoto::Scenery::screen_
SmartPointer< Screen > screen_
Definition: GyotoScenery.h:176
GyotoDefs.h
Gyoto ubiquitous macros and typedefs.
Gyoto::Scenery::deltaMaxOverR
double deltaMaxOverR() const
Passed to ph_.
Gyoto::Scenery::nthreads_
size_t nthreads_
Number of parallel threads to use in rayTrace()
Definition: GyotoScenery.h:205
Gyoto::Scenery::intensityConverter
void intensityConverter(std::string unit)
Set Scenery::intensity_converter_.
Gyoto::Scenery::tMin
double tMin(const std::string &unit) const
Get ph_.tmin_ in specified unit.
GyotoObject.h
Introspectable objects.
Gyoto::Scenery::tMin
void tMin(double)
Set ph_.tmin_.
Gyoto::Scenery::ph_
Gyoto::Photon ph_
Template Photon.
Definition: GyotoScenery.h:198
Gyoto::Scenery::delta_
double delta_
Definition: GyotoScenery.h:182
Gyoto
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
Gyoto::Scenery::delta
double delta() const
Get default step in geometrical units.
Gyoto::Scenery::metric
void metric(SmartPointer< Metric::Generic >)
Set Scenery::gg_.
Gyoto::Scenery::screen
SmartPointer< Screen > screen() const
Get Scenery::screen_.
Gyoto::Scenery::deltaMaxOverR
void deltaMaxOverR(double t)
Passed to ph_.
Gyoto::Scenery::spectrumConverter
void spectrumConverter(std::string unit)
Set Scenery::spectrum_converter_.
Gyoto::Scenery::astrobj
SmartPointer< Astrobj::Generic > astrobj() const
Get ph_.obj_.
Gyoto::Scenery::deltaMin
double deltaMin() const
Passed to ph_.
Gyoto::Scenery::fillElement
void fillElement(FactoryMessenger *fmp) const
Fill the XML element for this Object.
GyotoMetric.h
Base class for metric description.
Gyoto::Scenery::tMin
double tMin() const
Get ph_.tmin_.
Gyoto::Scenery::adaptive
void adaptive(bool mode)
Set ph_.adaptive_.
Gyoto::Scenery::intensity_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > intensity_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:211
Gyoto::Scenery::deltaMax
void deltaMax(double h1)
Passed to ph_.
Gyoto::Scenery::screen
void screen(SmartPointer< Screen >)
Set Scenery::screen_.
Gyoto::Scenery::mpiSpawn
void mpiSpawn(int nbchildren)
Spawn gyoto-mpi-worker processes.
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton(double a, double d)
Clone the internal Photon.
Gyoto::SmartPointer
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Gyoto::Scenery::parallelTransport
bool parallelTransport() const
Get ph_.parallel_transport_.
Gyoto::Scenery::integrator
std::string integrator() const
Passed to ph_.
Gyoto::Scenery::Scenery
Scenery(const Scenery &o)
Copy constructor.
Gyoto::Scenery::getSpectralQuantitiesCount
size_t getSpectralQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of spectral nature.
Gyoto::Scenery::setRequestedQuantities
void setRequestedQuantities(Quantity_t quant)
Set Scenery::quantities_.
Gyoto::Photon
A null geodesic transporting light.
Definition: GyotoPhoton.h:56
Gyoto::Scenery::delta
void delta(double, const std::string &unit)
set default step in specified units
Gyoto::Scenery::absTol
double absTol() const
Passed to ph_.
Gyoto::Scenery::getRequestedQuantities
Quantity_t getRequestedQuantities() const
Get Scenery::quantities_.
Gyoto::Scenery::astrobj
void astrobj(SmartPointer< Astrobj::Generic >)
Set ph_.obj_.
Gyoto::Scenery::secondary
bool secondary() const
Get ph_.secondary_.
Gyoto::Scenery::relTol
void relTol(double)
Passed to ph_.
Gyoto::Property
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:608
Gyoto::Scenery::Subcontractor
static SmartPointer< Scenery > Subcontractor(Gyoto::FactoryMessenger *)
Instanciate Scenery from an XML description.
Gyoto::Scenery::relTol
double relTol() const
Passed to ph_.
Gyoto::Quantity_t
unsigned int Quantity_t
Type for observabke quantities.
Definition: GyotoDefs.h:76
Gyoto::Scenery::quantities_
Gyoto::Quantity_t quantities_
Quantities to compute.
Definition: GyotoScenery.h:191
Gyoto::Scenery::mpiClone
void mpiClone()
Send a copy of self to the mpi workers.
Gyoto::Scenery::operator()
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::Scenery::mpiTask
void mpiTask(mpi_tag &tag)
Send a tag to workers.
Gyoto::Scenery::tMin
void tMin(double, const std::string &unit)
Set ph_.tmin_ in specified unit.
Gyoto::Screen::Coord2dSet
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:669
Gyoto::Scenery::deltaMax
double deltaMax() const
Passed to ph_.
Gyoto::Scenery::maxiter
void maxiter(size_t miter)
Set ph_.maxiter_.
GyotoScreen.h
Description of the observer screen.
Gyoto::Scenery::Scenery
Scenery()
Set everything to defaults.
Gyoto::Astrobj::Properties
Observable properties of an Astronomical object.
Definition: GyotoAstrobj.h:654
Gyoto::SmartPointee
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:81
GyotoConverters.h
GYOTO converters.
Gyoto::Scenery::absTol
void absTol(double)
Passed to ph_.
Gyoto::Scenery::mpi_tag
mpi_tag
Tags that may be sent to communicate with workers using MPI_Send()
Definition: GyotoScenery.h:264
Gyoto::Scenery::maxiter
size_t maxiter() const
Get ph_.maxiter_.
Gyoto::Scenery::am_worker
static bool am_worker
True in instance of gyoto-mpi-worker, otherwise false.
Definition: GyotoScenery.h:229
Gyoto::Scenery::nThreads
void nThreads(size_t)
Set nthreads_;.