[Debian-astro-commits] [gyoto] 122/221: Move Object API out of Worldline and into Star and Photon
Thibaut Jean-Claude Paumard
thibaut at moszumanska.debian.org
Fri May 22 20:52:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
thibaut pushed a commit to branch master
in repository gyoto.
commit 9e0d71b4eea1926d72573245caff6999ca5d5d75
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date: Mon Dec 1 11:29:46 2014 +0100
Move Object API out of Worldline and into Star and Photon
---
include/GyotoPhoton.h | 16 ++++++---
include/GyotoProperty.h | 12 ++++++-
include/GyotoStar.h | 24 ++++++++-----
include/GyotoUniformSphere.h | 4 +--
include/GyotoWorldline.h | 86 ++++++++++++++++++++++++++++++++++++--------
lib/Object.C | 46 ++++++++++++++++--------
lib/Photon.C | 47 +++++++++++++++++++-----
lib/Property.C | 3 ++
lib/Star.C | 62 ++++++++++++++++++++++++++++----
lib/StarTrace.C | 6 +---
lib/UniformSphere.C | 6 ++--
lib/Worldline.C | 86 --------------------------------------------
12 files changed, 242 insertions(+), 156 deletions(-)
diff --git a/include/GyotoPhoton.h b/include/GyotoPhoton.h
index 07145f3..e0c18c5 100644
--- a/include/GyotoPhoton.h
+++ b/include/GyotoPhoton.h
@@ -39,6 +39,7 @@ namespace Gyoto{
#include <GyotoMetric.h>
#include <GyotoScreen.h>
#include <GyotoWorldline.h>
+#include <GyotoObject.h>
#include <float.h>
@@ -48,7 +49,11 @@ namespace Gyoto{
*
* This is the central object for ray-tracing.
*/
-class Gyoto::Photon : public Gyoto::Worldline, public Gyoto::SmartPointee {
+class Gyoto::Photon
+: public Gyoto::Worldline,
+ public Gyoto::SmartPointee,
+ public Gyoto::Object
+{
friend class Gyoto::SmartPointer<Gyoto::Photon>;
// Data :
// -----
@@ -90,6 +95,8 @@ class Gyoto::Photon : public Gyoto::Worldline, public Gyoto::SmartPointee {
// -------------------------
public:
+ GYOTO_OBJECT;
+ GYOTO_WORLDLINE;
virtual std::string className() const ; ///< "Photon"
virtual std::string className_l() const ; ///< "photon"
@@ -221,10 +228,9 @@ class Gyoto::Photon : public Gyoto::Worldline, public Gyoto::SmartPointee {
double tinside, double &toutside) ;
#ifdef GYOTO_USE_XERCES
- public:
- /// Write XML description
- void fillElement(FactoryMessenger *fmp) const;
- /// Instanciate Photon from XML description
+ virtual void setParameters(FactoryMessenger *fmp) ;
+ virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const ;
+ virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
static SmartPointer<Photon> Subcontractor(Gyoto::FactoryMessenger*);
#endif
diff --git a/include/GyotoProperty.h b/include/GyotoProperty.h
index 3fb0f52..c382d27 100644
--- a/include/GyotoProperty.h
+++ b/include/GyotoProperty.h
@@ -45,6 +45,14 @@ namespace Gyoto {
#define GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor) \
Property const * const name##_ancestors[] = {ancestor, NULL}
+#define GYOTO_PROPERTY_MAKE_ANCESTORS2(name, ancestor1, ancestor2) \
+ Property const * const name##_ancestors[] = {ancestor1, ancestor2, NULL}
+
+#define GYOTO_PROPERTY_EMPTY2(class, name, ancestor1, ancestor2) \
+ GYOTO_PROPERTY_MAKE_ANCESTORS2(name, ancestor1, ancestor2); \
+ Property const name \
+ (name##_ancestors)
+
/// Define a new Property of type Bool
/*
* Declares a static variable named "name". name and namef should not
@@ -167,7 +175,7 @@ class Gyoto::Property
public:
enum type_e {double_t, long_t, unsigned_long_t, bool_t,
string_t, filename_t,
- vector_double_t, metric_t, spectrum_t};
+ vector_double_t, metric_t, spectrum_t, empty_t};
std::string name;
std::string name_false;
int type;
@@ -227,6 +235,8 @@ class Gyoto::Property
getter_unit_t getter_unit;
Property const * const * const parents;
+ Property(Property const * const * ancestors);
+
Property(std::string name,
set_long_t set_long,
get_long_t get_long,
diff --git a/include/GyotoStar.h b/include/GyotoStar.h
index 8d0a150..d33433a 100644
--- a/include/GyotoStar.h
+++ b/include/GyotoStar.h
@@ -101,6 +101,8 @@ class Gyoto::Astrobj::Star :
// Constructors - Destructor
// -------------------------
public:
+ GYOTO_OBJECT;
+
/**
* Create Star object and set initial condition.
* \param gg Gyoto::SmartPointer to the Gyoto::Metric in this part of the Universe
@@ -147,20 +149,24 @@ class Gyoto::Astrobj::Star :
// int getCoordSys(); ///< Set coordinate system for integration
virtual void setInitialCondition(double coord[8]); ///< Same as Worldline::setInitialCondition(gg, coord, sys,1)
+ public:
+ // Object / Property overloading for special needs:
+ // Overload to interpret InitialCoordinate alias, and to interpret
+ // Position/Velocity
virtual int setParameter(std::string name,
std::string content,
- std::string unit);
-
- public:
+ std::string unit) ;
#ifdef GYOTO_USE_XERCES
- /**
- * This implementation of UniformSphere::setParameters() uses
- * wait_pos_ and init_vel_ to make sure setVelocity() is called
- * after setPosition().
- */
+ // Overload to 1- get metric first and 2- interpret Position/Velocity
virtual void setParameters(FactoryMessenger *fmp) ;
- virtual void fillElement(FactoryMessenger *fmp) const ; ///< called from Factory
+ // Overload to dispatch InitCoord into Position and Velocity
+ // for massive particle
+ virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const ;
+ virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
#endif
+ GYOTO_WORLDLINE;
+ using Gyoto::Worldline::deltaMax;
+ using Gyoto::Astrobj::UniformSphere::deltaMax;
public:
diff --git a/include/GyotoUniformSphere.h b/include/GyotoUniformSphere.h
index ac20a0c..6918a9d 100644
--- a/include/GyotoUniformSphere.h
+++ b/include/GyotoUniformSphere.h
@@ -145,8 +145,8 @@ class Gyoto::Astrobj::UniformSphere :
///< Get opacity_
double radius() const ; ///< Get radius_ in geometrical units
virtual void radius(double); ///< Set radius_ in geometrical units
- double radius(std::string) const ; ///< Get radius_ in specified unit
- virtual void radius(double, std::string); ///< Set radius_ in specified unit
+ double radius(std::string const &) const ; ///< Get radius_ in specified unit
+ virtual void radius(double, std::string const &); ///< Set radius_ in specified unit
double deltaMaxOverRadius() const ; ///< Get dltmor_
virtual void deltaMaxOverRadius(double f); ///< Set dltmor_
diff --git a/include/GyotoWorldline.h b/include/GyotoWorldline.h
index 4b8c0c8..b9b945e 100644
--- a/include/GyotoWorldline.h
+++ b/include/GyotoWorldline.h
@@ -47,6 +47,76 @@ namespace Gyoto {
#include <GyotoScreen.h>
#include <GyotoHooks.h>
+#define GYOTO_WORLDLINE_PROPERTIES(c, a) \
+ GYOTO_PROPERTY_BOOL(c, HighOrderImages, PrimaryOnly, _secondary, a); \
+ GYOTO_PROPERTY_DOUBLE(c, RelTol, _relTol, &HighOrderImages); \
+ GYOTO_PROPERTY_DOUBLE(c, AbsTol, _absTol, &RelTol); \
+ GYOTO_PROPERTY_DOUBLE(c, DeltaMaxOverR, _deltaMaxOverR, &AbsTol); \
+ GYOTO_PROPERTY_DOUBLE(c, DeltaMax, _deltaMax, &DeltaMaxOverR); \
+ GYOTO_PROPERTY_DOUBLE(c, DeltaMin, _deltaMin, &DeltaMax); \
+ GYOTO_PROPERTY_STRING(c, Integrator, _integrator, &DeltaMin); \
+ GYOTO_PROPERTY_SIZE_T(c, MaxIter, _maxiter, &Integrator); \
+ GYOTO_PROPERTY_BOOL(c, Adaptive, NonAdaptive, _adaptive, &MaxIter); \
+ GYOTO_PROPERTY_DOUBLE_UNIT(c, Delta, _delta, &Adaptive); \
+ GYOTO_PROPERTY_VECTOR_DOUBLE(c, InitCoord, _initCoord, &Delta); \
+ GYOTO_PROPERTY_METRIC(c, Metric, _metric, &InitCoord); \
+ void c::_secondary(bool s) {secondary(s);} \
+ bool c::_secondary() const {return secondary();} \
+ void c::_adaptive(bool s) {adaptive(s);} \
+ bool c::_adaptive() const {return adaptive();} \
+ void c::_relTol(double f){relTol(f);} \
+ double c::_relTol()const{return relTol();} \
+ void c::_absTol(double f){absTol(f);} \
+ double c::_absTol()const{return absTol();} \
+ void c::_deltaMin(double f){deltaMin(f);} \
+ double c::_deltaMin()const{return deltaMin();} \
+ void c::_deltaMax(double f){deltaMax(f);} \
+ double c::_deltaMax()const{return deltaMax();} \
+ void c::_deltaMaxOverR(double f){deltaMaxOverR(f);} \
+ double c::_deltaMaxOverR()const{return deltaMaxOverR();} \
+ void c::_delta(double f){delta(f);} \
+ double c::_delta()const{return delta();} \
+ void c::_delta(double f, std::string const &u){delta(f, u);} \
+ double c::_delta(std::string const &u)const{return delta(u);} \
+ void c::_maxiter(size_t f){maxiter(f);} \
+ size_t c::_maxiter()const{return maxiter();} \
+ void c::_integrator(std::string const &f){integrator(f);} \
+ std::string c::_integrator() const {return integrator();} \
+ std::vector<double> c::_initCoord()const{return initCoord();} \
+ void c::_initCoord(std::vector<double> const &f){initCoord(f);} \
+ void c::_metric(SmartPointer<Metric::Generic>f){metric(f);} \
+ SmartPointer<Metric::Generic> c::_metric() const{return metric();}
+
+#define GYOTO_WORLDLINE_FIRST_PROPERTY ::Metric
+
+#define GYOTO_WORLDLINE \
+ void _delta(const double delta); \
+ void _delta(double, const std::string &unit); \
+ double _delta() const ; \
+ double _delta(const std::string &unit) const ; \
+ void _adaptive (bool mode) ; \
+ bool _adaptive () const ; \
+ void _secondary (bool sec) ; \
+ bool _secondary () const ; \
+ void _maxiter (size_t miter) ; \
+ size_t _maxiter () const ; \
+ void _integrator(std::string const & type); \
+ std::string _integrator() const ; \
+ double _deltaMin() const; \
+ void _deltaMin(double h1); \
+ void _absTol(double); \
+ double _absTol()const; \
+ void _relTol(double); \
+ double _relTol()const; \
+ void _deltaMax(double h1); \
+ double _deltaMax()const; \
+ double _deltaMaxOverR() const; \
+ void _deltaMaxOverR(double t); \
+ std::vector<double> _initCoord()const; \
+ void _initCoord(std::vector<double> const&f); \
+ void _metric(SmartPointer<Metric::Generic>); \
+ SmartPointer<Metric::Generic> _metric() const;
+
/**
* \class Gyoto::Worldline
* \brief Timelike or null geodesics
@@ -79,7 +149,7 @@ namespace Gyoto {
*
*/
class Gyoto::Worldline
-: protected Gyoto::Hook::Listener, public Gyoto::Object
+: protected Gyoto::Hook::Listener
{
// Data :
@@ -187,7 +257,6 @@ class Gyoto::Worldline
// Constructors - Destructor
// -------------------------
public:
- GYOTO_OBJECT;
Worldline() ; ///< Default constructor
Worldline(const Worldline& ) ; ///< Copy constructor
@@ -389,19 +458,6 @@ class Gyoto::Worldline
virtual void xFill(double tlim) ; ///< Fill x0, x1... by integrating the Worldline from previously set inittial condition to time tlim
- // Object / Property overloading for special needs:
- // Overload to interpret InitialCoordinate alias, and to interpret
- // Position/Velocity
- virtual int setParameter(std::string name,
- std::string content,
- std::string unit) ;
-#ifdef GYOTO_USE_XERCES
- // Overload to 1- get metric first and 2- interpret Position/Velocity
- virtual void setParameters(FactoryMessenger *fmp) ;
- // Overload to dispatch InitCoord into Position and Velocity
- // for massive particle
- virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const ;
-#endif
// Accessors
// ---------
diff --git a/lib/Object.C b/lib/Object.C
index 3c58d9b..df0dedf 100644
--- a/lib/Object.C
+++ b/lib/Object.C
@@ -22,37 +22,49 @@ Gyoto::Object::~Object() {}
void Object::set(Property const &p,
Value val,
std::string const &unit) {
-
- if (p.type == Property::double_t) {
- Property::set_double_unit_t setu = p.setter_unit.set_double;
- if (setu) {
- (this->*setu)(val, unit);
- } else {
- if (unit != "") throwError("Can't set this property with unit");
- set(p, val);
+ GYOTO_DEBUG_EXPR(p.type);
+ switch (p.type) {
+ case Property::empty_t:
+ throwError("Attempt to set empty_t Property");
+ return;
+ case Property::double_t:
+ {
+ Property::set_double_unit_t setu = p.setter_unit.set_double;
+ if (setu) {
+ GYOTO_DEBUG << "double Property which supports unit" << endl;
+ (this->*setu)(val, unit);
+ } else {
+ GYOTO_DEBUG << "double Property which does not support unit" << endl;
+ if (unit != "") throwError("Can't set this property with unit");
+ set(p, val);
+ }
}
return;
+ default:
+ GYOTO_DEBUG<< "Not a double_t or empty_t Property" << endl;
+ if (unit != "")
+ throwError("Can't set this property with unit (not a double)");
+ set(p, val);
+ return;
}
- if (unit != "")
- throwError("Can't set this property with unit (not a double)");
-
- set(p, val);
- return;
-
}
void Object::set(Property const &p, Value val) {
# define ___local_case(type) \
case Property::type##_t: \
{ \
- Property::set_##type##_t set = p.setter.set_##type; \
+ GYOTO_DEBUG <<"Setting property of type " #type << endl; \
+ Property::set_##type##_t set = p.setter.set_##type; \
+ GYOTO_DEBUG_EXPR(set); \
if (!set) throwError("Can't set this Property"); \
(this->*set)(val); \
} \
break
switch (p.type) {
+ case Property::empty_t:
+ return;
___local_case(double);
___local_case(bool);
___local_case(long);
@@ -102,6 +114,8 @@ Value Object::get(Property const &p) const {
Gyoto::Value val;
switch (p.type) {
+ case Property::empty_t:
+ throwError("Can't get empty property");
___local_case(bool);
___local_case(double);
___local_case(long);
@@ -133,6 +147,8 @@ void Object::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
FactoryMessenger * childfmp=NULL;
string name=p.name;
switch (p.type) {
+ case Property::empty_t:
+ break;
case Property::bool_t:
fmp->setParameter(get(p)?name:p.name_false);
break;
diff --git a/lib/Photon.C b/lib/Photon.C
index be01bf0..48aa801 100644
--- a/lib/Photon.C
+++ b/lib/Photon.C
@@ -23,6 +23,7 @@
#include "GyotoScreen.h"
#include "GyotoDefs.h"
#include "GyotoError.h"
+#include "GyotoProperty.h"
#include <iostream>
#include <fstream>
@@ -40,8 +41,12 @@
using namespace std;
using namespace Gyoto;
+GYOTO_WORLDLINE_PROPERTIES(Photon, Object::properties);
+GYOTO_PROPERTY_FINALIZE(Photon, &GYOTO_WORLDLINE_FIRST_PROPERTY);
+
Photon::Photon() :
Worldline(),
+ Object("Photon"),
object_(NULL),
freq_obs_(1.), transmission_freqobs_(1.),
spectro_(NULL), transmission_(NULL)
@@ -571,20 +576,46 @@ void Photon::Refined::transmit(size_t i, double t) {
#ifdef GYOTO_USE_XERCES
+void Photon::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const {
+ if (p.name == "InitCoord") {
+ if (imin_ <= imax_) {
+ double coord[8];
+ getInitialCoord(coord);
+ // For massless particle, only 4-velocity is meaningfull
+ fmp -> setParameter("InitCoord", coord, 8);
+ }
+ Property const * const * parent = p.parents;
+ if (parent) {
+ for ( ; *parent; ++parent) {
+ fillProperty(fmp, **parent);
+ }
+ }
+ return;
+ }
+ Object::fillProperty(fmp, p);
+}
+
void Photon::fillElement(FactoryMessenger *fmp) const {
if (object_) fmp -> astrobj (object_) ;
- Worldline::fillElement(fmp);
+ Object::fillElement(fmp);
}
-SmartPointer<Photon> Gyoto::Photon::Subcontractor(FactoryMessenger* fmp) {
- string name="", content="";
- SmartPointer<Metric::Generic> gg = NULL;
- SmartPointer<Astrobj::Generic> ao = NULL;
+void Photon::setParameters(FactoryMessenger* fmp) {
+ wait_pos_ = 1;
+ metric(fmp->metric());
+ astrobj( fmp->astrobj() );
+ Object::setParameters(fmp);
+ wait_pos_ = 0;
+ if (init_vel_) {
+ delete[] init_vel_; init_vel_=NULL;
+ throwError("Worldline::setParameters(): "
+ "Velocity was found but not Position");
+ }
+}
+SmartPointer<Photon> Gyoto::Photon::Subcontractor(FactoryMessenger* fmp) {
SmartPointer<Photon> ph = new Photon();
- ph -> astrobj( fmp->astrobj() );
- ph -> Worldline::setParameters(fmp);
-
+ ph -> setParameters(fmp);
return ph;
}
#endif
diff --git a/lib/Property.C b/lib/Property.C
index 9f31b49..e3cd1fe 100644
--- a/lib/Property.C
+++ b/lib/Property.C
@@ -3,6 +3,9 @@
using namespace std ;
using namespace Gyoto ;
+Property::Property(Property const * const * ancestors)
+ : name(""), type(empty_t), parents(ancestors) {}
+
Property::Property(string n, set_long_t set, get_long_t get,
Property const * const * ancestors)
: name(n), type(long_t), parents(ancestors) {
diff --git a/lib/Star.C b/lib/Star.C
index 9f22787..ac74fab 100644
--- a/lib/Star.C
+++ b/lib/Star.C
@@ -18,7 +18,9 @@
*/
#include "GyotoUtils.h"
+#include "GyotoWorldline.h"
#include "GyotoStar.h"
+#include "GyotoProperty.h"
#include "GyotoPhoton.h"
#include "GyotoPowerLawSpectrum.h"
#include "GyotoBlackBodySpectrum.h"
@@ -36,6 +38,9 @@ using namespace std;
using namespace Gyoto;
using namespace Gyoto::Astrobj;
+GYOTO_WORLDLINE_PROPERTIES(Star, UniformSphere::properties);
+GYOTO_PROPERTY_FINALIZE(Star, &GYOTO_WORLDLINE_FIRST_PROPERTY);
+
Star::Star() :
UniformSphere("Star"),
Worldline()
@@ -117,21 +122,61 @@ double Star::rMax() {
return rmax_;
}
-int Star::setParameter(string name, string content, string unit) {
- if (!UniformSphere::setParameter(name, content, unit)) ; // if found
- else if (!Worldline ::setParameter(name, content, unit)) ; // do nothing
- else return 1;
+int Star::setParameter(std::string name,
+ std::string content,
+ std::string unit) {
+ double coord[8];
+ char* tc = const_cast<char*>(content.c_str());
+ if (name=="InitialCoordinate") {
+ name=="InitCoord";
+ return UniformSphere::setParameter(name, content, unit);
+ } else if (name=="Position") {
+ if (FactoryMessenger::parseArray(content, coord, 4) != 4)
+ throwError("Worldline \"Position\" requires exactly 4 tokens");
+ if (init_vel_) {
+ setInitCoord(coord, init_vel_);
+ delete[] init_vel_; init_vel_=NULL;
+ } else setPosition(coord);
+ wait_pos_ = 0;
+ } else if (name=="Velocity") {
+ if (FactoryMessenger::parseArray(content, coord, 3) != 3)
+ throwError("Worldline \"Velocity\" requires exactly 3 tokens");
+ if (wait_pos_) {
+ if (init_vel_) delete [] init_vel_;
+ init_vel_ = new double[3];
+ memcpy(init_vel_, coord, 3*sizeof(double));
+ } else setVelocity(coord);
+ }
+ else return UniformSphere::setParameter(name, content, unit);
return 0;
}
#ifdef GYOTO_USE_XERCES
-void Star::fillElement(FactoryMessenger *fmp) const {
- Worldline::fillElement(fmp);
- Astrobj::UniformSphere::fillElement(fmp);
+
+void Star::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const {
+ if (p.name == "InitCoord") {
+ if (imin_ <= imax_) {
+ double coord[8];
+ getInitialCoord(coord);
+ // For massive particule, express initial condition with 3-velocity
+ double vel[3] = {coord[5]/coord[4], coord[6]/coord[4], coord[7]/coord[4]};
+ fmp -> setParameter ("Position", coord, 4);
+ fmp -> setParameter ("Velocity", vel, 3);
+ }
+ Property const * const * parent = p.parents;
+ if (parent) {
+ for ( ; *parent; ++parent) {
+ fillProperty(fmp, **parent);
+ }
+ }
+ return;
+ }
+ UniformSphere::fillProperty(fmp, p);
}
void Star::setParameters(FactoryMessenger* fmp) {
wait_pos_ = 1;
+ metric(fmp->metric());
UniformSphere::setParameters(fmp);
wait_pos_ = 0;
if (init_vel_) {
@@ -140,4 +185,7 @@ void Star::setParameters(FactoryMessenger* fmp) {
"Velocity was found but not Position");
}
}
+void Star::fillElement(Gyoto::FactoryMessenger *fmp) const {
+ UniformSphere::fillElement(fmp);
+}
#endif
diff --git a/lib/StarTrace.C b/lib/StarTrace.C
index db3e813..d39e22c 100644
--- a/lib/StarTrace.C
+++ b/lib/StarTrace.C
@@ -36,7 +36,6 @@ using namespace Gyoto::Astrobj;
StarTrace::StarTrace() : Star()
{
Generic::kind_="StarTrace";
- Worldline::kind_="StarTrace";
xAllocateXYZ();
# ifdef GYOTO_DEBUG_ENABLED
GYOTO_DEBUG << "done." << endl;
@@ -49,7 +48,6 @@ StarTrace::StarTrace(SmartPointer<Metric::Generic> met, double rad,
Star(met, rad, pos, v)
{
Generic::kind_="StarTrace";
- Worldline::kind_="StarTrace";
xAllocateXYZ();
computeXYZ(i0_);
}
@@ -57,7 +55,6 @@ StarTrace::StarTrace(SmartPointer<Metric::Generic> met, double rad,
StarTrace::StarTrace(const StarTrace& o) : Star(o), tmin_(o.tmin_), tmax_(o.tmax_)
{
Generic::kind_="StarTrace";
- Worldline::kind_="StarTrace";
xAllocateXYZ();
size_t sz = get_nelements()*sizeof(double);
memcpy(x_+imin_, o.x_+imin_, sz);
@@ -69,7 +66,6 @@ StarTrace::StarTrace(const Star& o, double tmin, double tmax) :
Star(o), tmin_(tmin), tmax_(tmax)
{
Generic::kind_="StarTrace";
- Worldline::kind_="StarTrace";
xAllocateXYZ();
computeXYZ();
}
@@ -185,7 +181,7 @@ int StarTrace::setParameter(string name, string content, string unit) {
#ifdef GYOTO_USE_XERCES
void StarTrace::fillElement(FactoryMessenger *fmp) const {
- Star::fillElement(fmp);
+ UniformSphere::fillElement(fmp);
fmp->setParameter("TMin", tmin_);
fmp->setParameter("TMax", tmax_);
}
diff --git a/lib/UniformSphere.C b/lib/UniformSphere.C
index a492c3f..75578a2 100644
--- a/lib/UniformSphere.C
+++ b/lib/UniformSphere.C
@@ -38,7 +38,7 @@ using namespace std;
using namespace Gyoto;
using namespace Gyoto::Astrobj;
-GYOTO_PROPERTY_DOUBLE(UniformSphere, Radius, radius, Standard::properties);
+GYOTO_PROPERTY_DOUBLE_UNIT(UniformSphere, Radius, radius, Standard::properties);
GYOTO_PROPERTY_DOUBLE(UniformSphere, Alpha, alpha, &Radius);
GYOTO_PROPERTY_DOUBLE(UniformSphere,
DeltaMaxOverRadius, deltaMaxOverRadius, &Alpha);
@@ -256,11 +256,11 @@ void UniformSphere::radius(double r) {
safety_value_ = critical_value_*1.1+0.1;
}
-double UniformSphere::radius(std::string unit) const {
+double UniformSphere::radius(std::string const &unit) const {
return Units::FromGeometrical(radius(), unit, gg_);
}
-void UniformSphere::radius(double r, std::string unit) {
+void UniformSphere::radius(double r, std::string const &unit) {
radius(Units::ToGeometrical(r, unit, gg_));
}
diff --git a/lib/Worldline.C b/lib/Worldline.C
index 78328e7..1494343 100644
--- a/lib/Worldline.C
+++ b/lib/Worldline.C
@@ -31,22 +31,6 @@
using namespace std;
using namespace Gyoto;
-GYOTO_PROPERTY_BOOL(Worldline,
- HighOrderImages, PrimaryOnly, secondary,
- Object::properties);
-GYOTO_PROPERTY_DOUBLE(Worldline, RelTol, relTol, &HighOrderImages);
-GYOTO_PROPERTY_DOUBLE(Worldline, AbsTol, absTol, &RelTol);
-GYOTO_PROPERTY_DOUBLE(Worldline, DeltaMaxOverR, deltaMaxOverR, &AbsTol);
-GYOTO_PROPERTY_DOUBLE(Worldline, DeltaMax, deltaMax, &DeltaMaxOverR);
-GYOTO_PROPERTY_DOUBLE(Worldline, DeltaMin, deltaMin, &DeltaMax);
-GYOTO_PROPERTY_STRING(Worldline, Integrator, integrator, &DeltaMin);
-GYOTO_PROPERTY_SIZE_T(Worldline, MaxIter, maxiter, &Integrator);
-GYOTO_PROPERTY_BOOL(Worldline, Adaptive, NonAdaptive, adaptive, &MaxIter);
-GYOTO_PROPERTY_DOUBLE_UNIT(Worldline, Delta, delta, &Adaptive);
-GYOTO_PROPERTY_VECTOR_DOUBLE(Worldline, InitCoord, initCoord, &Delta);
-GYOTO_PROPERTY_METRIC(Worldline, Metric, metric, &InitCoord);
-GYOTO_PROPERTY_FINALIZE(Worldline, &::Metric);
-
Worldline::Worldline() : stopcond(0), metric_(NULL),
imin_(1), i0_(0), imax_(0), adaptive_(1),
secondary_(1),
@@ -295,76 +279,6 @@ void Worldline::tell(Gyoto::Hook::Teller* msg) {
reInit();
}
-#ifdef GYOTO_USE_XERCES
-
-void Worldline::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const {
- if (p.name == "InitCoord") {
- if (imin_ <= imax_) {
- double coord[8];
- getInitialCoord(coord);
- if (getMass()) {
- // For massive particule, express initial condition with 3-velocity
- double vel[3] = {coord[5]/coord[4], coord[6]/coord[4], coord[7]/coord[4]};
- fmp -> setParameter ("Position", coord, 4);
- fmp -> setParameter ("Velocity", vel, 3);
- } else {
- // For massless particle, only 4-velocity is meaningfull
- fmp -> setParameter("InitCoord", coord, 8);
- }
- }
- Property const * const * parent = p.parents;
- if (parent) {
- for ( ; *parent; ++parent) {
- fillProperty(fmp, **parent);
- }
- }
- return;
- }
- Object::fillProperty(fmp, p);
-}
-
-void Worldline::setParameters(FactoryMessenger* fmp) {
- wait_pos_ = 1;
- metric(fmp->metric());
- Object::setParameters(fmp);
- wait_pos_ = 0;
- if (init_vel_) {
- delete[] init_vel_; init_vel_=NULL;
- throwError("Worldline::setParameters(): "
- "Velocity was found but not Position");
- }
-}
-#endif
-
-int Worldline::setParameter(std::string name,
- std::string content,
- std::string unit) {
- double coord[8];
- char* tc = const_cast<char*>(content.c_str());
- if (name=="InitialCoordinate") {
- name=="InitCoord";
- return Object::setParameter(name, content, unit);
- } else if (name=="Position") {
- if (FactoryMessenger::parseArray(content, coord, 4) != 4)
- throwError("Worldline \"Position\" requires exactly 4 tokens");
- if (init_vel_) {
- setInitCoord(coord, init_vel_);
- delete[] init_vel_; init_vel_=NULL;
- } else setPosition(coord);
- wait_pos_ = 0;
- } else if (name=="Velocity") {
- if (FactoryMessenger::parseArray(content, coord, 3) != 3)
- throwError("Worldline \"Velocity\" requires exactly 3 tokens");
- if (wait_pos_) {
- if (init_vel_) delete [] init_vel_;
- init_vel_ = new double[3];
- memcpy(init_vel_, coord, 3*sizeof(double));
- } else setVelocity(coord);
- }
- else return Object::setParameter(name, content, unit);
- return 0;
-}
-
void Worldline::integrator(std::string const &type) {
if (type=="Legacy") state_ = new IntegState::Legacy(this);
#ifdef HAVE_BOOST
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git
More information about the Debian-astro-commits
mailing list