scalar_raccord_externe.C

00001 /*
00002  *   Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
00003  *
00004  *   Copyright (c) 2001 Philippe Grandclement (for preceding Cmp version)
00005  *
00006  *
00007  *   This file is part of LORENE.
00008  *
00009  *   LORENE is free software; you can redistribute it and/or modify
00010  *   it under the terms of the GNU General Public License as published by
00011  *   the Free Software Foundation; either version 2 of the License, or
00012  *   (at your option) any later version.
00013  *
00014  *   LORENE is distributed in the hope that it will be useful,
00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *   GNU General Public License for more details.
00018  *
00019  *   You should have received a copy of the GNU General Public License
00020  *   along with LORENE; if not, write to the Free Software
00021  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  */
00024 
00025 
00026 char scalar_raccord_externe_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_raccord_externe.C,v 1.2 2003/09/25 09:22:33 j_novak Exp $" ;
00027 
00028 /*
00029  * $Id: scalar_raccord_externe.C,v 1.2 2003/09/25 09:22:33 j_novak Exp $
00030  * $Log: scalar_raccord_externe.C,v $
00031  * Revision 1.2  2003/09/25 09:22:33  j_novak
00032  * Added a #include<math.h>
00033  *
00034  * Revision 1.1  2003/09/25 08:58:10  e_gourgoulhon
00035  * First version.
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_raccord_externe.C,v 1.2 2003/09/25 09:22:33 j_novak Exp $
00039  *
00040  */
00041 
00042 
00043 
00044 //standard
00045 #include <stdlib.h>
00046 #include <math.h>
00047 
00048 // LORENE
00049 #include "matrice.h"
00050 #include "tensor.h"
00051 #include "proto.h"
00052 
00053 int cnp (int n, int p) ;
00054 
00055 // Fait le raccord dans la zec ...
00056 // Suppose (pour le moment, le meme nbre de points sur les angles ...)
00057 // et que la zone precedente est une coquille
00058 
00059 void Scalar::raccord_externe(int power, int nbre, int lmax) {
00060 
00061      va.coef() ;
00062      va.ylm() ;
00063      
00064      Base_val base_devel (va.base) ;
00065      int base_r, m_quant, l_quant ;
00066 
00067      // Confort :
00068      int zone = mp->get_mg()->get_nzone()-2 ;
00069      int nt = mp->get_mg()->get_nt(zone) ; 
00070      int np = mp->get_mg()->get_np(zone) ;
00071      int nr = mp->get_mg()->get_nr(zone) ;
00072      
00073      // Le mapping doit etre affine :
00074     const Map_af* map  = dynamic_cast<const Map_af*>(mp) ;
00075     if (map == 0x0) {
00076     cout << "Le mapping doit etre affine" << endl ;
00077     abort() ;
00078     }
00079      
00080      // Mappinhg en r
00081      double alpha = map->get_alpha()[zone] ;
00082      double beta = map->get_beta()[zone] ;
00083      
00084      // Mapping en 1/r 
00085      double new_alpha = -alpha/(beta*beta-alpha*alpha) ;
00086      double new_beta = beta/(beta*beta-alpha*alpha) ;
00087      
00088     // Mapping dans la zec :
00089     double alpha_zec = map->get_alpha()[zone+1] ;
00090     
00091     // Maintenant on construit les matrices de passage :
00092     // Celle de ksi a T
00093     Matrice tksi (nbre, nbre) ;
00094     tksi.set_etat_qcq() ;
00095     
00096     // Premier polynome
00097     tksi.set(0, 0) = sqrt(double(2)) ;
00098     for (int i=1 ; i<nbre ; i++)
00099     tksi.set(0, i) = 0 ;
00100     
00101     //Second polynome
00102     tksi.set(1, 0) = 0 ;
00103     tksi.set(1, 1) = sqrt(double(2)) ;
00104     for (int i=2 ; i<nbre ; i++)
00105     tksi.set(1, i) = 0 ;
00106     
00107     // On recurre :
00108     for (int lig=2 ; lig<nbre ; lig++) {
00109     tksi.set(lig, 0) = -tksi(lig-2, 0) ;
00110     for (int col=1 ; col<nbre ; col++)
00111         tksi.set(lig, col) = 2*tksi(lig-1, col-1)-tksi(lig-2, col) ;
00112     }
00113     
00114     // Celle de u/new_alpha a ksi :
00115     Matrice ksiu (nbre, nbre) ;
00116     ksiu.set_etat_qcq() ;
00117     
00118     for (int lig=0 ; lig<nbre ; lig++) {
00119     for (int col=0 ; col<=lig ; col++)
00120         ksiu.set(lig, col) = cnp(lig, col)*
00121         pow(-new_beta/new_alpha, lig-col) ;
00122     for (int col = lig+1 ; col<nbre ; col++)
00123         ksiu.set(lig, col) = 0 ;
00124     }
00125     
00126     // La matrice totale :
00127     Matrice tu (nbre, nbre) ;
00128     tu.set_etat_qcq() ;
00129     double somme ;
00130     for (int lig=0 ; lig<nbre ; lig++)
00131     for (int col=0 ; col<nbre ; col++) {
00132         somme = 0 ;
00133         for (int m=0 ; m<nbre ; m++)
00134         somme += tksi(lig, m)*ksiu(m, col) ;
00135         tu.set(lig, col) = somme ;
00136     }
00137      
00138     // On calcul les coefficients de u^n dans la zec
00139     Tbl coef_u (nbre+lmax, nr) ;
00140     coef_u.set_etat_qcq() ;
00141     int* dege = new int [3] ;
00142     dege[0] = 1 ; dege[1] = 1 ; dege[2] = nr ;
00143     double* ti = new double [nr] ;
00144     
00145     for (int puiss=0 ; puiss<nbre+lmax ; puiss++) {
00146     for (int i=0 ; i<nr ; i++)
00147         ti[i] = pow(-cos(M_PI*i/(nr-1))-1, puiss) ;
00148     cfrcheb (dege, dege, ti, dege, ti) ;
00149     for (int i=0 ; i<nr ; i++)
00150         coef_u.set(puiss, i) = ti[i] ;
00151     }
00152      
00153      // Avant d entrer dans la boucle :
00154      dege[2] = nbre ;
00155      double *coloc = new double[nbre] ;
00156      double *auxi = new double [1] ;
00157      
00158      Tbl coef_zec (np+2, nt,  nr) ;
00159      coef_zec.annule_hard() ;
00160      
00161      // Boucle sur les harmoniques :
00162      
00163      for (int k=0 ; k<np+2 ; k++)
00164     for (int j=0 ; j<nt ; j++)
00165         if (nullite_plm (j, nt, k, np, base_devel)==1) {
00166         donne_lm (zone+2, zone+1, j, k, base_devel, m_quant, 
00167         l_quant, base_r) ;
00168         if (l_quant <= lmax) {
00169         
00170     // On bosse :
00171     // On recupere les valeus aux points de colocation en 1/r :
00172     double ksi, air ;
00173     for (int i=0 ; i<nbre ; i++) {
00174     ksi = -cos(M_PI*i/(nbre-1)) ;
00175     air = 1./(new_alpha*ksi+new_beta) ;
00176     ksi = (air-beta)/alpha ;
00177     for (int m=0 ; m<nr ; m++)
00178         ti[m] = (*va.c_cf)(zone, k, j, m) ;
00179     som_r_cheb (ti, nr, 1, 1, ksi, auxi) ;
00180     coloc[i] = auxi[0]/ 
00181         pow (-new_alpha*cos(M_PI*i/(nbre-1))+new_beta, power+l_quant);
00182     }
00183     
00184     cfrcheb (dege, dege, coloc, dege, coloc) ;
00185     
00186     Tbl expansion (nbre) ;
00187     expansion.set_etat_qcq() ;
00188     for (int i=0 ; i<nbre ; i++) {
00189     somme = 0 ;
00190     for (int m=0 ; m<nbre ; m++)
00191         somme += coloc[m]*tu(m, i) ;
00192     expansion.set(i) = somme ;
00193     }
00194     
00195     for (int i=0 ; i<nr ; i++) {
00196     somme = 0 ;
00197     for (int m=0 ; m<nbre ; m++)
00198         somme += coef_u(m+l_quant, i)*expansion(m)*
00199             pow(alpha_zec, m+l_quant)/
00200             pow(new_alpha, m) ;
00201     coef_zec.set(k, j, i) = somme ;
00202     }
00203     }
00204     }
00205     
00206     va.set_etat_cf_qcq() ;
00207     va.c_cf->set_etat_qcq() ;
00208     va.c_cf->t[zone+1]->set_etat_qcq() ;
00209     
00210     for (int k=0 ; k<np+2 ; k++)
00211     for (int j=0 ; j<nt ; j++)
00212         for (int i=0 ; i<nr ; i++)
00213         va.c_cf->set(zone+1, k, j, i) = coef_zec(k, j, i) ;
00214     
00215     set_dzpuis(power) ;
00216     va.ylm_i() ;
00217     
00218     delete[] auxi ;
00219     delete [] dege ;
00220     delete [] ti ;
00221     delete [] coloc ;
00222 }

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