scalar_import.C

00001 /*
00002  * Member function of the Scalar class for initiating a Scalar from 
00003  * a Scalar defined on another mapping.
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
00008  *   Copyright (c) 1999-2001 Eric Gourgoulhon (Cmp version)
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 char scalar_import_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_import.C,v 1.3 2003/10/10 15:57:29 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: scalar_import.C,v 1.3 2003/10/10 15:57:29 j_novak Exp $
00033  * $Log: scalar_import.C,v $
00034  * Revision 1.3  2003/10/10 15:57:29  j_novak
00035  * Added the state one (ETATUN) to the class Scalar
00036  *
00037  * Revision 1.2  2003/10/01 13:04:44  e_gourgoulhon
00038  * The method Tensor::get_mp() returns now a reference (and not
00039  * a pointer) onto a mapping.
00040  *
00041  * Revision 1.1  2003/09/25 09:07:05  j_novak
00042  * Added the functions for importing from another mapping (to be tested).
00043  *
00044  *
00045  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_import.C,v 1.3 2003/10/10 15:57:29 j_novak Exp $
00046  *
00047  */
00048 
00049 // Headers C
00050 #include <math.h>
00051 
00052 // Headers Lorene
00053 #include "tensor.h"
00054 #include "param.h"
00055 #include "nbr_spx.h"
00056 
00057             //-------------------------------//
00058             //  Importation in all domains   //
00059             //-------------------------------//
00060 
00061 void Scalar::import(const Scalar& ci) {
00062     
00063     int nz = mp->get_mg()->get_nzone() ; 
00064     
00065     import(nz, ci) ; 
00066         
00067 }
00068 
00069             //--------------------------------------//
00070             //  Importation in inner domains only   //
00071             //--------------------------------------//
00072 
00073 void Scalar::import(int nzet, const Scalar& cm_d) {
00074     
00075     const Map* mp_d = &(cm_d.get_mp()) ; // Departure mapping
00076 
00077     // Trivial case : mappings identical !
00078     // -----------------------------------
00079     
00080     if (mp_d == mp) {
00081     *this = cm_d ; 
00082     return ; 
00083     }
00084     
00085     // Relative orientation of the two mappings
00086     // ----------------------------------------
00087  
00088     int align_rel = (mp->get_bvect_cart()).get_align()  
00089             * (mp_d->get_bvect_cart()).get_align() ;
00090             
00091     switch (align_rel) {
00092 
00093     case 1 : {  // the two mappings have aligned Cartesian axis
00094         import_align(nzet, cm_d) ; 
00095         break ; 
00096     }
00097 
00098     case -1 : {  // the two mappings have anti-aligned Cartesian axis
00099         import_anti(nzet, cm_d) ; 
00100         break ; 
00101     }
00102 
00103     case 0 : {  // general case 
00104         import_gal(nzet, cm_d) ; 
00105         break ; 
00106     }
00107 
00108     default : {  
00109         cout << "Scalar::import : unexpected value of align_rel : " 
00110          << align_rel << endl ; 
00111         abort() ; 
00112         break ; 
00113     }
00114 
00115     }
00116     
00117 }    
00118 
00119             //--------------------------------------//
00120             //     General case (axis not aligned)  //
00121             //--------------------------------------//
00122 
00123 
00124 void Scalar::import_gal(int nzet, const Scalar& cm_d) {
00125     
00126     const Map* mp_d = &(cm_d.get_mp()) ; // Departure mapping
00127 
00128     // Trivial case : mappings identical !
00129     // -----------------------------------
00130     
00131     if (mp_d == mp) {
00132     *this = cm_d ; 
00133     return ; 
00134     }
00135     
00136     // Another trivial case : null Scalar
00137     // -------------------------------
00138     
00139     if (cm_d.get_etat() == ETATZERO) {
00140     set_etat_zero() ; 
00141     return ; 
00142     }
00143 
00144     if (cm_d.get_etat() == ETATUN) {
00145     set_etat_one() ; 
00146     return ; 
00147     }
00148 
00149     // Protections
00150     // -----------
00151     
00152     assert(cm_d.get_etat() != ETATNONDEF) ; 
00153 
00154     if (cm_d.get_dzpuis() != 0) {
00155     cout << 
00156     "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00157          << endl ; 
00158     abort() ; 
00159     }
00160 
00161 
00162     const Mg3d* mg_a = mp->get_mg() ; 
00163     int nz_a = mg_a->get_nzone() ; 
00164     assert(nzet <= nz_a) ;     
00165 
00166 
00167     // General case :
00168     // -------------
00169     assert(cm_d.get_etat() == ETATQCQ) ;
00170     const Valeur& va_d = cm_d.get_spectral_va() ; 
00171     va_d.coef() ;       // The coefficients are required
00172     
00173 
00174     // Preparations for storing the result in *this 
00175     // --------------------------------------------
00176     del_t() ;   // delete all previously computed derived quantities
00177     
00178     set_etat_qcq() ;        // Set the state to ETATQCQ
00179     
00180     va.set_etat_c_qcq() ;   // Allocates the memory for the Mtbl va.c
00181                 //  if it does not exist already
00182     va.c->set_etat_qcq() ;  // Allocates the memory for the Tbl's in each
00183                 //  domain if they do not exist already
00184 
00185 
00186     // Absolute coordinates of the origin of the Departure mapping 
00187     double xo_d = mp_d->get_ori_x() ;     
00188     double yo_d = mp_d->get_ori_y() ;     
00189     double zo_d = mp_d->get_ori_z() ;     
00190 
00191     // Orientation relative to the Absolute frame of the Departure mapping
00192     double rot_phi_d = mp_d->get_rot_phi() ; 
00193 
00194     // Orientation relative to the Absolute frame of the Arrival mapping
00195     double rot_phi_a = mp->get_rot_phi() ; 
00196     
00197     // r, theta, phi, X, Y and Z on the Arrival mapping 
00198     //  update of the corresponding Coord's if necessary
00199     
00200     if ( (mp->r).c == 0x0 ) (mp->r).fait() ; 
00201     if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ; 
00202     if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ; 
00203     if ( (mp->xa).c == 0x0 ) (mp->xa).fait() ; 
00204     if ( (mp->ya).c == 0x0 ) (mp->ya).fait() ; 
00205     if ( (mp->za).c == 0x0 ) (mp->za).fait() ; 
00206 
00207     const Mtbl* mr_a = (mp->r).c ; 
00208     const Mtbl* mtet_a = (mp->tet).c ; 
00209     const Mtbl* mphi_a = (mp->phi).c ; 
00210     const Mtbl* mxa_a = (mp->xa).c ;
00211     const Mtbl* mya_a = (mp->ya).c ;
00212     const Mtbl* mza_a = (mp->za).c ;
00213 
00214     Param par_precis ;      // Required precision in the method Map::val_lx
00215     int nitermax = 100 ;    // Maximum number of iteration in the secant method
00216     int niter ; 
00217     double precis = 1e-15 ; // Absolute precision in the secant method
00218     par_precis.add_int(nitermax) ;  
00219     par_precis.add_int_mod(niter) ; 
00220     par_precis.add_double(precis) ; 
00221 
00222 
00223     // Loop of the Arrival domains where the computation is to be performed
00224     // --------------------------------------------------------------------
00225     
00226     for (int l=0; l < nzet; l++) {
00227     
00228     int nr = mg_a->get_nr(l) ;
00229     int nt = mg_a->get_nt(l) ;
00230     int np = mg_a->get_np(l) ;
00231     
00232     
00233     const double* pr_a = mr_a->t[l]->t ;      // Pointer on the values of r
00234     const double* ptet_a = mtet_a->t[l]->t ;  // Pointer on the values of theta
00235     const double* pphi_a = mphi_a->t[l]->t ;  // Pointer on the values of phi
00236     const double* pxa_a = mxa_a->t[l]->t ;    // Pointer on the values of X
00237     const double* pya_a = mya_a->t[l]->t ;    // Pointer on the values of Y
00238     const double* pza_a = mza_a->t[l]->t ;    // Pointer on the values of Z
00239     
00240     (va.c->t[l])->set_etat_qcq() ;       // Allocates the array of double to
00241                          //  store the result 
00242     double* ptx = (va.c->t[l])->t ;      // Pointer on the allocated array
00243     
00244     
00245     // Loop on all the grid points in the considered arrival domain:
00246         
00247     for (int k=0 ; k<np ; k++) {
00248         for (int j=0 ; j<nt ; j++) {
00249         for (int i=0 ; i<nr ; i++) {
00250 
00251             double r = *pr_a ; 
00252             double rd, tetd, phid ;
00253             if (r == __infinity) {
00254             rd = r ;
00255             tetd = *ptet_a ;
00256             phid = *pphi_a + rot_phi_a - rot_phi_d ;
00257             if (phid < 0) phid += 2*M_PI ;
00258             }
00259             else {
00260             // Coordinates in a Cartesian frame centered on
00261             //  the Departure mapping and whose axes are
00262             //  parallel to those of the Absolue Frame
00263             double xd = *pxa_a - xo_d ;
00264             double yd = *pya_a - yo_d ;
00265             double zd = *pza_a - zo_d ;
00266             
00267             // Spherical coordinates on the Departure mapping
00268             double rhod2 = xd*xd + yd*yd ; 
00269             double rhod = sqrt( rhod2 ) ;
00270             rd = sqrt(rhod2 + zd*zd) ;
00271             tetd = atan2(rhod, zd) ;
00272             phid = atan2(yd, xd) - rot_phi_d ; // (rotation)
00273             if (phid < 0) phid += 2*M_PI ;
00274             }           
00275 
00276 
00277             // NB: to increase the efficiency, the method Scalar::val_point
00278             //  is not invoked; the method Mtbl_cf::val_point is 
00279             //  called directly instead. 
00280 
00281             // Value of the grid coordinates (l,xi) corresponding to
00282             //  (rd,tetd,phid) :
00283             
00284             int ld ;        // domain index
00285             double xxd ;    // radial coordinate xi in [0,1] or [-1,1]
00286             mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00287 
00288             // Value of the Departure Scalar at the obtained point:
00289             *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00290 
00291             // Next point : 
00292             ptx++ ;   
00293             pr_a++ ;  
00294             ptet_a++ ;  
00295             pphi_a++ ; 
00296             pxa_a++ ;  
00297             pya_a++ ;  
00298             pza_a++ ;  
00299 
00300         }
00301         }
00302     }   
00303     
00304         
00305     }   // End of the loop on the Arrival domains
00306     
00307     // In the remaining domains, *this is set to zero:
00308     // ----------------------------------------------
00309     
00310     if (nzet < nz_a) {
00311     annule(nzet, nz_a - 1) ; 
00312     }
00313     
00314     // Treatment of dzpuis
00315     // -------------------
00316     
00317     
00318     set_dzpuis(0) ; 
00319 
00320 }
00321 
00322 
00323         //-----------------------------------------//
00324         //   Case of Cartesian axis anti-aligned   //
00325         //-----------------------------------------//
00326 
00327 
00328 void Scalar::import_anti(int nzet, const Scalar& cm_d) {
00329     
00330     // Trivial case : null Scalar
00331     // ------------------------
00332     
00333     if (cm_d.get_etat() == ETATZERO) {
00334     set_etat_zero() ; 
00335     return ; 
00336     }
00337 
00338     if (cm_d.get_etat() == ETATUN) {
00339     set_etat_one() ; 
00340     return ; 
00341     }
00342 
00343     const Map* mp_d = &(cm_d.get_mp()) ; // Departure mapping
00344 
00345     // Protections
00346     // -----------
00347     int align = (mp->get_bvect_cart()).get_align() ;
00348 
00349     assert( align  * (mp_d->get_bvect_cart()).get_align() == -1 ) ; 
00350     
00351     assert(cm_d.get_etat() == ETATQCQ) ;
00352 
00353     if (cm_d.get_dzpuis() != 0) {
00354     cout << 
00355     "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00356          << endl ; 
00357     abort() ; 
00358     }
00359 
00360 
00361     const Mg3d* mg_a = mp->get_mg() ; 
00362     int nz_a = mg_a->get_nzone() ; 
00363     assert(nzet <= nz_a) ;     
00364 
00365     const Valeur& va_d = cm_d.get_spectral_va() ; 
00366     va_d.coef() ;       // The coefficients are required
00367     
00368 
00369     // Preparations for storing the result in *this 
00370     // --------------------------------------------
00371     del_t() ;   // delete all previously computed derived quantities
00372     
00373     set_etat_qcq() ;        // Set the state to ETATQCQ
00374     
00375     va.set_etat_c_qcq() ;   // Allocates the memory for the Mtbl va.c
00376                 //  if it does not exist already
00377     va.c->set_etat_qcq() ;  // Allocates the memory for the Tbl's in each
00378                 //  domain if they do not exist already
00379 
00380 
00381     // Departure (x,y,z) coordinates of the origin of the Arrival mapping :
00382 
00383     double xx_a, yy_a, zz_a ; 
00384     if (align == 1) {
00385     xx_a = mp_d->get_ori_x() - mp->get_ori_x() ; 
00386     yy_a = mp_d->get_ori_y() - mp->get_ori_y() ; 
00387     }
00388     else {
00389     xx_a = mp->get_ori_x() - mp_d->get_ori_x() ; 
00390     yy_a = mp->get_ori_y() - mp_d->get_ori_y() ; 
00391     }
00392     zz_a = mp->get_ori_z() - mp_d->get_ori_z() ; 
00393 
00394     
00395     // r, theta, phi, x, y and z on the Arrival mapping 
00396     //  update of the corresponding Coord's if necessary
00397     
00398     if ( (mp->r).c == 0x0 ) (mp->r).fait() ; 
00399     if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ; 
00400     if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ; 
00401     if ( (mp->x).c == 0x0 ) (mp->x).fait() ; 
00402     if ( (mp->y).c == 0x0 ) (mp->y).fait() ; 
00403     if ( (mp->z).c == 0x0 ) (mp->z).fait() ; 
00404 
00405     const Mtbl* mr_a = (mp->r).c ; 
00406     const Mtbl* mtet_a = (mp->tet).c ; 
00407     const Mtbl* mphi_a = (mp->phi).c ; 
00408     const Mtbl* mx_a = (mp->x).c ;
00409     const Mtbl* my_a = (mp->y).c ;
00410     const Mtbl* mz_a = (mp->z).c ;
00411 
00412     Param par_precis ;      // Required precision in the method Map::val_lx
00413     int nitermax = 100 ;    // Maximum number of iteration in the secant method
00414     int niter ; 
00415     double precis = 1e-15 ; // Absolute precision in the secant method
00416     par_precis.add_int(nitermax) ;  
00417     par_precis.add_int_mod(niter) ; 
00418     par_precis.add_double(precis) ; 
00419 
00420 
00421     // Loop of the Arrival domains where the computation is to be performed
00422     // --------------------------------------------------------------------
00423     
00424     for (int l=0; l < nzet; l++) {
00425     
00426     int nr = mg_a->get_nr(l) ;
00427     int nt = mg_a->get_nt(l) ;
00428     int np = mg_a->get_np(l) ;
00429     
00430     
00431     const double* pr_a = mr_a->t[l]->t ;      // Pointer on the values of r
00432     const double* ptet_a = mtet_a->t[l]->t ;  // Pointer on the values of theta
00433     const double* pphi_a = mphi_a->t[l]->t ;  // Pointer on the values of phi
00434     const double* px_a = mx_a->t[l]->t ;      // Pointer on the values of X
00435     const double* py_a = my_a->t[l]->t ;      // Pointer on the values of Y
00436     const double* pz_a = mz_a->t[l]->t ;      // Pointer on the values of Z
00437     
00438     (va.c->t[l])->set_etat_qcq() ;       // Allocates the array of double to
00439                          //  store the result 
00440     double* ptx = (va.c->t[l])->t ;      // Pointer on the allocated array
00441     
00442     
00443     // Loop on all the grid points in the considered arrival domain:
00444         
00445     for (int k=0 ; k<np ; k++) {
00446         for (int j=0 ; j<nt ; j++) {
00447         for (int i=0 ; i<nr ; i++) {
00448 
00449             double r = *pr_a ; 
00450             double rd, tetd, phid ;
00451             if (r == __infinity) {
00452             rd = r ;
00453             tetd = *ptet_a ;
00454             phid = *pphi_a + M_PI ;
00455             if (phid < 0) phid += 2*M_PI ;
00456             }
00457             else {
00458 
00459             // Cartesian coordinates on the Departure mapping
00460             double xd = - *px_a + xx_a ; 
00461             double yd = - *py_a + yy_a ; 
00462             double zd = *pz_a + zz_a ; 
00463 
00464             // Spherical coordinates on the Departure mapping
00465             double rhod2 = xd*xd + yd*yd ; 
00466             double rhod = sqrt( rhod2 ) ;
00467             rd = sqrt(rhod2 + zd*zd) ;
00468             tetd = atan2(rhod, zd) ;
00469             phid = atan2(yd, xd) ; 
00470             if (phid < 0) phid += 2*M_PI ;
00471             }           
00472 
00473 
00474             // NB: to increase the efficiency, the method Scalar::val_point
00475             //  is not invoked; the method Mtbl_cf::val_point is 
00476             //  called directly instead. 
00477 
00478             // Value of the grid coordinates (l,xi) corresponding to
00479             //  (rd,tetd,phid) :
00480             
00481             int ld ;        // domain index
00482             double xxd ;    // radial coordinate xi in [0,1] or [-1,1]
00483             mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00484 
00485             // Value of the Departure Scalar at the obtained point:
00486             *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00487 
00488             // Next point : 
00489             ptx++ ;   
00490             pr_a++ ;  
00491             ptet_a++ ;  
00492             pphi_a++ ; 
00493             px_a++ ;  
00494             py_a++ ;  
00495             pz_a++ ;  
00496 
00497         }
00498         }
00499     }   
00500     
00501         
00502     }   // End of the loop on the Arrival domains
00503     
00504     // In the remaining domains, *this is set to zero:
00505     // ----------------------------------------------
00506     
00507     if (nzet < nz_a) {
00508     annule(nzet, nz_a - 1) ; 
00509     }
00510     
00511     // Treatment of dzpuis
00512     // -------------------
00513     
00514     
00515     set_dzpuis(0) ; 
00516 
00517 }
00518 
00519 
00520         //-------------------------------------//
00521         //   Case of aligned Cartesian axis    //
00522         //-------------------------------------//
00523 
00524 
00525 void Scalar::import_align(int nzet, const Scalar& cm_d) {
00526     
00527     // Trivial case : null Scalar
00528     // ------------------------
00529     
00530     if (cm_d.get_etat() == ETATZERO) {
00531     set_etat_zero() ; 
00532     return ; 
00533     }
00534     if (cm_d.get_etat() == ETATUN) {
00535     set_etat_one() ; 
00536     return ; 
00537     }
00538 
00539     const Map* mp_d = &(cm_d.get_mp()) ; // Departure mapping
00540 
00541     // Protections
00542     // -----------
00543     int align = (mp->get_bvect_cart()).get_align() ;
00544 
00545     assert( align  * (mp_d->get_bvect_cart()).get_align() == 1 ) ; 
00546     
00547     assert(cm_d.get_etat() == ETATQCQ) ;
00548 
00549     if (cm_d.get_dzpuis() != 0) {
00550     cout << 
00551     "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00552          << endl ; 
00553     abort() ; 
00554     }
00555 
00556 
00557     const Mg3d* mg_a = mp->get_mg() ; 
00558     int nz_a = mg_a->get_nzone() ; 
00559     assert(nzet <= nz_a) ;     
00560 
00561     const Valeur& va_d = cm_d.get_spectral_va() ; 
00562     va_d.coef() ;       // The coefficients are required
00563     
00564 
00565     // Preparations for storing the result in *this 
00566     // --------------------------------------------
00567     del_t() ;   // delete all previously computed derived quantities
00568     
00569     set_etat_qcq() ;        // Set the state to ETATQCQ
00570     
00571     va.set_etat_c_qcq() ;   // Allocates the memory for the Mtbl va.c
00572                 //  if it does not exist already
00573     va.c->set_etat_qcq() ;  // Allocates the memory for the Tbl's in each
00574                 //  domain if they do not exist already
00575 
00576 
00577     // Departure (x,y,z) coordinates of the origin of the Arrival mapping :
00578 
00579     double xx_a, yy_a, zz_a ; 
00580     if (align == 1) {
00581     xx_a = mp->get_ori_x() - mp_d->get_ori_x() ; 
00582     yy_a = mp->get_ori_y() - mp_d->get_ori_y() ; 
00583     }
00584     else {
00585     xx_a = mp_d->get_ori_x() - mp->get_ori_x() ; 
00586     yy_a = mp_d->get_ori_y() - mp->get_ori_y() ; 
00587     }
00588     zz_a = mp->get_ori_z() - mp_d->get_ori_z() ; 
00589 
00590     
00591     // r, theta, phi, x, y and z on the Arrival mapping 
00592     //  update of the corresponding Coord's if necessary
00593     
00594     if ( (mp->r).c == 0x0 ) (mp->r).fait() ; 
00595     if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ; 
00596     if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ; 
00597     if ( (mp->x).c == 0x0 ) (mp->x).fait() ; 
00598     if ( (mp->y).c == 0x0 ) (mp->y).fait() ; 
00599     if ( (mp->z).c == 0x0 ) (mp->z).fait() ; 
00600 
00601     const Mtbl* mr_a = (mp->r).c ; 
00602     const Mtbl* mtet_a = (mp->tet).c ; 
00603     const Mtbl* mphi_a = (mp->phi).c ; 
00604     const Mtbl* mx_a = (mp->x).c ;
00605     const Mtbl* my_a = (mp->y).c ;
00606     const Mtbl* mz_a = (mp->z).c ;
00607 
00608     Param par_precis ;      // Required precision in the method Map::val_lx
00609     int nitermax = 100 ;    // Maximum number of iteration in the secant method
00610     int niter ; 
00611     double precis = 1e-15 ; // Absolute precision in the secant method
00612     par_precis.add_int(nitermax) ;  
00613     par_precis.add_int_mod(niter) ; 
00614     par_precis.add_double(precis) ; 
00615 
00616 
00617     // Loop of the Arrival domains where the computation is to be performed
00618     // --------------------------------------------------------------------
00619     
00620     for (int l=0; l < nzet; l++) {
00621     
00622     int nr = mg_a->get_nr(l) ;
00623     int nt = mg_a->get_nt(l) ;
00624     int np = mg_a->get_np(l) ;
00625     
00626     
00627     const double* pr_a = mr_a->t[l]->t ;      // Pointer on the values of r
00628     const double* ptet_a = mtet_a->t[l]->t ;  // Pointer on the values of theta
00629     const double* pphi_a = mphi_a->t[l]->t ;  // Pointer on the values of phi
00630     const double* px_a = mx_a->t[l]->t ;      // Pointer on the values of X
00631     const double* py_a = my_a->t[l]->t ;      // Pointer on the values of Y
00632     const double* pz_a = mz_a->t[l]->t ;      // Pointer on the values of Z
00633     
00634     (va.c->t[l])->set_etat_qcq() ;       // Allocates the array of double to
00635                          //  store the result 
00636     double* ptx = (va.c->t[l])->t ;      // Pointer on the allocated array
00637     
00638     
00639     // Loop on all the grid points in the considered arrival domain:
00640         
00641     for (int k=0 ; k<np ; k++) {
00642         for (int j=0 ; j<nt ; j++) {
00643         for (int i=0 ; i<nr ; i++) {
00644 
00645             double r = *pr_a ; 
00646             double rd, tetd, phid ;
00647             if (r == __infinity) {
00648             rd = r ;
00649             tetd = *ptet_a ;
00650             phid = *pphi_a ;
00651             }
00652             else {
00653 
00654             // Cartesian coordinates on the Departure mapping
00655             double xd = *px_a + xx_a ; 
00656             double yd = *py_a + yy_a ; 
00657             double zd = *pz_a + zz_a ; 
00658 
00659             // Spherical coordinates on the Departure mapping
00660             double rhod2 = xd*xd + yd*yd ; 
00661             double rhod = sqrt( rhod2 ) ;
00662             rd = sqrt(rhod2 + zd*zd) ;
00663             tetd = atan2(rhod, zd) ;
00664             phid = atan2(yd, xd) ; 
00665             if (phid < 0) phid += 2*M_PI ;
00666             }           
00667 
00668 
00669             // NB: to increase the efficiency, the method Scalar::val_point
00670             //  is not invoked; the method Mtbl_cf::val_point is 
00671             //  called directly instead. 
00672 
00673             // Value of the grid coordinates (l,xi) corresponding to
00674             //  (rd,tetd,phid) :
00675             
00676             int ld ;        // domain index
00677             double xxd ;    // radial coordinate xi in [0,1] or [-1,1]
00678             mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00679 
00680             // Value of the Departure Scalar at the obtained point:
00681             *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00682 
00683             // Next point : 
00684             ptx++ ;   
00685             pr_a++ ;  
00686             ptet_a++ ;  
00687             pphi_a++ ; 
00688             px_a++ ;  
00689             py_a++ ;  
00690             pz_a++ ;  
00691 
00692         }
00693         }
00694     }   
00695     
00696         
00697     }   // End of the loop on the Arrival domains
00698     
00699     // In the remaining domains, *this is set to zero:
00700     // ----------------------------------------------
00701     
00702     if (nzet < nz_a) {
00703     annule(nzet, nz_a - 1) ; 
00704     }
00705     
00706     // Treatment of dzpuis
00707     // -------------------
00708     
00709     
00710     set_dzpuis(0) ; 
00711 
00712 }

Generated on Tue Feb 7 01:35:19 2012 for LORENE by  doxygen 1.4.6