[Debian-astro-commits] [gyoto] 204/221: Scenery: add updatePhoton and clonePhoton(i, j) APIs to get Photon with all tuning parameters from the Scenery Photon: fix findMin to work also when time is too large

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:47 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 cba8e4e56314432dee6e0ea1a6fbc1a4fccb9dd4
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Wed Mar 18 13:17:12 2015 +0100

    Scenery: add updatePhoton and clonePhoton(i, j) APIs to get Photon with all tuning parameters from the Scenery
    Photon: fix findMin to work also when time is too large
---
 include/GyotoScenery.h |  3 +++
 lib/Photon.C           |  5 +++++
 lib/Scenery.C          | 38 ++++++++++++++++++++++++++++----------
 yorick/gyoto_Scenery.C | 16 +++++++++++++++-
 4 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/include/GyotoScenery.h b/include/GyotoScenery.h
index ce781a3..f6d78e0 100644
--- a/include/GyotoScenery.h
+++ b/include/GyotoScenery.h
@@ -294,6 +294,9 @@ class Gyoto::Scenery
 
 
   SmartPointer<Photon> clonePhoton() const; ///< Clone the internal Photon
+  SmartPointer<Photon> clonePhoton(size_t i, size_t j); ///< Clone the internal Photon
+  SmartPointer<Photon> clonePhoton(double a, double d); ///< Clone the internal Photon
+  void updatePhoton(); ///< Update values in cached Photon
 
   double delta() const ; ///< Get default step in geometrical units
   double delta(const std::string &unit) const ;  ///< Get default step in specified units
diff --git a/lib/Photon.C b/lib/Photon.C
index e159134..858f4e0 100644
--- a/lib/Photon.C
+++ b/lib/Photon.C
@@ -494,6 +494,11 @@ double Photon::findMin(Functor::Double_constDoubleArray* object,
 
   while ( (fabs(t2-t1)>GYOTO_T_TOL) && (curval>threshold) ) {
     pcur[0] = 0.5*(t1+t2);
+    if ((pcur[0]==t1) ||pcur[0]==t2) {
+      GYOTO_SEVERE << "Photon::findMin(): dt still above GYOTO_T_TOL (t2-t1="
+		   << t2-t1 << ")";
+      break;
+    }
     getCoord(pcur, 1, pcur+1, pcur+2, pcur+3, pcur+4, pcur+5, pcur+6, pcur+7);
     curval=(*object)(pcur);
     if (val1<val2) {
diff --git a/lib/Scenery.C b/lib/Scenery.C
index 17b6d95..3b5301b 100644
--- a/lib/Scenery.C
+++ b/lib/Scenery.C
@@ -298,6 +298,30 @@ static void * SceneryThreadWorker (void *arg) {
   return NULL;
 }
 
+void Scenery::updatePhoton(){
+  if (screen_) {
+    ph_.spectrometer(screen_->spectrometer());
+    ph_.freqObs(screen_->freqObs());
+  }
+  ph_ . delta(delta_);
+}
+
+SmartPointer<Photon> Scenery::clonePhoton(size_t i, size_t j) {
+  updatePhoton();
+  double coord[8];
+  screen_ -> getRayCoord(size_t(1),size_t(1), coord);
+  ph_ . setInitCoord(coord, -1);
+  return ph_.clone();
+}
+
+SmartPointer<Photon> Scenery::clonePhoton(double a, double b) {
+  updatePhoton();
+  double coord[8];
+  screen_ -> getRayCoord(a, b, coord);
+  ph_ . setInitCoord(coord, -1);
+  return ph_.clone();
+}
+
 void Scenery::rayTrace(Screen::Coord2dSet & ij,
 		       Astrobj::Properties *data,
 		       double * impactcoords) {
@@ -330,12 +354,8 @@ void Scenery::rayTrace(Screen::Coord2dSet & ij,
      // Note : this is a BUG if this is required, should be done automagically.
 
   /// initialize photon once. It will be cloned.
-  SmartPointer<Spectrometer::Generic> spr = screen_->spectrometer();
-  ph_.spectrometer(spr);
-  ph_.freqObs(screen_->freqObs());
-  double coord[8];
-  screen_ -> getRayCoord(size_t(1),size_t(1), coord);
-  ph_ . setInitCoord(coord, -1);
+  updatePhoton();
+  SmartPointer<Spectrometer::Generic> spr = screen_ -> spectrometer();
   // delta is reset in operator()
 
   if (data) setPropertyConverters(data);
@@ -628,8 +648,7 @@ void Scenery::operator() (
     // is passed in particular when called in a multi-threaded
     // environment: it may really need to work on a given copy of the object.
     ph = &ph_;
-    ph -> spectrometer(spr);
-    ph -> freqObs(screen_->freqObs());
+    updatePhoton();
   }
   // Always reset delta
 # if GYOTO_DEBUG_ENABLED
@@ -674,8 +693,7 @@ void Scenery::operator() (
 
   if (!ph) {
     ph = &ph_;
-    ph -> spectrometer(spr);
-    ph -> freqObs(screen_->freqObs());
+    updatePhoton();
   }
   // Always reset delta
   ph -> delta(delta_);
diff --git a/yorick/gyoto_Scenery.C b/yorick/gyoto_Scenery.C
index 64762d9..c87ad58 100644
--- a/yorick/gyoto_Scenery.C
+++ b/yorick/gyoto_Scenery.C
@@ -124,7 +124,21 @@ extern "C" {
     /* CLONEPHOTON */
     if ((iarg=kiargs[++k])>=0) {
       if ((*rvset)++) y_error(rmsg);
-      *ypush_Photon() = (*OBJ)->clonePhoton();
+      int nb=0;
+      if (yarg_nil(iarg))
+	*ypush_Photon() = (*OBJ)->clonePhoton();
+      else if ((nb=yarg_number(iarg))==1) {
+	size_t i=ygets_l(iarg);
+	size_t j=ygets_l(piargs[0]);
+	if ((*paUsed)++) y_error(pmsg);
+	*ypush_Photon() = (*OBJ)->clonePhoton(i, j);
+      }
+      else if (nb==2) {
+	double a=ygets_d(iarg);
+	double d=ygets_d(piargs[0]);
+	if ((*paUsed)++) y_error(pmsg);
+	*ypush_Photon() = (*OBJ)->clonePhoton(a, d);
+      } else y_error("unsupported argument for clonephoton");
     }
 
     /* IMPACTCOORDS */

-- 
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