map_af_primr.C

00001 /*
00002  *  Method Map_af::primr
00003  *
00004  *    (see file map.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2004  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 version 2
00015  *   as published by the Free Software Foundation.
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 char map_af_primr_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_af_primr.C,v 1.4 2007/12/20 09:11:05 jl_cornou Exp $" ;
00029 
00030 /*
00031  * $Id: map_af_primr.C,v 1.4 2007/12/20 09:11:05 jl_cornou Exp $
00032  * $Log: map_af_primr.C,v $
00033  * Revision 1.4  2007/12/20 09:11:05  jl_cornou
00034  * Correction of an error in op_sxpun about Jacobi(0,2) polynomials
00035  *
00036  * Revision 1.3  2004/07/26 16:02:23  j_novak
00037  * Added a flag to specify whether the primitive should be zero either at r=0
00038  * or at r going to infinity.
00039  *
00040  * Revision 1.1  2004/06/14 15:25:34  e_gourgoulhon
00041  * First version.
00042  *
00043  *
00044  * $Header: /cvsroot/Lorene/C++/Source/Map/map_af_primr.C,v 1.4 2007/12/20 09:11:05 jl_cornou Exp $
00045  *
00046  */
00047 
00048 
00049 // C headers
00050 #include <stdlib.h>
00051 
00052 // Lorene headers
00053 #include "map.h"
00054 #include "tensor.h"
00055 
00056 void _primr_pas_prevu(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00057 void _primr_r_cheb(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00058 void _primr_r_chebp(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00059 void _primr_r_chebi(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00060 void _primr_r_chebpim_p(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00061 void _primr_r_chebpim_i(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ; 
00062 void _primr_r_jaco02(const Tbl&, int, const Tbl&, Tbl&, int&, Tbl&) ;
00063 
00064 void Map_af::primr(const Scalar& uu, Scalar& resu, bool null_infty) const {
00065 
00066     static void (*prim_domain[MAX_BASE])(const Tbl&, int bin, const Tbl&, 
00067         Tbl&, int&, Tbl& ) ; 
00068     static bool first_call = true ; 
00069 
00070     // Initialisation at first call of the array of primitive functions 
00071     // depending upon the basis in r
00072     // ----------------------------------------------------------------
00073     if (first_call) {
00074         for (int i=0 ; i<MAX_BASE ; i++) prim_domain[i] = _primr_pas_prevu ;
00075         
00076         prim_domain[R_CHEB >> TRA_R] = _primr_r_cheb ;
00077         prim_domain[R_CHEBU >> TRA_R] = _primr_r_cheb ;
00078         prim_domain[R_CHEBP >> TRA_R] = _primr_r_chebp ;
00079         prim_domain[R_CHEBI >> TRA_R] = _primr_r_chebi ;
00080         prim_domain[R_CHEBPIM_P >> TRA_R] = _primr_r_chebpim_p ;
00081         prim_domain[R_CHEBPIM_I >> TRA_R] = _primr_r_chebpim_i ;
00082         prim_domain[R_JACO02 >> TRA_R] = _primr_r_jaco02 ;
00083 
00084         first_call = false ; 
00085     }
00086 
00087     // End of first call operations
00088     // ----------------------------
00089     
00090     assert(uu.get_etat() != ETATNONDEF) ;
00091     assert(uu.get_mp().get_mg() == mg) ;  
00092     assert(resu.get_mp().get_mg() == mg) ;  
00093     
00094     // Special case of vanishing input:
00095     if (uu.get_etat() == ETATZERO) {
00096         resu.set_etat_zero() ; 
00097         return ; 
00098     }
00099 
00100     // General case
00101     assert( (uu.get_etat() == ETATQCQ) || (uu.get_etat() == ETATUN) ) ; 
00102     assert(uu.check_dzpuis(2)) ; 
00103 
00104     int nz = mg->get_nzone() ; 
00105     int nzm1 = nz - 1 ; 
00106     int np = mg->get_np(0) ;    
00107     int nt = mg->get_nt(0) ;
00108 #ifndef NDEBUG
00109     for (int l=1; l<nz; l++) {     
00110       assert (mg->get_np(l) == np) ;
00111       assert (mg->get_nt(l) == nt) ;
00112     }
00113 #endif
00114 
00115     const Valeur& vuu = uu.get_spectral_va() ; 
00116     vuu.coef() ; 
00117 
00118     const Mtbl_cf& cuu = *(vuu.c_cf) ; 
00119     assert(cuu.t != 0x0) ; 
00120 
00121     const Base_val& buu = vuu.get_base() ; // spectral bases of the input
00122     
00123     resu.set_etat_qcq() ;   // result in ordinary state
00124     Valeur& vprim = resu.set_spectral_va() ; 
00125     vprim.set_etat_cf_qcq() ;  // allocates the Mtbl_cf for the coefficients
00126                                // of the result
00127     Mtbl_cf& cprim = *(vprim.c_cf) ;   
00128     cprim.set_etat_qcq() ;  // allocates the Tbl's to store the coefficients
00129                             // of the result in each domain   
00130     
00131     Base_val& bprim = cprim.base ;    // spectral bases of the result
00132     
00133     Tbl val_rmin(np+2,nt) ;  // Values of primitive at the left boundary 
00134                              // in the current domain 
00135     Tbl val_rmax(np+2,nt) ;  // same but for the right boundary
00136     
00137     val_rmin.set_etat_zero() ;  // initialisation: primitive = 0 at r=0
00138     
00139     int lmax = (mg->get_type_r(nzm1) == UNSURR) ? nz-2 : nzm1 ;  
00140     
00141     for (int l=0; l<=lmax; l++) {
00142         assert(cuu.t[l] != 0x0) ; 
00143         assert(cprim.t[l] != 0x0) ; 
00144         const Tbl& cfuu = *(cuu.t[l]) ; 
00145         Tbl& cfprim = *(cprim.t[l]) ; 
00146     
00147         int buu_dom = buu.get_b(l) ; 
00148         int base_r = (buu_dom & MSQ_R) >> TRA_R ;
00149         
00150         prim_domain[base_r](cfuu, buu_dom, val_rmin, cfprim, bprim.b[l],
00151             val_rmax) ; 
00152             
00153         cfprim *= alpha[l] ; 
00154         val_rmin = alpha[l] * val_rmax / alpha[l+1] ;  // for next domain
00155     }     
00156     
00157     // Special case of compactified external domain (CED)
00158     // --------------------------------------------------
00159     if (mg->get_type_r(nzm1) == UNSURR) {
00160         val_rmin = - val_rmin ; 
00161         const Tbl& cfuu = *(cuu.t[nzm1]) ; 
00162         Tbl& cfprim = *(cprim.t[nzm1]) ; 
00163     
00164         int buu_dom = buu.get_b(nzm1) ; 
00165         int base_r = (buu_dom & MSQ_R) >> TRA_R ;
00166         assert(base_r == R_CHEBU) ; 
00167         
00168         prim_domain[base_r](cfuu, buu_dom, val_rmin, cfprim, bprim.b[nzm1],
00169             val_rmax) ;
00170         
00171         cfprim *= - alpha[nzm1] ;  
00172     }
00173     
00174     if (null_infty) 
00175       for (int k=0; k<np; k++)  //## not very elegant!
00176     for(int j=0; j<nt; j++) 
00177       val_rmax.set(k,j) = cprim.val_point_jk(nzm1, 1., j, k) ;
00178     
00179     // The output spectral bases (set on the Mtbl_cf) are copied to the Valeur:
00180     vprim.set_base(bprim) ; 
00181 
00182     if (null_infty)
00183       for (int l=0; l<nz; l++) //## not very elegant!
00184     for (int k=0; k<np; k++) 
00185       for(int j=0; j<nt; j++) 
00186         for (int i=0; i<mg->get_nr(l); i++) 
00187           vprim.set(l, k, j, i) -= val_rmax(k,j) ;
00188      
00189     
00190 }

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