star_rot_lambda_grv2.C

00001 /*
00002  * Method Star_rot::lambda_grv2.
00003  *
00004  * (see file star_rot.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2010 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 star_rot_lambda_grv2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_rot_lambda_grv2.C,v 1.1 2010/01/25 18:15:52 e_gourgoulhon Exp $" ;
00031 
00032 /*
00033  * $Id: star_rot_lambda_grv2.C,v 1.1 2010/01/25 18:15:52 e_gourgoulhon Exp $
00034  * $Log: star_rot_lambda_grv2.C,v $
00035  * Revision 1.1  2010/01/25 18:15:52  e_gourgoulhon
00036  * First version.
00037  *
00038  *
00039  *
00040  * $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_lambda_grv2.C,v 1.1 2010/01/25 18:15:52 e_gourgoulhon Exp $
00041  *
00042  */
00043 
00044 // Headers C
00045 #include <math.h>
00046 
00047 // Headers Lorene
00048 #include "star_rot.h"
00049 #include "proto_f77.h"
00050 
00051 double Star_rot::lambda_grv2(const Scalar& sou_m, const Scalar& sou_q) {
00052 
00053     const Map_radial* mprad = dynamic_cast<const Map_radial*>( &sou_m.get_mp() ) ;
00054     
00055     if (mprad == 0x0) {
00056         cout << "Star_rot::lambda_grv2: the mapping of sou_m does not"
00057              << endl << " belong to the class Map_radial !" << endl ;
00058         abort() ;
00059     }   
00060 
00061     assert( &sou_q.get_mp() == mprad ) ;
00062     
00063     sou_q.check_dzpuis(4) ;
00064     
00065     const Mg3d* mg = mprad->get_mg() ;
00066     int nz = mg->get_nzone() ;
00067         
00068     // Construction of a Map_af which coincides with *mp on the equator
00069     // ----------------------------------------------------------------
00070 
00071     double theta0 = M_PI / 2 ;      // Equator
00072     double phi0 = 0 ;
00073 
00074     Map_af mpaff(*mprad) ;
00075 
00076     for (int l=0 ; l<nz ; l++) {
00077         double rmax = mprad->val_r(l, double(1), theta0, phi0) ;
00078         switch ( mg->get_type_r(l) ) {
00079             case RARE:  {
00080                 double rmin = mprad->val_r(l, double(0), theta0, phi0) ;
00081                 mpaff.set_alpha(rmax - rmin, l) ;
00082                 mpaff.set_beta(rmin, l) ;
00083                 break ;
00084             }
00085     
00086             case FIN:   {
00087                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00088                 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
00089                 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
00090                 break ;
00091             }
00092 
00093             case FINJAC:    {
00094                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00095                 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
00096                 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
00097                 break ;
00098             }
00099 
00100     
00101             case UNSURR: {
00102                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00103                 double umax = double(1) / rmin ;
00104                 double umin = double(1) / rmax ;
00105                 mpaff.set_alpha( double(.5) * (umin - umax),  l) ;
00106                 mpaff.set_beta( double(.5) * (umin + umax), l) ;
00107                 break ;
00108             }
00109     
00110             default: {
00111                 cout << "Star_rot::lambda_grv2: unknown type_r ! " << endl ;
00112                 abort () ;
00113                 break ;
00114             }
00115     
00116         }
00117     }
00118 
00119 
00120     // Reduced Jacobian of
00121     // the transformation  (r,theta,phi) <-> (dzeta,theta',phi')
00122     // ------------------------------------------------------------
00123     
00124     Mtbl jac = 1 / ( (mprad->xsr) * (mprad->dxdr) ) ;   
00125                                 // R/x dR/dx in the nucleus
00126                                 // R dR/dx   in the shells
00127                                 // - U/(x-1) dU/dx in the ZEC                       
00128     for (int l=0; l<nz; l++) {
00129         switch ( mg->get_type_r(l) ) {
00130             case RARE:  {
00131                 double a1 = mpaff.get_alpha()[l] ;
00132                 *(jac.t[l]) =  *(jac.t[l]) / (a1*a1) ;
00133                 break ;
00134             }
00135     
00136             case FIN:   {
00137                 double a1 = mpaff.get_alpha()[l] ;
00138                 double b1 = mpaff.get_beta()[l] ;
00139                 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
00140                 double* tjac = jac.t[l]->t ;
00141                 double* const xi = mg->get_grille3d(l)->x ;
00142                 for (int k=0; k<mg->get_np(l); k++) {
00143                     for (int j=0; j<mg->get_nt(l); j++) {
00144                         for (int i=0; i<mg->get_nr(l); i++) {
00145                             *tjac = *tjac /
00146                                     (a1 * (a1 * xi[i] + b1) ) ;
00147                             tjac++ ;    
00148                         }
00149                     }
00150                 }               
00151                 
00152                 break ;
00153             }
00154 
00155             case FINJAC:    {
00156                 double a1 = mpaff.get_alpha()[l] ;
00157                 double b1 = mpaff.get_beta()[l] ;
00158                 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
00159                 double* tjac = jac.t[l]->t ;
00160                 double* const xi = mg->get_grille3d(l)->x ;
00161                 for (int k=0; k<mg->get_np(l); k++) {
00162                     for (int j=0; j<mg->get_nt(l); j++) {
00163                         for (int i=0; i<mg->get_nr(l); i++) {
00164                             *tjac = *tjac /
00165                                     (a1 * (a1 * xi[i] + b1) ) ;
00166                             tjac++ ;    
00167                         }
00168                     }
00169                 }               
00170                 
00171                 break ;
00172             }
00173 
00174     
00175             case UNSURR: {
00176                 double a1 = mpaff.get_alpha()[l] ;
00177                 *(jac.t[l]) = - *(jac.t[l]) / (a1*a1) ;
00178                 break ;
00179             }
00180     
00181             default: {
00182                 cout << "Star_rot::lambda_grv2: unknown type_r ! " << endl ;
00183                 abort () ;
00184                 break ;
00185             }
00186     
00187         }
00188     
00189     }
00190 
00191 
00192     // Multiplication of the sources by the reduced Jacobian:
00193     // -----------------------------------------------------
00194         
00195     Mtbl s_m(mg) ;
00196     if ( sou_m.get_etat() == ETATZERO ) {
00197         s_m = 0 ;
00198     }
00199     else{
00200         assert(sou_m.get_spectral_va().get_etat() == ETATQCQ) ; 
00201         sou_m.get_spectral_va().coef_i() ;  
00202         s_m = *(sou_m.get_spectral_va().c) ;
00203     }
00204         
00205     Mtbl s_q(mg) ;
00206     if ( sou_q.get_etat() == ETATZERO ) {
00207         s_q = 0 ;
00208     }
00209     else{
00210         assert(sou_q.get_spectral_va().get_etat() == ETATQCQ) ; 
00211         sou_q.get_spectral_va().coef_i() ;  
00212         s_q = *(sou_q.get_spectral_va().c) ;
00213     }
00214             
00215     s_m *= jac ;
00216     s_q *= jac ;
00217         
00218     
00219     // Preparations for the call to the Fortran subroutine
00220     // ---------------------------------------------------                              
00221     
00222     int np1 = 1 ;       // Axisymmetry enforced
00223     int nt = mg->get_nt(0) ;
00224     int nt2 = 2*nt - 1 ;    // Number of points for the theta sampling
00225                             //  in [0,Pi], instead of [0,Pi/2]
00226 
00227     // Array NDL
00228     // ---------
00229     int* ndl = new int[nz+4] ;
00230     ndl[0] = nz ;
00231     for (int l=0; l<nz; l++) {
00232         ndl[1+l] = mg->get_nr(l) ;
00233     }
00234     ndl[1+nz] = nt2 ;
00235     ndl[2+nz] = np1 ;
00236     ndl[3+nz] = nz ;
00237 
00238     // Parameters NDR, NDT, NDP
00239     // ------------------------
00240     int nrmax = 0 ;
00241     for (int l=0; l<nz ; l++) {
00242         nrmax = ( ndl[1+l] > nrmax ) ? ndl[1+l] : nrmax ;
00243     }
00244     int ndr = nrmax + 5 ;
00245     int ndt = nt2 + 2 ;
00246     int ndp = np1 + 2 ;
00247 
00248     // Array ERRE
00249     // ----------
00250 
00251     double* erre = new double [nz*ndr] ;
00252 
00253     for (int l=0; l<nz; l++) {
00254         double a1 = mpaff.get_alpha()[l] ;
00255         double b1 = mpaff.get_beta()[l] ;
00256         for (int i=0; i<ndl[1+l]; i++) {
00257             double xi = mg->get_grille3d(l)->x[i] ;
00258             erre[ ndr*l + i ] = a1 * xi + b1 ;
00259         }
00260     }
00261 
00262     // Arrays containing the data
00263     // --------------------------
00264 
00265     int ndrt = ndr*ndt ;
00266     int ndrtp = ndr*ndt*ndp ;
00267     int taille = ndrtp*nz ;
00268 
00269     double* tsou_m = new double[ taille ] ;
00270     double* tsou_q = new double[ taille ] ;
00271 
00272     // Initialisation to zero :
00273     for (int i=0; i<taille; i++) {
00274         tsou_m[i] = 0 ;
00275         tsou_q[i] = 0 ;
00276     }
00277 
00278     // Copy of s_m into tsou_m
00279     // -----------------------
00280 
00281     for (int l=0; l<nz; l++) {
00282        for (int k=0; k<np1; k++) {
00283             for (int j=0; j<nt; j++) {
00284                 for (int i=0; i<mg->get_nr(l); i++) {
00285                     double xx = s_m(l, k, j, i) ;
00286                     tsou_m[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00287                     // point symetrique par rapport au plan theta = pi/2 :
00288                     tsou_m[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00289                 }
00290             }
00291         }
00292     }
00293 
00294     // Copy of s_q into tsou_q
00295     // -----------------------
00296 
00297     for (int l=0; l<nz; l++) {
00298        for (int k=0; k<np1; k++) {
00299             for (int j=0; j<nt; j++) {
00300                 for (int i=0; i<mg->get_nr(l); i++) {
00301                     double xx = s_q(l, k, j, i) ;
00302                     tsou_q[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00303                     // point symetrique par rapport au plan theta = pi/2 :
00304                     tsou_q[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00305                 }
00306             }
00307         }
00308     }
00309 
00310     
00311     // Computation of the integrals
00312     // ----------------------------
00313 
00314     double int_m, int_q ;
00315     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_m, &int_m) ;
00316     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_q, &int_q) ;
00317 
00318     // Cleaning
00319     // --------
00320 
00321     delete [] ndl ;
00322     delete [] erre ;
00323     delete [] tsou_m ;
00324     delete [] tsou_q ;
00325 
00326     // Computation of lambda
00327     // ---------------------
00328 
00329     double lambda ;
00330     if ( int_q != double(0) ) {
00331         lambda = - int_m / int_q ;
00332     }
00333     else{
00334         lambda = 0 ;
00335     }
00336     
00337     return lambda ;
00338     
00339 }

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