et_rot_lambda_grv2.C

00001 /*
00002  * Method Etoile_rot::lambda_grv2.
00003  *
00004  * (see file etoile.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License as published by
00015  *   the Free Software Foundation; either version 2 of the License, or
00016  *   (at your option) any later version.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 
00030 char et_rot_lambda_grv2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_lambda_grv2.C,v 1.4 2008/08/27 08:47:17 jl_cornou Exp $" ;
00031 
00032 /*
00033  * $Id: et_rot_lambda_grv2.C,v 1.4 2008/08/27 08:47:17 jl_cornou Exp $
00034  * $Log: et_rot_lambda_grv2.C,v $
00035  * Revision 1.4  2008/08/27 08:47:17  jl_cornou
00036  * Added R_JACO02 case
00037  *
00038  * Revision 1.3  2003/10/27 10:53:16  e_gourgoulhon
00039  * Changed variable name mp --> mprad in order not to shadow member mp.
00040  *
00041  * Revision 1.2  2002/09/09 13:00:39  e_gourgoulhon
00042  * Modification of declaration of Fortran 77 prototypes for
00043  * a better portability (in particular on IBM AIX systems):
00044  * All Fortran subroutine names are now written F77_* and are
00045  * defined in the new file C++/Include/proto_f77.h.
00046  *
00047  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00048  * LORENE
00049  *
00050  * Revision 2.1  2001/10/10  13:52:21  eric
00051  * Modif Joachim: suppression caractere invisible en fin de fichier.
00052  *
00053  * Revision 2.0  2000/11/19  18:52:30  eric
00054  * *** empty log message ***
00055  *
00056  *
00057  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_lambda_grv2.C,v 1.4 2008/08/27 08:47:17 jl_cornou Exp $
00058  *
00059  */
00060 
00061 // Headers C
00062 #include <math.h>
00063 
00064 // Headers Lorene
00065 #include "etoile.h"
00066 #include "proto_f77.h"
00067 
00068 double Etoile_rot::lambda_grv2(const Cmp& sou_m, const Cmp& sou_q) {
00069 
00070     const Map_radial* mprad = dynamic_cast<const Map_radial*>( sou_m.get_mp() ) ;
00071     
00072     if (mprad == 0x0) {
00073         cout << "Etoile_rot::lambda_grv2: the mapping of sou_m does not"
00074              << endl << " belong to the class Map_radial !" << endl ;
00075         abort() ;
00076     }   
00077 
00078     assert( sou_q.get_mp() == mprad ) ;
00079     
00080     sou_q.check_dzpuis(4) ;
00081     
00082     const Mg3d* mg = mprad->get_mg() ;
00083     int nz = mg->get_nzone() ;
00084         
00085     // Construction of a Map_af which coincides with *mp on the equator
00086     // ----------------------------------------------------------------
00087 
00088     double theta0 = M_PI / 2 ;      // Equator
00089     double phi0 = 0 ;
00090 
00091     Map_af mpaff(*mprad) ;
00092 
00093     for (int l=0 ; l<nz ; l++) {
00094         double rmax = mprad->val_r(l, double(1), theta0, phi0) ;
00095         switch ( mg->get_type_r(l) ) {
00096             case RARE:  {
00097                 double rmin = mprad->val_r(l, double(0), theta0, phi0) ;
00098                 mpaff.set_alpha(rmax - rmin, l) ;
00099                 mpaff.set_beta(rmin, l) ;
00100                 break ;
00101             }
00102     
00103             case FIN:   {
00104                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00105                 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
00106                 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
00107                 break ;
00108             }
00109 
00110             case FINJAC:    {
00111                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00112                 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
00113                 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
00114                 break ;
00115             }
00116 
00117     
00118             case UNSURR: {
00119                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00120                 double umax = double(1) / rmin ;
00121                 double umin = double(1) / rmax ;
00122                 mpaff.set_alpha( double(.5) * (umin - umax),  l) ;
00123                 mpaff.set_beta( double(.5) * (umin + umax), l) ;
00124                 break ;
00125             }
00126     
00127             default: {
00128                 cout << "Etoile_rot::lambda_grv2: unknown type_r ! " << endl ;
00129                 abort () ;
00130                 break ;
00131             }
00132     
00133         }
00134     }
00135 
00136 
00137     // Reduced Jacobian of
00138     // the transformation  (r,theta,phi) <-> (dzeta,theta',phi')
00139     // ------------------------------------------------------------
00140     
00141     Mtbl jac = 1 / ( (mprad->xsr) * (mprad->dxdr) ) ;   
00142                                 // R/x dR/dx in the nucleus
00143                                 // R dR/dx   in the shells
00144                                 // - U/(x-1) dU/dx in the ZEC                       
00145     for (int l=0; l<nz; l++) {
00146         switch ( mg->get_type_r(l) ) {
00147             case RARE:  {
00148                 double a1 = mpaff.get_alpha()[l] ;
00149                 *(jac.t[l]) =  *(jac.t[l]) / (a1*a1) ;
00150                 break ;
00151             }
00152     
00153             case FIN:   {
00154                 double a1 = mpaff.get_alpha()[l] ;
00155                 double b1 = mpaff.get_beta()[l] ;
00156                 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
00157                 double* tjac = jac.t[l]->t ;
00158                 double* const xi = mg->get_grille3d(l)->x ;
00159                 for (int k=0; k<mg->get_np(l); k++) {
00160                     for (int j=0; j<mg->get_nt(l); j++) {
00161                         for (int i=0; i<mg->get_nr(l); i++) {
00162                             *tjac = *tjac /
00163                                     (a1 * (a1 * xi[i] + b1) ) ;
00164                             tjac++ ;    
00165                         }
00166                     }
00167                 }               
00168                 
00169                 break ;
00170             }
00171 
00172             case FINJAC:    {
00173                 double a1 = mpaff.get_alpha()[l] ;
00174                 double b1 = mpaff.get_beta()[l] ;
00175                 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
00176                 double* tjac = jac.t[l]->t ;
00177                 double* const xi = mg->get_grille3d(l)->x ;
00178                 for (int k=0; k<mg->get_np(l); k++) {
00179                     for (int j=0; j<mg->get_nt(l); j++) {
00180                         for (int i=0; i<mg->get_nr(l); i++) {
00181                             *tjac = *tjac /
00182                                     (a1 * (a1 * xi[i] + b1) ) ;
00183                             tjac++ ;    
00184                         }
00185                     }
00186                 }               
00187                 
00188                 break ;
00189             }
00190 
00191     
00192             case UNSURR: {
00193                 double a1 = mpaff.get_alpha()[l] ;
00194                 *(jac.t[l]) = - *(jac.t[l]) / (a1*a1) ;
00195                 break ;
00196             }
00197     
00198             default: {
00199                 cout << "Etoile_rot::lambda_grv2: unknown type_r ! " << endl ;
00200                 abort () ;
00201                 break ;
00202             }
00203     
00204         }
00205     
00206     }
00207 
00208 
00209     // Multiplication of the sources by the reduced Jacobian:
00210     // -----------------------------------------------------
00211         
00212     Mtbl s_m(mg) ;
00213     if ( sou_m.get_etat() == ETATZERO ) {
00214         s_m = 0 ;
00215     }
00216     else{
00217         assert(sou_m.va.get_etat() == ETATQCQ) ;    
00218         sou_m.va.coef_i() ; 
00219         s_m = *(sou_m.va.c) ;
00220     }
00221         
00222     Mtbl s_q(mg) ;
00223     if ( sou_q.get_etat() == ETATZERO ) {
00224         s_q = 0 ;
00225     }
00226     else{
00227         assert(sou_q.va.get_etat() == ETATQCQ) ;    
00228         sou_q.va.coef_i() ; 
00229         s_q = *(sou_q.va.c) ;
00230     }
00231             
00232     s_m *= jac ;
00233     s_q *= jac ;
00234         
00235     
00236     // Preparations for the call to the Fortran subroutine
00237     // ---------------------------------------------------                              
00238     
00239     int np1 = 1 ;       // Axisymmetry enforced
00240     int nt = mg->get_nt(0) ;
00241     int nt2 = 2*nt - 1 ;    // Number of points for the theta sampling
00242                             //  in [0,Pi], instead of [0,Pi/2]
00243 
00244     // Array NDL
00245     // ---------
00246     int* ndl = new int[nz+4] ;
00247     ndl[0] = nz ;
00248     for (int l=0; l<nz; l++) {
00249         ndl[1+l] = mg->get_nr(l) ;
00250     }
00251     ndl[1+nz] = nt2 ;
00252     ndl[2+nz] = np1 ;
00253     ndl[3+nz] = nz ;
00254 
00255     // Parameters NDR, NDT, NDP
00256     // ------------------------
00257     int nrmax = 0 ;
00258     for (int l=0; l<nz ; l++) {
00259         nrmax = ( ndl[1+l] > nrmax ) ? ndl[1+l] : nrmax ;
00260     }
00261     int ndr = nrmax + 5 ;
00262     int ndt = nt2 + 2 ;
00263     int ndp = np1 + 2 ;
00264 
00265     // Array ERRE
00266     // ----------
00267 
00268     double* erre = new double [nz*ndr] ;
00269 
00270     for (int l=0; l<nz; l++) {
00271         double a1 = mpaff.get_alpha()[l] ;
00272         double b1 = mpaff.get_beta()[l] ;
00273         for (int i=0; i<ndl[1+l]; i++) {
00274             double xi = mg->get_grille3d(l)->x[i] ;
00275             erre[ ndr*l + i ] = a1 * xi + b1 ;
00276         }
00277     }
00278 
00279     // Arrays containing the data
00280     // --------------------------
00281 
00282     int ndrt = ndr*ndt ;
00283     int ndrtp = ndr*ndt*ndp ;
00284     int taille = ndrtp*nz ;
00285 
00286     double* tsou_m = new double[ taille ] ;
00287     double* tsou_q = new double[ taille ] ;
00288 
00289     // Initialisation to zero :
00290     for (int i=0; i<taille; i++) {
00291         tsou_m[i] = 0 ;
00292         tsou_q[i] = 0 ;
00293     }
00294 
00295     // Copy of s_m into tsou_m
00296     // -----------------------
00297 
00298     for (int l=0; l<nz; l++) {
00299        for (int k=0; k<np1; k++) {
00300             for (int j=0; j<nt; j++) {
00301                 for (int i=0; i<mg->get_nr(l); i++) {
00302                     double xx = s_m(l, k, j, i) ;
00303                     tsou_m[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00304                     // point symetrique par rapport au plan theta = pi/2 :
00305                     tsou_m[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00306                 }
00307             }
00308         }
00309     }
00310 
00311     // Copy of s_q into tsou_q
00312     // -----------------------
00313 
00314     for (int l=0; l<nz; l++) {
00315        for (int k=0; k<np1; k++) {
00316             for (int j=0; j<nt; j++) {
00317                 for (int i=0; i<mg->get_nr(l); i++) {
00318                     double xx = s_q(l, k, j, i) ;
00319                     tsou_q[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00320                     // point symetrique par rapport au plan theta = pi/2 :
00321                     tsou_q[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00322                 }
00323             }
00324         }
00325     }
00326 
00327     
00328     // Computation of the integrals
00329     // ----------------------------
00330 
00331     double int_m, int_q ;
00332     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_m, &int_m) ;
00333     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_q, &int_q) ;
00334 
00335     // Cleaning
00336     // --------
00337 
00338     delete [] ndl ;
00339     delete [] erre ;
00340     delete [] tsou_m ;
00341     delete [] tsou_q ;
00342 
00343     // Computation of lambda
00344     // ---------------------
00345 
00346     double lambda ;
00347     if ( int_q != double(0) ) {
00348         lambda = - int_m / int_q ;
00349     }
00350     else{
00351         lambda = 0 ;
00352     }
00353     
00354     return lambda ;
00355     
00356 }

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