map_log_radius.C

00001 /*
00002  *  Methods of the class Map_log relative to the function
00003  *      r = R_l(xi, theta', phi')
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2004 Philippe Grandclement
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License as published by
00013  *   the Free Software Foundation; either version 2 of the License, or
00014  *   (at your option) any later version.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 char map_log_radius_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_log_radius.C,v 1.2 2004/06/22 12:20:17 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: map_log_radius.C,v 1.2 2004/06/22 12:20:17 j_novak Exp $
00032  * $Log: map_log_radius.C,v $
00033  * Revision 1.2  2004/06/22 12:20:17  j_novak
00034  * *** empty log message ***
00035  *
00036  * Revision 1.1  2004/06/22 08:49:58  p_grandclement
00037  * Addition of everything needed for using the logarithmic mapping
00038  *
00039  * 
00040  * $Header: /cvsroot/Lorene/C++/Source/Map/map_log_radius.C,v 1.2 2004/06/22 12:20:17 j_novak Exp $
00041  *
00042  */
00043 
00044 #include<math.h>
00045 
00046 // Headers Lorene
00047 #include "map.h"
00048 
00049             //------------------------------// 
00050             //      val_r       //
00051             //------------------------------// 
00052 
00053  
00054 double Map_log::val_r(int l, double xi, double, double) const {
00055 
00056     assert( l>=0 ) ; 
00057     assert( l<mg->get_nzone() ) ; 
00058     
00059     double resu ; 
00060 
00061     switch (type_var(l)) {
00062     case AFFINE : {
00063       
00064       switch( mg->get_type_r(l) ) {
00065       case FIN: case RARE: {
00066     resu = alpha(l) * xi + beta(l) ;
00067     break ;
00068       }
00069     
00070       case UNSURR: {
00071     resu = double(1) / ( alpha(l) * xi + beta(l) ) ;
00072     break ;
00073       }
00074     
00075       default: {
00076     cout << "Map_log::val_r: unknown type_r ! " << endl ;
00077     abort () ;
00078       }    
00079       }
00080       break ;
00081     }
00082 
00083     case LOG : { 
00084       switch( mg->get_type_r(l) ) {
00085       case FIN: {
00086     resu = exp(alpha(l) * xi + beta(l)) ;
00087     break ;
00088       }
00089     
00090       default: {
00091     cout << "Map_log::val_r: unknown type_r ! " << endl ;
00092     abort () ;
00093       }    
00094       }
00095       break ;
00096     }
00097       
00098     default: {
00099       cout << "Map_log::val_r: unknown type_r ! " << endl ;
00100       abort () ;
00101     }
00102     }
00103              
00104     return resu ;    
00105 }
00106             
00107             //------------------------------// 
00108             //      val_lx      //
00109             //------------------------------// 
00110 
00111 void Map_log::val_lx(double rr, double, double, int& lz, double& xi) const {
00112                
00113     // In which domain is located r ? 
00114     // ----------------------------
00115     int nz = mg->get_nzone() ;
00116     lz = - 1 ;
00117     
00118     for (int l=0; l<nz; l++) {
00119         
00120     double rmax = 0; 
00121     switch (type_var(l)) {
00122     case AFFINE : {
00123       rmax = alpha(l) + beta(l) ;
00124       break ;
00125     }
00126     case LOG : {
00127       rmax = exp(alpha(l) + beta(l)) ;
00128       break ;
00129     }
00130     default : {
00131       cout << "Case unknown in Map_log::val_lx" << endl ;
00132       break ;
00133     }
00134     }
00135     
00136     if (mg->get_type_r(l) == UNSURR) rmax = double(1)/rmax ; 
00137         
00138     if ( rr <= rmax ) { 
00139         lz = l ;
00140         break ; 
00141     }   
00142     }       // fin de la boucle sur les zones
00143     
00144     if (lz == -1) {         // On n'a pas trouve la zone 
00145     cout.precision(16);
00146     cout.setf(ios::showpoint);
00147     cout << "Map_log::val_lx: the domain containing r = " << rr <<
00148       " has not been found ! " 
00149          << endl ;
00150     abort () ;
00151     }
00152 
00153     // Computation of xi
00154     // ----------------- 
00155 
00156     switch (type_var(lz)) {
00157     case AFFINE: {
00158       switch( mg->get_type_r(lz) ) {
00159       case FIN: case RARE: {
00160     xi = ( rr - beta(lz) ) / alpha(lz)  ;
00161     break ;
00162       }
00163     
00164       case UNSURR: {
00165     xi = ( double(1)/rr - beta(lz) ) / alpha(lz)  ;
00166     break ;
00167       }
00168     
00169       default: {
00170     cout << "Map_log::val_lx: unknown type_r ! " << endl ;
00171     abort () ;
00172       }    
00173       }
00174       break ;
00175     }
00176     case LOG :{
00177       switch( mg->get_type_r(lz) ) {
00178       case FIN: {
00179     xi = ( log(rr) - beta(lz) ) / alpha(lz)  ;
00180     break ;
00181       }
00182       default: {
00183     cout << "Map_log::val_lx: unknown type_r ! " << endl ;
00184     abort () ;
00185       }     
00186       }
00187       break ;
00188     }
00189     default : {
00190       cout << "Map_log::val_lx: unknown type_r ! " << endl ;
00191       abort () ;
00192     }
00193     }   
00194 }
00195 
00196 
00197 void Map_log::val_lx(double rr, double, double, const Param&,  
00198                 int& lz, double& xi) const {
00199 
00200     val_lx(rr, 0., 0., lz, xi) ;
00201 
00202 }
00203 
00204 
00205             //------------------------------// 
00206             //      val_r_jk        //
00207             //------------------------------// 
00208 
00209  
00210 double Map_log::val_r_jk(int l, double xi, int, int) const {
00211 
00212     return val_r(l, xi, 0., 0.) ; 
00213     
00214 }
00215             
00216             //------------------------------// 
00217             //      val_lx_jk       //
00218             //------------------------------// 
00219 
00220 void Map_log::val_lx_jk(double rr, int, int, const Param& par, 
00221                 int& l, double& xi) const {
00222                
00223     val_lx(rr, 0., 0., par, l, xi) ; 
00224 
00225 } 
00226 
00227 

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