cmp_raccord_externe.C

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

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