[Debian-astro-commits] [gyoto] 135/221: Finish converting Scenery to Object/Property
Thibaut Jean-Claude Paumard
thibaut at moszumanska.debian.org
Fri May 22 20:52:40 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 4cd3a4069075c18cc440b50617c946487feadd68
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date: Tue Dec 9 11:04:16 2014 +0100
Finish converting Scenery to Object/Property
---
bin/gyoto.C | 2 +-
include/GyotoScenery.h | 16 ++++----
lib/Scenery.C | 103 ++++++++++++++++++++++++++-----------------------
yorick/gyoto_Scenery.C | 6 +--
4 files changed, 65 insertions(+), 62 deletions(-)
diff --git a/bin/gyoto.C b/bin/gyoto.C
index 65d5c7f..8a8f6d0 100644
--- a/bin/gyoto.C
+++ b/bin/gyoto.C
@@ -363,7 +363,7 @@ int main(int argc, char** argv) {
cerr << "DEBUG: gyoto.C: flag_radtransf = ";
cerr << scenery -> astrobj() -> opticallyThin() << endl;
cerr << "DEBUG: gyoto.C: Requested quantities: ";
- cerr << scenery -> getRequestedQuantitiesString() << endl;
+ cerr << scenery -> requestedQuantitiesString() << endl;
}
char keyname[FLEN_KEYWORD];
diff --git a/include/GyotoScenery.h b/include/GyotoScenery.h
index f6385ab..ae3330f 100644
--- a/include/GyotoScenery.h
+++ b/include/GyotoScenery.h
@@ -315,13 +315,13 @@ class Gyoto::Scenery
* \param squant Coma-separated list of quantities, e.g. "Spectrum
* MinDistance". The order is not relevant.
*/
- void setRequestedQuantities(std::string squant) ;
+ void requestedQuantitiesString(std::string const &squant) ;
/// Get Scenery::quantities_
Quantity_t getRequestedQuantities() const ;
/// Get a string representation of Scenery::quantities_
- std::string getRequestedQuantitiesString() const ;
+ std::string requestedQuantitiesString() const ;
/// Get number of requested quantities of scalar nature
/**
@@ -380,8 +380,8 @@ class Gyoto::Scenery
void nThreads(size_t); ///< Set nthreads_;
size_t nThreads() const ; ///< Get nthreads_;
- void nProcesses(int); ///< Set nprocesses_;
- int nProcesses() const ; ///< Get nprocesses_;
+ void nProcesses(size_t); ///< Set nprocesses_;
+ size_t nProcesses() const ; ///< Get nprocesses_;
/// Set Scenery::intensity_converter_
void intensityConverter(std::string unit);
@@ -477,11 +477,9 @@ class Gyoto::Scenery
#ifdef GYOTO_USE_XERCES
public:
- /// Fill XML section
- /**
- * Akin to Astrobj::Generic::fillElement or
- * Metric::Generic::fillElement for instance.
- */
+ // 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);
/// Instanciate Scenery from an XML description.
static SmartPointer<Scenery> Subcontractor(Gyoto::FactoryMessenger*);
diff --git a/lib/Scenery.C b/lib/Scenery.C
index 2e4a84f..dbd7876 100644
--- a/lib/Scenery.C
+++ b/lib/Scenery.C
@@ -53,8 +53,58 @@ using namespace std;
#include "GyotoProperty.h"
GYOTO_PROPERTY_START(Scenery)
+GYOTO_PROPERTY_METRIC(Scenery, Metric, metric)
+GYOTO_PROPERTY_SCREEN(Scenery, Screen, screen)
+GYOTO_PROPERTY_ASTROBJ(Scenery, Astrobj, astrobj)
+GYOTO_PROPERTY_DOUBLE_UNIT(Scenery, MinimumTime, tMin)
+GYOTO_PROPERTY_SIZE_T(Scenery, NThreads, nThreads)
+GYOTO_PROPERTY_SIZE_T(Scenery, NProcesses, nProcesses)
+GYOTO_PROPERTY_STRING(Scenery, Quantities, requestedQuantitiesString)
GYOTO_WORLDLINE_PROPERTY_END(Scenery, Object::properties)
+#ifdef GYOTO_USE_XERCES
+void Scenery::fillProperty(Gyoto::FactoryMessenger *fmp,
+ Property const &p) const {
+ if (p.name == "InitCoord") {
+ std::vector<double> v=initCoord();
+ if (v[4] != 0) fmp -> setParameter(p.name, v);
+ } else Object::fillProperty(fmp, p);
+}
+
+void Scenery::fillElement(FactoryMessenger *fmp) {
+ if (metric()) fmp -> metric (metric()) ;
+ if (screen_) fmp -> screen (screen_) ;
+ if (astrobj()) fmp -> astrobj (astrobj()) ;
+ Object::fillElement(fmp);
+}
+
+SmartPointer<Scenery> Gyoto::Scenery::Subcontractor(FactoryMessenger* fmp) {
+ std::string name="", content="", unit="";
+ SmartPointer<Metric::Generic> gg = NULL;
+ SmartPointer<Screen> scr = NULL;
+ SmartPointer<Astrobj::Generic> ao = NULL;
+ Property const *prop=NULL;
+
+ gg = fmp->metric();
+ scr= fmp->screen();
+ ao = fmp->astrobj();
+
+ SmartPointer<Scenery> sc = new Scenery(gg, scr, ao);
+
+ int mpi=0;
+
+ while (fmp->getNextParameter(&name, &content, &unit)) {
+ if (name=="Metric" || name=="Screen" || name=="Astrobj") ;
+ else if (prop = sc->property(name))
+ sc -> setParameter(*prop, name, content, unit);
+ else GYOTO_WARNING << "Unrecognized XML entity in Scenery section: '"
+ << name << "'" << endl;
+ }
+ return sc;
+}
+#endif
+
+
///
Scenery::Scenery() :
@@ -139,8 +189,8 @@ std::vector<double> Scenery::initCoord() const { return ph_.initCoord();}
void Scenery::nThreads(size_t n) { nthreads_ = n; }
size_t Scenery::nThreads() const { return nthreads_; }
-void Scenery::nProcesses(int n) { nprocesses_ = n; }
-int Scenery::nProcesses() const { return nprocesses_; }
+void Scenery::nProcesses(size_t n) { nprocesses_ = n; }
+size_t Scenery::nProcesses() const { return nprocesses_; }
typedef struct SceneryThreadWorkerArg {
#ifdef HAVE_PTHREAD
@@ -635,7 +685,7 @@ SmartPointer<Photon> Scenery::clonePhoton() const {
void Scenery::setRequestedQuantities(Gyoto::Quantity_t quant)
{quantities_=quant;}
-void Scenery::setRequestedQuantities(std::string squant) {
+void Scenery::requestedQuantitiesString(std::string const &squant) {
quantities_=0;
char * tk = strtok(const_cast<char*>(squant.c_str()), " \t\n");
string tkk="", quant="", unit = "";
@@ -753,7 +803,7 @@ void Scenery::binSpectrumConverter(string unit) {
# endif
}
-std::string Scenery::getRequestedQuantitiesString() const {
+std::string Scenery::requestedQuantitiesString() const {
string squant = "";
Quantity_t quantities
= quantities_?quantities_:(astrobj()?astrobj()->getDefaultQuantities():0);
@@ -832,51 +882,6 @@ bool Scenery::secondary() const { return ph_.secondary(); }
void Scenery::maxiter(size_t miter) { ph_.maxiter(miter); }
size_t Scenery::maxiter() const { return ph_.maxiter(); }
-#ifdef GYOTO_USE_XERCES
-void Scenery::fillElement(FactoryMessenger *fmp) {
- if (metric()) fmp -> metric (metric()) ;
- if (screen_) fmp -> screen (screen_) ;
- if (astrobj()) fmp -> astrobj (astrobj()) ;
-
- if (getRequestedQuantities())
- fmp -> setParameter("Quantities", getRequestedQuantitiesString());
-
- fmp -> setParameter("MinimumTime", tMin());
- fmp -> setParameter("NThreads", nthreads_);
- fmp -> setParameter("NProcesses", nprocesses_);
-
- Object::fillElement(fmp);
-}
-
-SmartPointer<Scenery> Gyoto::Scenery::Subcontractor(FactoryMessenger* fmp) {
-
- string name="", content="", unit="";
- SmartPointer<Metric::Generic> gg = NULL;
- SmartPointer<Screen> scr = NULL;
- SmartPointer<Astrobj::Generic> ao = NULL;
- string squant = "";
-
- gg = fmp->metric();
- scr= fmp->screen();
- ao = fmp->astrobj();
-
- SmartPointer<Scenery> sc = new Scenery(gg, scr, ao);
-
- int mpi=0;
-
- while (fmp->getNextParameter(&name, &content, &unit)) {
- char* tc = const_cast<char*>(content.c_str());
- if (name=="Quantities") sc -> setRequestedQuantities(tc);
- else if (name=="MinimumTime") sc -> tMin(atof(tc), unit);
- else if (name=="NThreads") sc -> nThreads(atoi(tc));
- else if (name=="NProcesses") sc -> nProcesses(atoi(content.c_str()));
- else if (name=="Metric" || name=="Screen" || name=="Astrobj") ;
- else sc -> setParameter(name, content, unit);
- }
- return sc;
-}
-#endif
-
bool Gyoto::Scenery::am_worker=false;
void Gyoto::Scenery::mpiSpawn(int nbchildren) {
diff --git a/yorick/gyoto_Scenery.C b/yorick/gyoto_Scenery.C
index 3ea9cb6..64762d9 100644
--- a/yorick/gyoto_Scenery.C
+++ b/yorick/gyoto_Scenery.C
@@ -91,7 +91,7 @@ extern "C" {
long dims[2] = { rquant, nk };
ystring_t *squant = ypush_q(dims);
long k = 0;
- string requested=(*OBJ)->getRequestedQuantitiesString();
+ string requested=(*OBJ)->requestedQuantitiesString();
char *tk = strtok(const_cast<char*>(requested.c_str()), " \n\t");
while (tk!=NULL) {
if (k>=nk) y_error("BUG: too many tokens in quantity list");
@@ -106,7 +106,7 @@ extern "C" {
quants += " ";
quants += squant[k];
}
- (*OBJ) -> setRequestedQuantities(quants);
+ (*OBJ) -> requestedQuantitiesString(quants);
}
}
@@ -215,7 +215,7 @@ extern "C" {
squant = ypush_q(dims);
size_t k = 0;
char *tk =
- strtok(const_cast<char*>((*OBJ)->getRequestedQuantitiesString().c_str()),
+ strtok(const_cast<char*>((*OBJ)->requestedQuantitiesString().c_str()),
" \n\t");
while (tk!=NULL) {
if (k>=nk) y_error("BUG: too many tokens in quantity list");
--
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