Gyoto
GyotoScenery.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011-2016 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 
253  void mpiSpawn(int nbchildren);
254 
256  void mpiTerminate ();
257 
259 
262  void mpiClone();
263 
265  enum mpi_tag {give_task, read_scenery, terminate,
266  raytrace, raytrace_done, ready,
267  impactcoords, noimpactcoords};
268 
270  void mpiTask(mpi_tag &tag);
271 
272  // Constructors - Destructor
273  // -------------------------
274  public:
275  GYOTO_OBJECT;
277  Scenery();
278  Scenery (const Scenery& o);
279  Scenery * clone() const;
280 
282 
287 
288  ~Scenery();
289 
290  // Mutators / assignment
291  // ---------------------
292  public:
293  // Accessors
294  // ---------
296 
300  SmartPointer<Screen> screen() const;
301 
307 
311 
312 
314  SmartPointer<Photon> clonePhoton(size_t i, size_t j);
315  SmartPointer<Photon> clonePhoton(double a, double d);
316  void updatePhoton();
317 
318  double delta() const ;
319  double delta(const std::string &unit) const ;
320  void delta(double);
321  void delta(double, const std::string &unit);
322 
323  void initCoord(std::vector<double> c);
324  std::vector<double> initCoord() const;
325 
326 
328 
331  void setRequestedQuantities(Quantity_t quant) ;
332 
334 
338  void requestedQuantitiesString(std::string const &squant) ;
339 
342 
344  std::string requestedQuantitiesString() const ;
345 
347 
350  size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const ;
351 
353  double tMin() const ;
355  double tMin(const std::string &unit) const ;
357  void tMin(double);
359  void tMin(double, const std::string &unit);
360 
361  void adaptive (bool mode) ;
362  bool adaptive () const ;
363 
365  void integrator(std::string type);
367  std::string integrator() const;
368 
370  double deltaMin() const;
372  void deltaMin(double h1);
373 
375  double deltaMax() const;
376 
378  void deltaMax(double h1);
379 
381  double deltaMaxOverR() const;
383  void deltaMaxOverR(double t);
384 
386  void absTol(double);
388  double absTol()const;
390  void relTol(double);
392  double relTol()const;
393 
394  void secondary (bool sec) ;
395  bool secondary () const ;
396 
397  void maxiter (size_t miter) ;
398  size_t maxiter () const ;
399 
400  void nThreads(size_t);
401  size_t nThreads() const ;
402 
403  void nProcesses(size_t);
404  size_t nProcesses() const ;
405 
407  void intensityConverter(std::string unit);
409  void spectrumConverter(std::string unit);
411  void binSpectrumConverter(std::string unit);
412 
414 
419 
420  // Worker:
421  public:
423 
472  void rayTrace(
473 #ifdef GYOTO_SWIGIMPORTED
474  Coord2dSet & ij,
475 #else
476  Screen::Coord2dSet & ij,
477 #endif
478  Astrobj::Properties *data,
479  double * impactcoords=NULL);
480 
482 
489  void operator() (size_t i, size_t j, Astrobj::Properties *data,
490  double * impactcoords = NULL, Photon * ph = NULL);
491 
493 
500  void operator() (double alpha, double delta, Astrobj::Properties *data,
501  Photon * ph = NULL);
502 
503 #ifdef GYOTO_USE_XERCES
504  public:
505  // Override fillProperty() to issue InitCoord only if it was set
506  void fillProperty(FactoryMessenger *fmp, Property const &p) const ;
507  // Override fillElement to fill metric, screen and astrobj first
508  void fillElement(FactoryMessenger *fmp) const;
511 
512 #endif
513 
514 };
515 
516 #endif
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
void rayTrace(Screen::Coord2dSet &ij, Astrobj::Properties *data, double *impactcoords=NULL)
Perform ray-tracing.
void fillElement(FactoryMessenger *fmp) const
Fill the XML element for this Object.
void mpiSpawn(int nbchildren)
Spawn gyoto-mpi-worker processes.
Astronomical objects (light emitters)
double tMin() const
Get ph_.tmin_.
std::string integrator() const
Passed to ph_.
double absTol() const
Passed to ph_.
A null geodesic transporting light.
Definition: GyotoPhoton.h:52
Ray-tracing scene.
Definition: GyotoScenery.h:162
Reference-counting pointers.
#define GYOTO_OBJECT_THREAD_SAFETY
Declare virtual bool isThreadSafe() const.
Definition: GyotoObject.h:99
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 <sys/types.h>.
Definition: GyotoConfig.h:354
void binSpectrumConverter(std::string unit)
Set Scenery::binspectrum_converter_.
Gyoto::Photon ph_
Template Photon.
Definition: GyotoScenery.h:198
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
SmartPointer< Screen > screen() const
Get Scenery::screen_.
Gyoto::Quantity_t quantities_
Quantities to compute.
Definition: GyotoScenery.h:191
void mpiClone()
Send a copy of self to the mpi workers.
void mpiTask(mpi_tag &tag)
Send a tag to workers.
double relTol() const
Passed to ph_.
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_.
double deltaMin() const
Passed to ph_.
void fillProperty(FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
Gyoto::SmartPointer< Gyoto::Units::Converter > binspectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:215
Gyoto::SmartPointer< Gyoto::Units::Converter > intensity_converter_
See Astrobj::Properties::intensity_converter_.
Definition: GyotoScenery.h:211
double deltaMax() const
Passed to ph_.
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
SmartPointer< Photon > clonePhoton() const
Clone the internal Photon.
int nprocesses_
Number of parallel processes to use in rayTrace()
Definition: GyotoScenery.h:207
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:607
bool secondary() const
Get ph_.secondary_.
mpi_tag
Tags that may be sent to communicate with workers using MPI_Send()
Definition: GyotoScenery.h:265
size_t maxiter() const
Get ph_.maxiter_.
static bool am_worker
True in instance of gyoto-mpi-worker, otherwise false.
Definition: GyotoScenery.h:229
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_.
#define GYOTO_WORLDLINE
Declare the Worldline interface wrappers.
Definition: GyotoWorldline.h:151
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
double deltaMaxOverR() const
Passed to ph_.
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:226
std::string requestedQuantitiesString() const
Get a string representation of Scenery::quantities_.
SmartPointer< Metric::Generic > metric() const
Get ph_.Worldline::metric_.
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
void setPropertyConverters(Gyoto::Astrobj::Properties *prop)
Copy converters to Astrobj::Properties instance.
size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of scalar nature.
Scenery()
Set everything to defaults.
size_t nThreads() const
Get nthreads_;.
Scenery * clone() const
Cloner.
GYOTO converters.
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:643
Object with properties.
Definition: GyotoObject.h:151
Description of the observer screen.
size_t nProcesses() const
Get nprocesses_;.
double delta_
Definition: GyotoScenery.h:182
void setRequestedQuantities(Quantity_t quant)
Set Scenery::quantities_.
SmartPointer< Screen > screen_
Definition: GyotoScenery.h:176
double delta() const
Get default step in geometrical units.
Quantity_t getRequestedQuantities() const
Get Scenery::quantities_.
bool adaptive() const
Get ph_.adaptive_.
void spectrumConverter(std::string unit)
Set Scenery::spectrum_converter_.
A single light ray.
Observable properties of an Astronomical object.
Definition: GyotoAstrobj.h:603
SmartPointer< Astrobj::Generic > astrobj() const
Get ph_.obj_.