GyotoScenery.h
Go to the documentation of this file.
/*
Copyright 2011-2016, 2018-2019 Thibaut Paumard
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoScenery_H_
#define __GyotoScenery_H_
namespace Gyoto{
class Scenery;
}
#include <GyotoDefs.h>
#include <GyotoSmartPointer.h>
#include <GyotoObject.h>
#include <GyotoAstrobj.h>
#include <GyotoMetric.h>
#include <GyotoScreen.h>
#include <GyotoPhoton.h>
#include <GyotoConverters.h>
#ifdef HAVE_MPI
#include "GyotoFactory.h"
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#endif
class Gyoto::Scenery
: public Gyoto::SmartPointee,
public Gyoto::Object
{
friend class Gyoto::SmartPointer<Gyoto::Scenery>;
// Data :
// -----
protected:
SmartPointer<Screen> screen_;
double delta_; // default integration step for the photons
Gyoto::Quantity_t quantities_;
Gyoto::Photon ph_;
size_t nthreads_;
int nprocesses_;
# ifdef HAVE_UDUNITS
Gyoto::SmartPointer<Gyoto::Units::Converter> intensity_converter_;
Gyoto::SmartPointer<Gyoto::Units::Converter> spectrum_converter_;
Gyoto::SmartPointer<Gyoto::Units::Converter> binspectrum_converter_;
# endif
public:
GYOTO_OBJECT_THREAD_SAFETY;
# ifdef HAVE_MPI
boost::mpi::communicator * mpi_team_;
# endif
static bool am_worker;
void mpiSpawn(int nbchildren);
void mpiTerminate ();
void mpiClone();
enum mpi_tag {give_task, read_scenery, terminate,
raytrace, raytrace_done, ready,
impactcoords, noimpactcoords};
void mpiTask(mpi_tag &tag);
static void mpiWorker();
// Constructors - Destructor
// -------------------------
public:
GYOTO_OBJECT;
GYOTO_WORLDLINE;
Scenery();
Scenery (const Scenery& o);
Scenery * clone() const;
Scenery(SmartPointer<Metric::Generic>, SmartPointer<Screen>, SmartPointer<Astrobj::Generic>);
~Scenery();
// Mutators / assignment
// ---------------------
public:
// Accessors
// ---------
SmartPointer<Metric::Generic> metric() const;
void metric(SmartPointer<Metric::Generic>);
SmartPointer<Screen> screen() const;
void screen(SmartPointer<Screen>);
SmartPointer<Astrobj::Generic> astrobj() const;
void astrobj(SmartPointer<Astrobj::Generic>);
SmartPointer<Photon> clonePhoton() const;
SmartPointer<Photon> clonePhoton(size_t i, size_t j);
SmartPointer<Photon> clonePhoton(double a, double d);
void updatePhoton();
double delta() const ;
double delta(const std::string &unit) const ;
void delta(double);
void delta(double, const std::string &unit);
void initCoord(std::vector<double> c);
std::vector<double> initCoord() const;
void setRequestedQuantities(Quantity_t quant) ;
void requestedQuantitiesString(std::string const &squant) ;
Quantity_t getRequestedQuantities() const ;
std::string requestedQuantitiesString() const ;
size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const ;
size_t getSpectralQuantitiesCount(Quantity_t *q=NULL) const ;
double tMin() const ;
double tMin(const std::string &unit) const ;
void tMin(double);
void tMin(double, const std::string &unit);
void adaptive (bool mode) ;
bool adaptive () const ;
void integrator(std::string type);
std::string integrator() const;
double deltaMin() const;
void deltaMin(double h1);
double deltaMax() const;
void deltaMax(double h1);
double deltaMaxOverR() const;
void deltaMaxOverR(double t);
void absTol(double);
double absTol()const;
void relTol(double);
double relTol()const;
void maxCrossEqplane(double);
double maxCrossEqplane()const;
void secondary (bool sec) ;
bool secondary () const ;
void integ31(bool integ);
bool integ31() const ;
void parallelTransport (bool pt) ;
bool parallelTransport () const ;
void maxiter (size_t miter) ;
size_t maxiter () const ;
void nThreads(size_t);
size_t nThreads() const ;
void nProcesses(size_t);
size_t nProcesses() const ;
void intensityConverter(std::string unit);
void spectrumConverter(std::string unit);
void binSpectrumConverter(std::string unit);
void setPropertyConverters(Gyoto::Astrobj::Properties *prop);
// Worker:
public:
void rayTrace(
#ifdef GYOTO_SWIGIMPORTED
Coord2dSet & ij,
#else
Screen::Coord2dSet & ij,
#endif
Astrobj::Properties *data,
double * impactcoords=NULL);
void operator() (size_t i, size_t j, Astrobj::Properties *data,
double * impactcoords = NULL, Photon * ph = NULL);
void operator() (double alpha, double delta, Astrobj::Properties *data,
Photon * ph = NULL);
#ifdef GYOTO_USE_XERCES
public:
// Override fillProperty() to issue InitCoord only if it was set
void fillProperty(FactoryMessenger *fmp, Property const &p) const ;
// Override fillElement to fill metric, screen and astrobj first
void fillElement(FactoryMessenger *fmp) const;
static SmartPointer<Scenery> Subcontractor(Gyoto::FactoryMessenger*);
#endif
};
#endif
GyotoAstrobj.h
Astronomical objects (light emitters).
size_t
#define size_t
If not defined in <sys/types.h>.
Definition GyotoConfig.h:390
GyotoConverters.h
GYOTO converters.
GyotoDefs.h
Gyoto ubiquitous macros and typedefs.
GyotoFactory.h
XML I/O.
GyotoMetric.h
Base class for metric description.
GyotoObject.h
Introspectable objects.
GYOTO_OBJECT
#define GYOTO_OBJECT
Declare class::properties and class::getProperties().
Definition GyotoObject.h:84
GyotoPhoton.h
A single light ray.
GyotoScreen.h
Description of the observer screen.
GyotoSmartPointer.h
Reference-counting pointers.
Gyoto::Astrobj::Properties
Observable properties of an Astronomical object.
Definition GyotoAstrobj.h:792
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Gyoto::Object
Object with properties.
Definition GyotoObject.h:152
Gyoto::Photon
A null geodesic transporting light.
Definition GyotoPhoton.h:57
Gyoto::Property
Property that can be set and got using standard methods.
Definition GyotoProperty.h:608
Gyoto::Scenery
Ray-tracing scene.
Definition GyotoScenery.h:165
Gyoto::Scenery::delta
void delta(double)
set default step in geometrical units
Gyoto::Scenery::nThreads
size_t nThreads() const
Get nthreads_;.
Gyoto::Scenery::clone
Scenery * clone() const
Cloner.
Gyoto::Scenery::tMin
void tMin(double, const std::string &unit)
Set ph_.tmin_ in specified unit.
Gyoto::Scenery::relTol
double relTol() const
Passed to ph_.
Gyoto::Scenery::metric
SmartPointer< Metric::Generic > metric() const
Get ph_.Worldline::metric_.
Gyoto::Scenery::mpiTerminate
void mpiTerminate()
Terminate worker processes.
Gyoto::Scenery::adaptive
bool adaptive() const
Get ph_.adaptive_.
Gyoto::Scenery::secondary
void secondary(bool sec)
Set ph_.secondary_.
Gyoto::Scenery::maxCrossEqplane
double maxCrossEqplane() const
Passed to ph_.
Gyoto::Scenery::integ31
void integ31(bool integ)
Set WorldlinIntegState integ_31_.
Gyoto::Scenery::adaptive
void adaptive(bool mode)
Set ph_.adaptive_.
Gyoto::Scenery::requestedQuantitiesString
void requestedQuantitiesString(std::string const &squant)
Set Scenery::quantities_ from string.
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::deltaMax
void deltaMax(double h1)
Passed to ph_.
Gyoto::Scenery::parallelTransport
bool parallelTransport() const
Get ph_.parallel_transport_.
Gyoto::Scenery::intensity_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > intensity_converter_
See Astrobj::Properties::intensity_converter_.
Definition GyotoScenery.h:211
Gyoto::Scenery::maxCrossEqplane
void maxCrossEqplane(double)
Passed to ph_.
Gyoto::Scenery::astrobj
void astrobj(SmartPointer< Astrobj::Generic >)
Set ph_.obj_.
Gyoto::Scenery::Scenery
Scenery(const Scenery &o)
Copy constructor.
Gyoto::Scenery::nprocesses_
int nprocesses_
Number of parallel processes to use in rayTrace().
Definition GyotoScenery.h:207
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton() const
Get clone of template Photon.
Gyoto::Scenery::nThreads
void nThreads(size_t)
Set nthreads_;.
Gyoto::Scenery::deltaMaxOverR
void deltaMaxOverR(double t)
Passed to ph_.
Gyoto::Scenery::screen
void screen(SmartPointer< Screen >)
Set Scenery::screen_.
Gyoto::Scenery::integrator
std::string integrator() const
Passed to ph_.
Gyoto::Scenery::deltaMaxOverR
double deltaMaxOverR() const
Passed to ph_.
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton(double a, double d)
Get clone of template Photon, intitializing it to direction.
Gyoto::Scenery::absTol
double absTol() const
Passed to ph_.
Gyoto::Scenery::Scenery
Scenery()
Set everything to defaults.
Gyoto::Scenery::delta_
double delta_
Definition GyotoScenery.h:182
Gyoto::Scenery::relTol
void relTol(double)
Passed to ph_.
Gyoto::Scenery::fillElement
void fillElement(FactoryMessenger *fmp) const
Fill the XML element for this Object.
Gyoto::Scenery::mpiWorker
static void mpiWorker()
Become an MPI worker.
Gyoto::Scenery::binSpectrumConverter
void binSpectrumConverter(std::string unit)
Set Scenery::binspectrum_converter_.
Gyoto::Scenery::mpi_team_
boost::mpi::communicator * mpi_team_
Team of processes for MPI.
Definition GyotoScenery.h:226
Gyoto::Scenery::delta
void delta(double, const std::string &unit)
set default step in specified units
Gyoto::Scenery::nthreads_
size_t nthreads_
Number of parallel threads to use in rayTrace().
Definition GyotoScenery.h:205
Gyoto::Scenery::maxiter
size_t maxiter() const
Get ph_.maxiter_.
Gyoto::Scenery::mpiSpawn
void mpiSpawn(int nbchildren)
Spawn gyoto-mpi-worker processes.
Gyoto::Scenery::mpiClone
void mpiClone()
Send a copy of self to the mpi workers.
Gyoto::Scenery::absTol
void absTol(double)
Passed to ph_.
Gyoto::Scenery::setPropertyConverters
void setPropertyConverters(Gyoto::Astrobj::Properties *prop)
Copy converters to Astrobj::Properties instance.
Gyoto::Scenery::requestedQuantitiesString
std::string requestedQuantitiesString() const
Get a string representation of Scenery::quantities_.
Gyoto::Scenery::integ31
bool integ31() const
Get WorldlinIntegState integ_31_.
Gyoto::Scenery::getRequestedQuantities
Quantity_t getRequestedQuantities() const
Get Scenery::quantities_.
Gyoto::Scenery::astrobj
SmartPointer< Astrobj::Generic > astrobj() const
Get ph_.obj_.
Gyoto::Scenery::nProcesses
void nProcesses(size_t)
Set nprocesses_;.
Gyoto::Scenery::Subcontractor
static SmartPointer< Scenery > Subcontractor(Gyoto::FactoryMessenger *)
Instanciate Scenery from an XML description.
Gyoto::Scenery::spectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > spectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition GyotoScenery.h:213
Gyoto::Scenery::fillProperty
void fillProperty(FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
Gyoto::Scenery::updatePhoton
void updatePhoton()
Update values in cached Photon.
Gyoto::Scenery::mpi_tag
mpi_tag
Tags that may be sent to communicate with workers using MPI_Send().
Definition GyotoScenery.h:264
Gyoto::Scenery::am_worker
static bool am_worker
True in instance of gyoto-mpi-worker, otherwise false.
Definition GyotoScenery.h:229
Gyoto::Scenery::screen
SmartPointer< Screen > screen() const
Get Scenery::screen_.
Gyoto::Scenery::tMin
double tMin(const std::string &unit) const
Get ph_.tmin_ in specified unit.
Gyoto::Scenery::binspectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > binspectrum_converter_
See Astrobj::Properties::intensity_converter_.
Definition GyotoScenery.h:215
Gyoto::Scenery::deltaMin
double deltaMin() const
Passed to ph_.
Gyoto::Scenery::ph_
Gyoto::Photon ph_
Template Photon.
Definition GyotoScenery.h:198
Gyoto::Scenery::delta
double delta() const
Get default step in geometrical units.
Gyoto::Scenery::clonePhoton
SmartPointer< Photon > clonePhoton(size_t i, size_t j)
Get clone of template Photon, intitializing it to pixel.
Gyoto::Scenery::Scenery
Scenery(SmartPointer< Metric::Generic >, SmartPointer< Screen >, SmartPointer< Astrobj::Generic >)
Constructor setting Scenery::gg_, Scenery::screen_, and Scenery::obj_.
Gyoto::Scenery::secondary
bool secondary() const
Get ph_.secondary_.
Gyoto::Scenery::intensityConverter
void intensityConverter(std::string unit)
Set Scenery::intensity_converter_.
Gyoto::Scenery::integrator
void integrator(std::string type)
Passed to ph_.
Gyoto::Scenery::tMin
double tMin() const
Get ph_.tmin_.
Gyoto::Scenery::spectrumConverter
void spectrumConverter(std::string unit)
Set Scenery::spectrum_converter_.
Gyoto::Scenery::setRequestedQuantities
void setRequestedQuantities(Quantity_t quant)
Set Scenery::quantities_.
Gyoto::Scenery::delta
double delta(const std::string &unit) const
Get default step in specified units.
Gyoto::Scenery::deltaMax
double deltaMax() const
Passed to ph_.
Gyoto::Scenery::parallelTransport
void parallelTransport(bool pt)
Set ph_.parallel_transport_.
Gyoto::Scenery::tMin
void tMin(double)
Set ph_.tmin_.
Gyoto::Scenery::nProcesses
size_t nProcesses() const
Get nprocesses_;.
Gyoto::Scenery::maxiter
void maxiter(size_t miter)
Set ph_.maxiter_.
Gyoto::Scenery::screen_
SmartPointer< Screen > screen_
Definition GyotoScenery.h:176
Gyoto::Scenery::getSpectralQuantitiesCount
size_t getSpectralQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of spectral nature.
Gyoto::Scenery::quantities_
Gyoto::Quantity_t quantities_
Quantities to compute.
Definition GyotoScenery.h:191
Gyoto::Scenery::deltaMin
void deltaMin(double h1)
Passed to ph_.
Gyoto::Scenery::rayTrace
void rayTrace(Screen::Coord2dSet &ij, Astrobj::Properties *data, double *impactcoords=NULL)
Perform ray-tracing.
Gyoto::Scenery::mpiTask
void mpiTask(mpi_tag &tag)
Send a tag to workers.
Gyoto::Scenery::metric
void metric(SmartPointer< Metric::Generic >)
Set Scenery::gg_.
Gyoto::Scenery::getScalarQuantitiesCount
size_t getScalarQuantitiesCount(Quantity_t *q=NULL) const
Get number of requested quantities of scalar nature.
Gyoto::Screen::Coord2dSet
Class to specify a set of points on the Screen.
Definition GyotoScreen.h:682
Gyoto::SmartPointee
Can be pointed to by a SmartPointer.
Definition GyotoSmartPointer.h:81
Gyoto::SmartPointer
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44
Gyoto::Quantity_t
unsigned int Quantity_t
Type for observabke quantities.
Definition GyotoDefs.h:76