map_et.C

00001 /*
00002  *  Methods of class Map_et
00003  */
00004 
00005 /*
00006  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00007  *
00008  *   This file is part of LORENE.
00009  *
00010  *   LORENE is free software; you can redistribute it and/or modify
00011  *   it under the terms of the GNU General Public License as published by
00012  *   the Free Software Foundation; either version 2 of the License, or
00013  *   (at your option) any later version.
00014  *
00015  *   LORENE is distributed in the hope that it will be useful,
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *   GNU General Public License for more details.
00019  *
00020  *   You should have received a copy of the GNU General Public License
00021  *   along with LORENE; if not, write to the Free Software
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 
00027 char map_et_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_et.C,v 1.13 2008/09/29 13:23:51 j_novak Exp $" ;
00028 
00029 /*
00030  * $Id: map_et.C,v 1.13 2008/09/29 13:23:51 j_novak Exp $
00031  * $Log: map_et.C,v $
00032  * Revision 1.13  2008/09/29 13:23:51  j_novak
00033  * Implementation of the angular mapping associated with an affine
00034  * mapping. Things must be improved to take into account the domain index.
00035  *
00036  * Revision 1.12  2008/08/27 08:48:26  jl_cornou
00037  * Added_R_JACO02 case
00038  *
00039  * Revision 1.11  2005/11/30 11:09:07  p_grandclement
00040  * Changes for the Bin_ns_bh project
00041  *
00042  * Revision 1.10  2004/03/25 10:29:23  j_novak
00043  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00044  *
00045  * Revision 1.9  2004/01/29 08:50:03  p_grandclement
00046  * Modification of Map::operator==(const Map&) and addition of the surface
00047  * integrales using Scalar.
00048  *
00049  * Revision 1.8  2003/10/15 10:36:52  e_gourgoulhon
00050  * In method fait_poly(): changed local variable name x to x1, not to shadow
00051  *  Coord's x.
00052  *
00053  * Revision 1.7  2003/07/07 20:01:43  p_grandclement
00054  * change assert in constructor for map_et from a surface
00055  *
00056  * Revision 1.6  2003/06/04 21:11:55  p_grandclement
00057  * Correction of separation in odd-even harmonics
00058  *
00059  * Revision 1.5  2002/10/16 14:36:41  j_novak
00060  * Reorganization of #include instructions of standard C++, in order to
00061  * use experimental version 3 of gcc.
00062  *
00063  * Revision 1.4  2002/05/07 07:10:44  e_gourgoulhon
00064  * Compatibilty with xlC compiler on IBM SP2:
00065  *  suppressed the parenthesis around argument of instruction new:
00066  *  e.g.   aa = new (Tbl*[nzone])  --->  aa = new Tbl*[nzone]
00067  *      result = new (Param)   --->  result = new Param
00068  *
00069  * Revision 1.3  2002/01/15 15:53:06  p_grandclement
00070  * I have had a constructor fot map_et using the equation of the surface
00071  * of the star.
00072  *
00073  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00074  *
00075  * All writing/reading to a binary file are now performed according to
00076  * the big endian convention, whatever the system is big endian or
00077  * small endian, thanks to the functions fwrite_be and fread_be
00078  *
00079  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00080  * LORENE
00081  *
00082  * Revision 1.11  2001/02/28  11:04:20  eric
00083  * 1ere version testee de resize.
00084  *
00085  * Revision 1.10  2001/02/26  17:29:42  eric
00086  * Ajout de la fonction resize.
00087  *
00088  * Revision 1.9  2000/08/18  11:10:48  eric
00089  * Ajout de l'operateur d'affectation a un autre Map_et.
00090  *
00091  * Revision 1.8  2000/01/24  16:42:36  eric
00092  * Ajout de la fonction virtuelle operator=(const Map_af& ).
00093  *
00094  * Revision 1.7  2000/01/24  11:03:28  eric
00095  * Correction d'une erreur dans le constructeur par lecture de fichier:
00096  *  ff et gg doivent etre construits sur mgi.get_angu() et non sur mgi.
00097  *
00098  * Revision 1.6  1999/12/20  10:24:49  eric
00099  * Ajout des fonctions de lecture des parametres de Map_et:
00100  *   get_alpha(), get_beta(), get_ff(), get_gg().
00101  *
00102  * Revision 1.5  1999/12/17  11:20:08  eric
00103  * Ajout de la fonction homothetie.
00104  *
00105  * Revision 1.4  1999/12/17  09:14:30  eric
00106  * Amelioration de l'affichage.
00107  *
00108  * Revision 1.3  1999/11/24  16:31:41  eric
00109  * Ajout des fonctions set_ff et set_gg.
00110  *
00111  * Revision 1.2  1999/11/24  11:22:44  eric
00112  * Map_et : fonctions de constructions amies.
00113  *
00114  * Revision 1.1  1999/11/22  10:37:36  eric
00115  * Initial revision
00116  *
00117  *
00118  * $Header: /cvsroot/Lorene/C++/Source/Map/map_et.C,v 1.13 2008/09/29 13:23:51 j_novak Exp $
00119  *
00120  */
00121 
00122 // headers C
00123 #include <math.h>
00124 
00125 // headers Lorene
00126 #include "proto.h"
00127 #include "map.h"
00128 #include "utilitaires.h"
00129 #include "unites.h"
00130 
00131             //--------------//
00132             // Constructors //
00133             //--------------//
00134 
00135 // -----------------------
00136 // Constructor from a grid
00137 // -----------------------
00138 Map_et::Map_et(const Mg3d& mgrille, const double* bornes) 
00139           : Map_radial(mgrille),
00140             aasx( mgrille.get_nr(0) ), 
00141             aasx2( mgrille.get_nr(0) ), 
00142             zaasx( mgrille.get_nr(mgrille.get_nzone()-1) ), 
00143             zaasx2( mgrille.get_nr(mgrille.get_nzone()-1) ), 
00144             bbsx( mgrille.get_nr(0) ), 
00145             bbsx2( mgrille.get_nr(0) ), 
00146         ff(mgrille.get_angu()) , 
00147         gg(mgrille.get_angu())   
00148 {
00149     // The Coord rsxdxdr and rsx2drdx are constructed by the default Coord 
00150     // constructor
00151     
00152     // Assignement of the building functions of the Coord's
00153     // ----------------------------------------------------
00154     set_coord() ; 
00155     
00156     
00157     // alpha and beta
00158     // --------------
00159     int nzone = mg->get_nzone() ;
00160     
00161     alpha = new double[nzone] ;
00162     beta = new double[nzone] ;
00163 
00164     for (int l=0 ; l<nzone ; l++) {
00165     switch (mg->get_type_r(l)) {
00166         case RARE:  {
00167         alpha[l] = bornes[l+1] - bornes[l] ;
00168         beta[l] = bornes[l] ;
00169         break ; 
00170         }
00171 
00172         case FINJAC: {
00173         alpha[l] = (bornes[l+1] - bornes[l]) * .5;
00174         beta[l] = (bornes[l+1] + bornes[l]) * .5;
00175         break;
00176         }
00177         
00178         case FIN:   {
00179         alpha[l] = (bornes[l+1] - bornes[l]) * .5 ;
00180         beta[l] = (bornes[l+1] + bornes[l]) * .5 ;
00181         break ;
00182         }
00183         
00184         case UNSURR: {
00185         double umax = double(1) / bornes[l] ;
00186         double umin = double(1) /bornes[l+1] ;
00187         alpha[l] = (umin - umax) * double(0.5) ;  // u est une fonction decroissante
00188         beta[l] = (umin + umax) * double(0.5) ;   //  de l'indice i en r
00189         break ;
00190         }
00191         
00192         default:    {
00193         cout << "Map_et::Map_et: unkown type_r ! " << endl ;
00194         abort () ;
00195         break ;
00196         }
00197         
00198     }
00199     }       // End of the loop onto the domains
00200 
00201 
00202     // Radial polynomials A(x) and B(x)
00203     // --------------------------------
00204     
00205     fait_poly() ; 
00206 
00207     // Initialisation at zero of the functions F(theta',phi') and G(theta',phi')
00208     // -------------------------------------------------------------------------
00209 
00210     ff.set_etat_zero() ;
00211     gg.set_etat_zero() ;
00212     
00213     ff.std_base_scal() ;    // Standard spectral bases for F 
00214     gg.std_base_scal() ;    // Standard spectral bases for G
00215 
00216 }
00217 
00218 Map_et::Map_et(const Mg3d& grille, const double* r_lim, const Tbl& S_0) : 
00219                 Map_radial(grille),
00220             aasx(grille.get_nr(0) ), 
00221             aasx2(grille.get_nr(0) ), 
00222             zaasx(grille.get_nr(grille.get_nzone()-1) ), 
00223             zaasx2(grille.get_nr(grille.get_nzone()-1) ), 
00224             bbsx(grille.get_nr(0) ), 
00225             bbsx2(grille.get_nr(0) ), 
00226         ff(grille.get_angu()) , 
00227         gg(grille.get_angu()) {
00228   
00229   assert (S_0.get_ndim() == 2) ;
00230   assert (S_0.get_dim(0) == grille.get_nt(0)) ;
00231   assert (S_0.get_dim(1) == grille.get_np(0)) ;
00232 
00233   Map_et mapping (grille, r_lim) ;
00234 
00235   int nz = grille.get_nzone() ;
00236   assert (nz >2) ;
00237 
00238   // Le noyau :
00239   int np = grille.get_np(0) ;
00240   int nt = grille.get_nt(0) ;
00241   
00242   double * cf = new double [nt*(np+2)] ;
00243   for (int k=0 ; k<np ; k++)
00244     for (int j=0 ; j<nt ; j++)
00245       cf[k*nt+j] = S_0(k,j) - S_0(0,0) ;
00246 
00247   int* deg = new int [3] ;
00248   deg[0] = np ;
00249   deg[1] = nt ;
00250   deg[2] = 1 ;
00251 
00252   int* dim = new int [3] ;
00253   dim[0] = np+2 ;
00254   dim[1] = nt ;
00255   dim[2] = 1 ;
00256   
00257   Tbl ff_nucleus (np,nt) ;
00258   ff_nucleus.set_etat_qcq() ;
00259 
00260   Tbl gg_nucleus (np,nt) ;
00261   gg_nucleus.set_etat_qcq() ;
00262   
00263   // On recupere la base en phi :
00264   int base_p = grille.std_base_scal().get_base_p(0) ;
00265   // Selon les cas (pas tres propre mais bon ...)
00266   double * odd ; 
00267   double * even ;
00268   double * coloc_odd ;
00269   double * coloc_even ;
00270 
00271   switch (base_p) {
00272   case P_COSSIN:
00273      cfpcossin (deg,dim,cf) ;
00274 
00275      // Separation des harmoniques paires et impaires :
00276      odd = new double [nt*(np+2)] ;
00277      even = new double [nt*(np+2)] ;
00278 
00279 
00280      for (int k=0 ; k<np+2 ; k++)
00281        if ((k%4 == 0) || (k%4==1))
00282      for (int j=0 ; j<nt ; j++) {
00283        odd[k*nt+j] = 0 ;
00284        even[k*nt+j] = cf[k*nt+j] ;
00285      }
00286        else
00287      if ((k%4 == 2) || (k%4 == 3))
00288      for (int j=0 ; j<nt ; j++) {
00289        even[k*nt+j] = 0 ;
00290        odd[k*nt+j] = cf[k*nt+j] ;
00291      }
00292 
00293      else {
00294        cout << "Erreur bizzare..." << endl ;
00295        abort() ;
00296      }
00297 
00298      coloc_odd = new double [nt*np] ;
00299      coloc_even = new double [nt*np] ;
00300 
00301      cipcossin (deg,dim,deg,odd,coloc_odd) ;
00302      cipcossin (deg,dim,deg,even,coloc_even) ;
00303      for (int k=0 ; k<np ; k++)
00304        for (int j=0 ; j<nt ; j++) {
00305      gg_nucleus.set(k,j) = coloc_even[k*nt+j] ;
00306      ff_nucleus.set(k,j) = coloc_odd[k*nt+j] ;
00307        }
00308 
00309      delete [] even ;
00310      delete [] odd ;
00311      delete [] coloc_even ;
00312      delete [] coloc_odd ;
00313      delete[] dim ;
00314      delete [] deg ;
00315      delete [] cf ;
00316      
00317      break;
00318   default:
00319     cout << "Base_p != P_COSSIN not implemented in Map_et constructor" << 
00320       endl ;
00321     abort() ;
00322   }
00323 
00324   double mu_nucleus = - min(gg_nucleus) ;
00325   double alpha_nucleus = S_0(0,0)-mu_nucleus ;
00326 
00327   ff_nucleus /= alpha_nucleus ;
00328   gg_nucleus += mu_nucleus ;
00329   gg_nucleus /= alpha_nucleus ;
00330   
00331   // First shell : much simpler no ?
00332   Tbl ff_shell (np,nt) ;
00333   ff_shell.set_etat_qcq() ;
00334   ff_shell = S_0 - S_0(0,0) ;
00335   
00336   double lambda_shell = -max(ff_shell) ;
00337   
00338   double R_ext = r_lim[2] ;
00339 
00340   double beta_shell = (R_ext+S_0(0,0)-lambda_shell)/2. ;
00341   double alpha_shell = (R_ext-S_0(0,0)+lambda_shell)/2. ;
00342   
00343   ff_shell += lambda_shell ;
00344   ff_shell /= alpha_shell ;
00345 
00346   ff.annule_hard() ;
00347   gg.annule_hard() ;
00348   
00349   ff.set_etat_c_qcq() ;
00350   gg.set_etat_c_qcq() ;
00351 
00352   for (int k=0 ; k<np ; k++)
00353     for (int j=0 ; j<nt ; j++) {
00354       ff.set(0,k,j,0) = ff_nucleus(k,j) ;
00355       gg.set(0,k,j,0) = gg_nucleus(k,j) ;
00356       ff.set(1,k,j,0) = ff_shell(k,j) ;
00357     }
00358 
00359   gg.annule(1,nz-1) ;
00360   ff.annule(2,nz-1) ;
00361   
00362   ff.std_base_scal() ;
00363   gg.std_base_scal() ;
00364   
00365   alpha = new double[nz] ;
00366   alpha[0] = alpha_nucleus ;
00367   alpha[1] = alpha_shell ;
00368   
00369   beta = new double[nz] ;
00370   beta[0] = 0 ;
00371   beta[1] = beta_shell ;
00372   for (int i=2 ; i<nz ; i++) {
00373     alpha[i] = mapping.get_alpha()[i] ;
00374     beta[i] = mapping.get_beta()[i] ;
00375   }
00376 
00377   fait_poly() ;
00378   set_coord() ;
00379 }
00380 // ------------------
00381 // Copy constructor 
00382 // ------------------
00383 Map_et::Map_et(const Map_et& mpi) : Map_radial(mpi) , 
00384             aasx( mpi.aasx ), 
00385             aasx2( mpi.aasx2 ), 
00386             zaasx( mpi.zaasx ), 
00387             zaasx2( mpi.zaasx2 ), 
00388             bbsx( mpi.bbsx ), 
00389             bbsx2( mpi.bbsx2 ), 
00390         ff(mpi.ff) , 
00391         gg(mpi.gg)   
00392 {
00393     // Assignement of the building functions of the Coord's
00394     // ----------------------------------------------------
00395     set_coord() ; 
00396 
00397     // alpha and beta
00398     // --------------
00399     int nzone = mg->get_nzone() ;
00400     
00401     alpha = new double[nzone] ;
00402     beta = new double[nzone] ;
00403 
00404     for (int l=0 ; l<nzone ; l++) {
00405     alpha[l] = mpi.alpha[l] ;
00406     beta[l] = mpi.beta[l] ;
00407     }
00408     
00409     // Radial polynomials A(x) and B(x)
00410     // --------------------------------
00411     
00412     fait_poly() ; 
00413 
00414 } 
00415             //------------------------------------------//
00416             //  Modification of the mapping parameters  //
00417             //------------------------------------------//
00418 
00419 void Map_et::set_alpha(double alpha0, int l) {
00420     
00421     assert(l>=0) ; 
00422     assert(l<mg->get_nzone()) ; 
00423     
00424     alpha[l] = alpha0 ; 
00425     
00426     reset_coord() ; 
00427     
00428 }
00429 
00430 void Map_et::set_beta(double beta0, int l) {
00431     
00432     assert(l>=0) ; 
00433     assert(l<mg->get_nzone()) ; 
00434     
00435     beta[l] = beta0 ; 
00436     
00437     reset_coord() ; 
00438     
00439 }
00440 
00441 // ---------------------
00442 // Constructor from file
00443 // ---------------------
00444 Map_et::Map_et(const Mg3d& mgi, FILE* fich) 
00445           : Map_radial(mgi, fich),
00446             aasx( mgi.get_nr(0) ), 
00447             aasx2( mgi.get_nr(0) ), 
00448             zaasx( mgi.get_nr(mgi.get_nzone()-1) ), 
00449             zaasx2( mgi.get_nr(mgi.get_nzone()-1) ), 
00450             bbsx( mgi.get_nr(0) ), 
00451             bbsx2( mgi.get_nr(0) ), 
00452         ff(*(mgi.get_angu()), fich) , 
00453         gg(*(mgi.get_angu()), fich)   
00454 {
00455     // The Coord rsxdxdr and rsx2drdx are constructed by the default Coord 
00456     // constructor
00457     
00458     // alpha and beta
00459     // --------------
00460     int nz = mg->get_nzone() ;
00461     alpha = new double[nz] ;
00462     beta = new double[nz] ;
00463     fread_be(alpha, sizeof(double), nz, fich) ; 
00464     fread_be(beta, sizeof(double), nz, fich) ;  
00465 
00466     // Assignement of the building functions of the Coord's
00467     // ----------------------------------------------------
00468     set_coord() ; 
00469     
00470     // Radial polynomials A(x) and B(x)
00471     // --------------------------------
00472     
00473     fait_poly() ; 
00474 
00475 }
00476 
00477             //------------//
00478             // Destructor //
00479             //------------//
00480 
00481 Map_et::~Map_et() {
00482     
00483     delete [] alpha ;
00484     delete [] beta ;
00485     
00486     for (int l=0 ; l<mg->get_nzone(); l++) {
00487     delete aa[l] ;
00488     delete daa[l] ;
00489     delete ddaa[l] ;
00490     delete bb[l] ;
00491     delete dbb[l] ;
00492     delete ddbb[l] ;
00493     }
00494     delete [] aa ; 
00495     delete [] daa ; 
00496     delete [] ddaa ; 
00497     delete [] bb ; 
00498     delete [] dbb ; 
00499     delete [] ddbb ; 
00500     
00501 }
00502 
00503 
00504                 //------------//
00505                 // Assignment //
00506                 //------------//
00507 
00508 void Map_et::operator=(const Map_et& mpi) {
00509     
00510     assert(mpi.get_mg() == mg) ; 
00511     
00512     set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ; 
00513     
00514     set_rot_phi( mpi.get_rot_phi() ) ; 
00515     
00516     // The members bvect_spher and bvect_cart are treated by the functions
00517     //  set_ori and set_rot_phi.
00518     
00519     for (int l=0; l<mg->get_nzone(); l++){
00520     alpha[l] = mpi.get_alpha()[l] ; 
00521     beta[l] = mpi.get_beta()[l] ; 
00522     }
00523     
00524     ff = mpi.ff ; 
00525     gg = mpi.gg ; 
00526     
00527     reset_coord() ; // update of all the Coords
00528         
00529 }
00530 
00531 
00532 
00533 
00534 void Map_et::operator=(const Map_af& mpi) {
00535     
00536     assert(mpi.get_mg() == mg) ; 
00537     
00538     set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ; 
00539     
00540     set_rot_phi( mpi.get_rot_phi() ) ; 
00541     
00542     // The members bvect_spher and bvect_cart are treated by the functions
00543     //  set_ori and set_rot_phi.
00544     
00545     for (int l=0; l<mg->get_nzone(); l++){
00546     alpha[l] = mpi.get_alpha()[l] ; 
00547     beta[l] = mpi.get_beta()[l] ; 
00548     }
00549     
00550     ff = 0 ; 
00551     gg = 0 ; 
00552     
00553     reset_coord() ; // update of all the Coords
00554         
00555 }
00556 
00557 void Map_et::set_ff(const Valeur& ffi) {
00558     
00559     ff = ffi ; 
00560     
00561     reset_coord() ; // update of all the Coords
00562     
00563 }
00564 
00565 void Map_et::set_gg(const Valeur& ggi) {
00566     
00567     gg = ggi ; 
00568     
00569     reset_coord() ; // update of all the Coords
00570     
00571 }
00572 
00573 
00574 
00575         //-------------------------------------------------//
00576         //  Assignment of the Coord building functions    //
00577         //-------------------------------------------------//
00578         
00579 void Map_et::set_coord(){
00580 
00581     // ... Coord's introduced by the base class Map : 
00582     r.set(this, map_et_fait_r) ;
00583     tet.set(this, map_et_fait_tet) ;
00584     phi.set(this, map_et_fait_phi) ;
00585     sint.set(this, map_et_fait_sint) ;
00586     cost.set(this, map_et_fait_cost) ;
00587     sinp.set(this, map_et_fait_sinp) ;
00588     cosp.set(this, map_et_fait_cosp) ;
00589 
00590     x.set(this, map_et_fait_x) ;
00591     y.set(this, map_et_fait_y) ;
00592     z.set(this, map_et_fait_z) ;
00593 
00594     xa.set(this, map_et_fait_xa) ;
00595     ya.set(this, map_et_fait_ya) ;
00596     za.set(this, map_et_fait_za) ;
00597     
00598     // ... Coord's introduced by the base class Map_radial : 
00599     xsr.set(this, map_et_fait_xsr) ;
00600     dxdr.set(this, map_et_fait_dxdr) ;
00601     drdt.set(this, map_et_fait_drdt) ;
00602     stdrdp.set(this, map_et_fait_stdrdp) ;
00603     srdrdt.set(this, map_et_fait_srdrdt) ;
00604     srstdrdp.set(this, map_et_fait_srstdrdp) ;
00605     sr2drdt.set(this, map_et_fait_sr2drdt) ;
00606     sr2stdrdp.set(this, map_et_fait_sr2stdrdp) ;
00607     d2rdx2.set(this, map_et_fait_d2rdx2) ;
00608     lapr_tp.set(this, map_et_fait_lapr_tp) ;
00609     d2rdtdx.set(this, map_et_fait_d2rdtdx) ;
00610     sstd2rdpdx.set(this, map_et_fait_sstd2rdpdx) ;
00611     sr2d2rdt2.set(this, map_et_fait_sr2d2rdt2) ;
00612     
00613     //... Coord's which belong to the class Map_et only : 
00614     rsxdxdr.set(this, map_et_fait_rsxdxdr) ; 
00615     rsx2drdx.set(this, map_et_fait_rsx2drdx) ; 
00616 
00617 }
00618 
00619             //--------------------------//
00620             //  Reset of the Coord's    //
00621             //--------------------------//
00622 
00623 void Map_et::reset_coord() {
00624 
00625     // Coord's of all the class derived from Map_radial:
00626     
00627     Map_radial::reset_coord() ;
00628     
00629     // Coord's specific to Map_et
00630     
00631     rsxdxdr.del_t() ; 
00632     rsx2drdx.del_t() ; 
00633      
00634 }
00635     
00636         //------------------------------------------------------//
00637         // Construction of the radial polynomials A(x) and B(x) //
00638         //------------------------------------------------------//
00639 
00640 void Map_et::fait_poly() {
00641     
00642     int nzone = mg->get_nzone() ;
00643 
00644     aa = new Tbl*[nzone] ;
00645     daa = new Tbl*[nzone] ;
00646     ddaa = new Tbl*[nzone] ;
00647     bb = new Tbl*[nzone] ;
00648     dbb = new Tbl*[nzone] ;
00649     ddbb = new Tbl*[nzone] ;
00650 
00651     for (int l=0; l<nzone; l++) {
00652     int nr = mg->get_nr(l) ;
00653     aa[l] = new Tbl(nr) ;
00654     daa[l] = new Tbl(nr) ;
00655     ddaa[l] = new Tbl(nr) ;
00656     bb[l] = new Tbl(nr) ;
00657     dbb[l] = new Tbl(nr) ;
00658     ddbb[l] = new Tbl(nr) ;
00659     }
00660 
00661     // Values in the nucleus
00662     // ---------------------
00663     assert( mg->get_type_r(0) == RARE || mg->get_type_r(0) == FINJAC ) ;
00664     
00665     aa[0]->set_etat_qcq() ;     // Memory allocation for the Tbl 
00666     daa[0]->set_etat_qcq() ; 
00667     ddaa[0]->set_etat_qcq() ; 
00668     aasx.set_etat_qcq() ; 
00669     aasx2.set_etat_qcq() ; 
00670 
00671     bb[0]->set_etat_qcq() ;     
00672     dbb[0]->set_etat_qcq() ; 
00673     ddbb[0]->set_etat_qcq() ; 
00674     bbsx.set_etat_qcq() ; 
00675     bbsx2.set_etat_qcq() ; 
00676     
00677     for (int i=0; i<mg->get_nr(0); i++) {
00678 
00679     double x1 =  (mg->get_grille3d(0))->x[i]  ;
00680     double x2 = x1 * x1 ;
00681     double x3 = x1 * x2 ; 
00682 
00683                 //##...... A(x) = 2 x^2 - x^4 : 
00684                 //  (aa[0])->t[i] = x2 * (2. - x2) ;
00685                 //  (daa[0])->t[i] = 4. * x * (1. + x) * (1. - x)  ;
00686                 //  (ddaa[0])->t[i] = 4. *(1. - 3.* x2)  ;
00687                 //  aasx->t[i] = x * (2. - x2) ;
00688                 //  aasx2->t[i] = 2. - x2 ;
00689 
00690     //...... A(x) = 3 x^4 - 2 x^6 : 
00691 
00692     aa[0]->set(i) = x2 * x2 * (3. - 2.*x2) ;
00693     daa[0]->set(i) = 12. * x3 * (1. + x1) * (1. - x1)  ;
00694     ddaa[0]->set(i) = 12. *x2 *(3. - 5.* x2)  ;
00695     aasx.set(i) = x3 * (3. - 2.*x2) ;
00696     aasx2.set(i) = x2 * (3. - 2.*x2) ;
00697 
00698     //... B(x) = 5/2 x^3 - 3/2 x^5   :  
00699 
00700     bb[0]->set(i) = 0.5 * x3 * (5. - 3.* x2) ; 
00701     dbb[0]->set(i) = 7.5 * x2 * (1. + x1) * (1. - x1) ;
00702     ddbb[0]->set(i) =  15. * x1 * ( 1. - 2.*x2 )   ;
00703     bbsx.set(i) = 0.5 * x2 * (5. - 3.* x2) ;
00704     bbsx2.set(i) = 0.5 * x1 * (5. - 3.* x2) ;
00705     }
00706     
00707     // Values in the shells and the outermost domain
00708     // ---------------------------------------------
00709 
00710     for (int l=1; l<nzone; l++) {
00711 
00712     assert( (mg->get_type_r(l) == FIN)|| (mg->get_type_r(l) == UNSURR) ) ;
00713 
00714     aa[l]->set_etat_qcq() ;     // Memory allocation for the Tbl 
00715     daa[l]->set_etat_qcq() ; 
00716     ddaa[l]->set_etat_qcq() ; 
00717 
00718     bb[l]->set_etat_qcq() ;     
00719     dbb[l]->set_etat_qcq() ; 
00720     ddbb[l]->set_etat_qcq() ; 
00721     
00722     for (int i=0; i<mg->get_nr(l); i++) {
00723 
00724         double x1 = (mg->get_grille3d(l))->x[i] ;
00725         double xm1 = x1 - 1. ; 
00726         double xp1 = x1 + 1. ; 
00727 
00728         //... A(x) = 1/4 (x-1)^2 (x+2) = 1/4(x^3 -3x +2)  : 
00729 
00730         aa[l]->set(i) = 0.25* xm1 * xm1 * (x1 + 2.) ;
00731         daa[l]->set(i) = 0.75* xm1 * xp1  ;
00732         ddaa[l]->set(i) = 1.5* x1 ;
00733 
00734         //... B(x) = 1/4 (x+1)^2 (-x+2) = 1/4(-x^3 +3x +2)   : 
00735 
00736         bb[l]->set(i) = 0.25* xp1 * xp1 * (2. - x1) ;
00737         dbb[l]->set(i) = - 0.75* xm1 * xp1  ;
00738         ddbb[l]->set(i) = - 1.5* x1  ;
00739     }
00740 
00741     }       // End of the loop onto the domains
00742 
00743     // Special case of a compactified outermost domain
00744     // -----------------------------------------------
00745     
00746     int nzm1 = nzone - 1 ; 
00747     if ( mg->get_type_r(nzm1) == UNSURR ) {
00748 
00749     zaasx.set_etat_qcq() ;      // Memory allocation for the Tbl 
00750     zaasx2.set_etat_qcq() ;
00751     
00752     for (int i=0; i<mg->get_nr(nzm1); i++) {
00753         
00754         double x1 = (mg->get_grille3d(nzm1))->x[i] ; 
00755         zaasx.set(i) = 0.25 * (x1 - 1.) * (2. + x1) ;       // A(x)/(x-1)
00756         zaasx2.set(i) = 0.25 * (2. + x1) ;          // A(x)/(x-1)^2
00757         
00758     }
00759     
00760     bb[nzm1]->set_etat_zero() ; 
00761     dbb[nzm1]->set_etat_zero() ; 
00762     ddbb[nzm1]->set_etat_zero() ; 
00763     
00764     }  
00765   
00766 }
00767 
00768 
00769 
00770             //----------------//
00771             // Save in a file //
00772             //----------------//
00773 
00774 void Map_et::sauve(FILE* fich) const {
00775 
00776     Map_radial::sauve(fich) ;   // Write of the elements common to all the
00777                 // classes derived from Map_radial
00778     
00779     ff.sauve(fich) ;        // Write of F(theta',phi')
00780     gg.sauve(fich) ;        // Write of G(theta',phi')
00781     
00782     // Write of alpha and beta :
00783     int nz = mg->get_nzone() ;
00784     fwrite_be(alpha, sizeof(double), nz, fich) ;    
00785     fwrite_be(beta, sizeof(double), nz, fich) ; 
00786     
00787 }
00788 
00789         //---------------------------//
00790         //        Printing       //
00791         //---------------------------//
00792 
00793 ostream & Map_et::operator>>(ostream & ost) const {
00794 
00795   using namespace Unites ;
00796 
00797     ost << 
00798     "Radial mapping of form r = xi + A(xi)F(t,p) + B(xi)G(t,p) (class Map_et)" 
00799     << endl ; 
00800     int nz = mg->get_nzone() ;
00801     for (int l=0; l<nz; l++) {
00802     ost << "     Domain #" << l << " : alpha_l = " << alpha[l] 
00803       << " ,  beta_l = " << beta[l] << endl ;  
00804     }
00805     ost << endl << "Function F(theta', phi') : " << endl ; 
00806     ost << "-------------------------  " << endl ; 
00807     ff.affiche_seuil(ost) ; 
00808     ost << endl <<"Function G(theta', phi') : " << endl ; 
00809     ost << "-------------------------  " << endl ; 
00810     gg.affiche_seuil(ost) ; 
00811 
00812     int type_t = mg->get_type_t() ; 
00813     int type_p = mg->get_type_p() ; 
00814 
00815     ost << endl 
00816     << "Values of r at the outer boundary of each domain [km] :" << endl ; 
00817     ost << "------------------------------------------------------" << endl ; 
00818     ost << "   1/ for theta = Pi/2 and phi = 0 : " << endl ; 
00819     ost << "       val_r :   " ;
00820     for (int l=0; l<nz; l++) {
00821     ost << " " << val_r(l, 1., M_PI/2, 0) / km ; 
00822     }
00823     ost << endl ; 
00824 
00825     if ( type_t == SYM ) {
00826     assert( (type_p == SYM) || (type_p == NONSYM) ) ; 
00827     ost << "       Coord r : " ; 
00828     for (int l=0; l<nz; l++) {
00829         int nrm1 = mg->get_nr(l) - 1 ; 
00830         int ntm1 = mg->get_nt(l) - 1 ; 
00831         ost << " " << (+r)(l, 0, ntm1, nrm1) / km ; 
00832     }
00833     ost << endl ; 
00834     }
00835 
00836     ost << "   2/ for theta = Pi/2 and phi = Pi/2 : " << endl ; 
00837     ost << "       val_r :   " ;
00838     for (int l=0; l<nz; l++) {
00839     ost << " " << val_r(l, 1., M_PI/2, M_PI/2) / km ; 
00840     }
00841     ost << endl ; 
00842 
00843     if ( type_t == SYM ) {
00844     ost << "       Coord r : " ; 
00845     for (int l=0; l<nz; l++) {
00846         int nrm1 = mg->get_nr(l) - 1 ; 
00847         int ntm1 = mg->get_nt(l) - 1 ; 
00848         int np = mg->get_np(l) ;
00849         if ( (type_p == NONSYM) && (np % 4 == 0) ) {
00850         ost << " " << (+r)(l, np/4, ntm1, nrm1) / km ; 
00851         }
00852         if ( type_p == SYM ) {
00853         ost << " " << (+r)(l, np/2, ntm1, nrm1) / km ; 
00854         }
00855     }
00856     ost << endl ; 
00857     }
00858 
00859     ost << "   3/ for theta = Pi/2 and phi = Pi : " << endl ; 
00860     ost << "       val_r :   " ;
00861     for (int l=0; l<nz; l++) {
00862     ost << " " << val_r(l, 1., M_PI/2, M_PI) / km ; 
00863     }
00864     ost << endl ; 
00865 
00866     if ( (type_t == SYM) && (type_p == NONSYM) ) {
00867     ost << "       Coord r : " ; 
00868     for (int l=0; l<nz; l++) {
00869         int nrm1 = mg->get_nr(l) - 1 ; 
00870         int ntm1 = mg->get_nt(l) - 1 ; 
00871         int np = mg->get_np(l) ;
00872         ost << " " << (+r)(l, np/2, ntm1, nrm1) / km ; 
00873     }
00874     ost << endl ; 
00875     }
00876 
00877     ost << "   4/ for theta = 0 : " << endl ; 
00878     ost << "       val_r :   " ;
00879     for (int l=0; l<nz; l++) {
00880     ost << " " << val_r(l, 1., 0., 0.) / km ; 
00881     }
00882     ost << endl ; 
00883 
00884     ost << "       Coord r : " ; 
00885     for (int l=0; l<nz; l++) {
00886     int nrm1 = mg->get_nr(l) - 1 ; 
00887     ost << " " << (+r)(l, 0, 0, nrm1) / km ; 
00888     }
00889     ost << endl ; 
00890 
00891     return ost ;
00892     
00893 }    
00894 
00895             //------------------//
00896             //  Homothetie      //
00897             //------------------//
00898 
00899 
00900 void Map_et::homothetie(double fact) {
00901 
00902     int nz = mg->get_nzone() ; 
00903     
00904     for (int l=0; l<nz; l++) {
00905     if (mg->get_type_r(l) == UNSURR) {
00906         alpha[l] /= fact ;
00907         beta[l] /= fact ;
00908     }
00909     else {
00910         alpha[l] *= fact ;
00911         beta[l] *= fact ;
00912     }
00913     }
00914     
00915     reset_coord() ; 
00916     
00917 }
00918 
00919             //----------------------------//
00920             //  Rescaling of one domain   //
00921             //----------------------------//
00922 
00923 void Map_et::resize(int l, double lambda) {
00924 
00925     // Protections
00926     // -----------
00927     if (mg->get_type_r(l) != FIN) {
00928     cout << "Map_et::resize can be applied only to a shell !" << endl ; 
00929     abort() ;
00930     }
00931 
00932     // New values of alpha, beta, F and G in domain l :
00933     // ----------------------------------------------
00934     double n_alpha = 0.5 * ( (lambda + 1.) * alpha[l] +  
00935                  (lambda - 1.) * beta[l] ) ; 
00936 
00937     double n_beta = 0.5 * ( (lambda - 1.) * alpha[l] +  
00938                 (lambda + 1.) * beta[l] ) ; 
00939                 
00940     ff.set(l) = alpha[l] / n_alpha  * ff(l) ; 
00941     gg.set(l) = lambda * alpha[l] / n_alpha  * gg(l) ; 
00942 
00943     alpha[l] = n_alpha ; 
00944     beta[l] = n_beta ; 
00945     
00946     // New values of alpha, beta, F and G in  in domain l+1 :
00947     // ----------------------------------------------------
00948     assert(l<mg->get_nzone()-1) ; 
00949     int lp1 = l + 1 ; 
00950     
00951     if (mg->get_type_r(lp1) == UNSURR) {        // compactified case
00952     
00953     assert(ff(lp1).get_etat() == ETATZERO ) ; 
00954     assert(gg(lp1).get_etat() == ETATZERO ) ; 
00955     
00956     alpha[lp1] = - 0.5 / ( alpha[l] + beta[l] ) ; 
00957     beta[lp1] = - alpha[lp1] ; 
00958     
00959     }
00960     else{   // non-compactified case
00961     
00962     assert( mg->get_type_r(lp1) == FIN ) ;
00963     n_alpha = 0.5 * ( alpha[lp1] - alpha[l] + beta[lp1] - beta[l] ) ; 
00964     n_beta =  0.5 * ( alpha[lp1] + alpha[l] + beta[lp1] + beta[l] ) ; 
00965     
00966     ff.set(lp1) = alpha[l] / n_alpha * gg(l) ; 
00967     gg.set(lp1) = alpha[lp1] / n_alpha * gg(lp1) ; 
00968     
00969     alpha[lp1] = n_alpha ; 
00970     beta[lp1] = n_beta ; 
00971     }
00972     
00973     // The coords are no longer up to date :
00974     reset_coord() ; 
00975 } 
00976 
00977 
00978 // Comparison operator :
00979 bool Map_et::operator==(const Map& mpi) const {
00980   
00981   // Precision of the comparison
00982   double precis = 1e-10 ;
00983   bool resu = true ;
00984 
00985   // Dynamic cast pour etre sur meme Map...
00986   const Map_et* mp0 = dynamic_cast<const Map_et*>(&mpi) ;
00987   if (mp0 == 0x0)
00988     resu = false ;
00989   else {
00990     if (*mg != *(mpi.get_mg()))
00991       resu = false ;
00992     
00993     if (fabs(ori_x-mpi.get_ori_x()) > precis) resu = false ;
00994     if (fabs(ori_y-mpi.get_ori_y()) > precis) resu = false ;
00995     if (fabs(ori_z-mpi.get_ori_z()) > precis)  resu = false ;
00996 
00997     if (bvect_spher != mpi.get_bvect_spher()) resu = false ;
00998     if (bvect_cart != mpi.get_bvect_cart()) resu = false ;
00999 
01000     int nz = mg->get_nzone() ;
01001     for (int i=0 ; i<nz ; i++) {
01002       if (fabs(alpha[i]-mp0->alpha[i])/fabs(alpha[i]) > precis) 
01003     resu = false ;
01004       if ((i!=0) && (i!=nz-1))
01005     if (fabs(beta[i]-mp0->beta[i])/fabs(beta[i]) > precis) 
01006     resu = false ;
01007     }
01008 
01009     if (max(diffrelmax(ff, mp0->ff)) > precis)
01010       resu = false ;
01011     if (max(diffrelmax(gg, mp0->gg)) > precis)
01012       resu = false ;
01013   }
01014 
01015   return resu ;
01016 }
01017         //--------------------------------------//
01018         // Extraction of the mapping parameters //
01019         //--------------------------------------//
01020 
01021 const double* Map_et::get_alpha() const {
01022     return alpha ; 
01023 }
01024 
01025 const double* Map_et::get_beta() const {
01026     return beta ; 
01027 }
01028 
01029 const Valeur& Map_et::get_ff() const {
01030     return ff ; 
01031 }
01032 
01033 const Valeur& Map_et::get_gg() const {
01034     return gg ; 
01035 }
01036 
01037 
01038 // To be done
01039 //-----------
01040 const Map_af& Map_et::mp_angu(int) const {
01041     const char* f = __FILE__ ;
01042     c_est_pas_fait(f) ;
01043     p_mp_angu = new Map_af(*this) ;
01044     return *p_mp_angu ;
01045 }
01046 

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