valeur_coef.C

00001 /*
00002  * Computation of the spectral coefficients.
00003  */
00004 
00005 /*
00006  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00007  *
00008  *   This file is part of LORENE.
00009  *
00010  *   LORENE is free software; you can redistribute it and/or modify
00011  *   it under the terms of the GNU General Public License as published by
00012  *   the Free Software Foundation; either version 2 of the License, or
00013  *   (at your option) any later version.
00014  *
00015  *   LORENE is distributed in the hope that it will be useful,
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *   GNU General Public License for more details.
00019  *
00020  *   You should have received a copy of the GNU General Public License
00021  *   along with LORENE; if not, write to the Free Software
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 
00027 char valeur_coef_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_coef.C,v 1.15 2012/01/17 17:51:16 j_penner Exp $" ;
00028 
00029 
00030 /*
00031  * $Id: valeur_coef.C,v 1.15 2012/01/17 17:51:16 j_penner Exp $
00032  * $Log: valeur_coef.C,v $
00033  * Revision 1.15  2012/01/17 17:51:16  j_penner
00034  * *** empty log message ***
00035  *
00036  * Revision 1.14  2012/01/17 15:07:57  j_penner
00037  * using MAX_BASE_2 for the phi coordinate
00038  *
00039  * Revision 1.13  2009/10/23 12:56:29  j_novak
00040  * New base T_LEG_MI
00041  *
00042  * Revision 1.12  2009/10/13 13:49:58  j_novak
00043  * New base T_LEG_MP.
00044  *
00045  * Revision 1.11  2008/10/07 15:01:58  j_novak
00046  * The case nt=1 is now treated separately.
00047  *
00048  * Revision 1.10  2008/05/24 15:09:02  j_novak
00049  * Getting back to previous version, the new one was an error.
00050  *
00051  * Revision 1.9  2008/05/24 15:05:22  j_novak
00052  * New method Scalar::match_tau to match the output of an explicit time-marching scheme with the tau method.
00053  *
00054  * Revision 1.8  2008/02/18 13:53:51  j_novak
00055  * Removal of special indentation instructions.
00056  *
00057  * Revision 1.7  2007/12/11 15:28:25  jl_cornou
00058  * Jacobi(0,2) polynomials partially implemented
00059  *
00060  * Revision 1.6  2004/11/23 15:17:19  m_forot
00061  * Added the bases for the cases without any equatorial symmetry
00062  *  (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
00063  *
00064  * Revision 1.5  2003/09/17 12:30:22  j_novak
00065  * New checks for changing to T_LEG* bases.
00066  *
00067  * Revision 1.4  2003/09/16 13:07:41  j_novak
00068  * New files for coefficient trnasformation to/from the T_LEG_II base.
00069  *
00070  * Revision 1.3  2002/11/12 17:44:35  j_novak
00071  * Added transformation function for T_COS basis.
00072  *
00073  * Revision 1.2  2002/10/16 14:37:15  j_novak
00074  * Reorganization of #include instructions of standard C++, in order to
00075  * use experimental version 3 of gcc.
00076  *
00077  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00078  * LORENE
00079  *
00080  * Revision 2.10  2000/10/04  14:41:26  eric
00081  * Ajout des bases T_LEG_IP et T_LEG_PI
00082  *
00083  * Revision 2.9  2000/09/29  16:09:25  eric
00084  * Mise a zero des coefficients k=1 et k=2 dans le cas np=1.
00085  *
00086  * Revision 2.8  2000/09/07  15:14:30  eric
00087  * Ajout de la base P_COSSIN_I
00088  *
00089  * Revision 2.7  2000/08/16  10:32:53  eric
00090  * Suppression de Mtbl::dzpuis.
00091  * >> .
00092  *
00093  * Revision 2.6  1999/11/30  12:42:29  eric
00094  * Valeur::base est desormais du type Base_val et non plus Base_val*.
00095  *
00096  * Revision 2.5  1999/11/24  16:06:13  eric
00097  * Ajout du test de l'admissibilite FFT des nombres de degres de liberte.
00098  *
00099  * Revision 2.4  1999/10/28  07:43:14  eric
00100  * Modif commentaires.
00101  *
00102  * Revision 2.3  1999/10/13  15:51:07  eric
00103  * Ajout de la base dans l'appel au constructeur de Mtbl_cf.
00104  *
00105  * Revision 2.2  1999/06/22  14:21:23  phil
00106  * Ajout de dzpuis
00107  *
00108  * Revision 2.1  1999/03/01  14:55:12  eric
00109  * *** empty log message ***
00110  *
00111  * Revision 2.0  1999/02/22  15:40:37  hyc
00112  * *** empty log message ***
00113  *
00114  *
00115  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_coef.C,v 1.15 2012/01/17 17:51:16 j_penner Exp $
00116  *
00117  */
00118 #include<cmath>
00119 
00120 // Header Lorene
00121 #include "mtbl.h"
00122 #include "mtbl_cf.h"
00123 #include "valeur.h"
00124 #include "proto.h"
00125 
00126 // Prototypage local
00127 void pasprevu_r(const int*, const int*, double*, const int*, double*) ;
00128 void pasprevu_t(const int*, const int*, double*, const int*, double*) ;
00129 void pasprevu_p(const int* ,const int* ,  double* ) ;
00130 
00131 void base_non_def_r(const int*, const int*, double*, const int*, double*) ;
00132 void base_non_def_t(const int*, const int*, double*, const int*, double*) ;
00133 void base_non_def_p(const int* ,const int* ,  double* ) ;
00134 
00135 bool admissible_fft(int ) ; 
00136 
00137 void Valeur::coef() const {
00138     
00139     // Variables statiques
00140     static void (*coef_r[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00141     static void (*coef_t[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00142     static void (*coef_p[MAX_BASE_2])(const int* ,const int* ,  double* ) ;
00143     static int premier_appel = 1 ;
00144     
00145     // Premier appel
00146     if (premier_appel) {
00147     premier_appel = 0 ;
00148 
00149     for (int i=0; i<MAX_BASE; i++) {
00150         coef_r[i] = pasprevu_r ;
00151         coef_t[i] = pasprevu_t ;
00152         if(i%2 == 0){
00153         coef_p[i/2] = pasprevu_p ;
00154         }
00155     }   
00156 
00157     coef_r[NONDEF] = base_non_def_r ;
00158     coef_r[R_CHEB >> TRA_R] = cfrcheb ;     
00159     coef_r[R_CHEBU >> TRA_R] = cfrcheb ;        
00160     coef_r[R_CHEBP >> TRA_R] = cfrchebp ;       
00161     coef_r[R_CHEBI >> TRA_R] = cfrchebi ;       
00162     coef_r[R_CHEBPIM_P >> TRA_R] = cfrchebpimp ;        
00163     coef_r[R_CHEBPIM_I >> TRA_R] = cfrchebpimi ;        
00164     coef_r[R_CHEBPI_P >> TRA_R] = cfrchebpip ;      
00165     coef_r[R_CHEBPI_I >> TRA_R] = cfrchebpii ;
00166     coef_r[R_JACO02 >> TRA_R] = cfrjaco02 ;
00167 
00168     coef_t[NONDEF] = base_non_def_t ;
00169     coef_t[T_COS >> TRA_T] = cftcos ;
00170     coef_t[T_SIN >> TRA_T] = cftsin ;
00171     coef_t[T_COS_P >> TRA_T] = cftcosp ;
00172     coef_t[T_COS_I >> TRA_T] = cftcosi ;
00173     coef_t[T_SIN_P >> TRA_T] = cftsinp ;
00174     coef_t[T_SIN_I >> TRA_T] = cftsini ;
00175     coef_t[T_COSSIN_CP >> TRA_T] = cftcossincp ;
00176     coef_t[T_COSSIN_SI >> TRA_T] = cftcossinsi ;
00177     coef_t[T_COSSIN_SP >> TRA_T] = cftcossinsp ;
00178     coef_t[T_COSSIN_CI >> TRA_T] = cftcossinci ;
00179     coef_t[T_COSSIN_S >> TRA_T] = cftcossins ;
00180     coef_t[T_COSSIN_C >> TRA_T] = cftcossinc ;
00181     coef_t[T_LEG_P >> TRA_T] = cftlegp ;
00182     coef_t[T_LEG_PP >> TRA_T] = cftlegpp ;
00183     coef_t[T_LEG_I >> TRA_T] = cftlegi ;
00184     coef_t[T_LEG_IP >> TRA_T] = cftlegip ;
00185     coef_t[T_LEG_PI >> TRA_T] = cftlegpi ;
00186     coef_t[T_LEG_II >> TRA_T] = cftlegii ;
00187     coef_t[T_LEG_MP >> TRA_T] = cftlegmp ;
00188     coef_t[T_LEG_MI >> TRA_T] = cftlegmi ;
00189     coef_t[T_LEG >> TRA_T] = cftleg ;
00190 
00191     coef_p[NONDEF] = base_non_def_p ;
00192     coef_p[P_COSSIN >> TRA_P] = cfpcossin ;
00193     coef_p[P_COSSIN_P >> TRA_P] = cfpcossin ;
00194     coef_p[P_COSSIN_I >> TRA_P] = cfpcossini ;
00195 
00196     }  // fin des operation de premier appel
00197 
00198 
00199         //-------------------//
00200         //  DEBUT DU CALCUL  //
00201         //-------------------//
00202 
00203     // Tout null ?
00204     if (etat == ETATZERO) {
00205     return ;
00206     }
00207     
00208     // Protection
00209     assert(etat != ETATNONDEF) ;
00210         
00211     // Peut-etre rien a faire
00212     if (c_cf != 0x0) {
00213     return ;
00214     }
00215     
00216     // Il faut bosser
00217     assert(c != 0x0) ;      // ..si on peut
00218     c_cf = new Mtbl_cf(mg, base) ;
00219     c_cf->set_etat_qcq() ;
00220     
00221     // Boucles sur les zones
00222     int nz = mg->get_nzone() ;
00223     for (int l=0; l<nz; l++) {
00224     
00225     // Initialisation des valeurs de this->c_cf avec celle de this->c :
00226     const Tbl* f =  (c->t)[l]  ;
00227     Tbl* cf =  (c_cf->t)[l]  ;
00228 
00229     if (f->get_etat() == ETATZERO) {
00230         cf->set_etat_zero() ;
00231         continue ; // on ne fait rien si le tbl = 0  
00232     }
00233 
00234     cf->set_etat_qcq() ;
00235         
00236     int np = f->get_dim(2) ;
00237     int nt = f->get_dim(1) ;
00238     int nr = f->get_dim(0) ;
00239 
00240     int np_c = cf->get_dim(2) ;
00241     int nt_c = cf->get_dim(1) ;
00242     int nr_c = cf->get_dim(0) ;     
00243 
00244     // Attention a ce qui suit... (deg et dim)
00245     int deg[3] ;
00246     deg[0] = np ;
00247     deg[1] = nt ;
00248     deg[2] = nr ;
00249 
00250     int dim[3] ;
00251     dim[0] = np_c ;
00252     dim[1] = nt_c ;
00253     dim[2] = nr_c ;
00254 
00255     int nrnt = nr * nt ;
00256     int nrnt_c = nr_c * nt_c ; 
00257         
00258     for (int i=0; i<np ; i++) {
00259         for (int j=0; j<nt ; j++) {
00260         for (int k=0; k<nr ; k++) {
00261             int index = nrnt * i + nr * j + k ;
00262             int index_c = nrnt_c * i + nr_c * j + k ;           
00263             (cf->t)[index_c] = (f->t)[index] ;
00264         }
00265         }
00266     }
00267 
00268     // On recupere les bases en r, theta et phi : 
00269     int base_r = ( base.b[l] & MSQ_R ) >> TRA_R ;
00270     int base_t = ( base.b[l] & MSQ_T ) >> TRA_T ;
00271     int base_p = ( base.b[l] & MSQ_P ) >> TRA_P ;
00272     int vbase_t = base.b[l] & MSQ_T ;
00273     int vbase_p = base.b[l] & MSQ_P ;
00274 
00275     assert(base_r < MAX_BASE) ; 
00276     assert(base_t < MAX_BASE) ; 
00277     assert(base_p < MAX_BASE_2) ; 
00278 
00279     // Transformation en phi 
00280     // ---------------------
00281     if ( np > 1 ) {
00282         assert( admissible_fft(np) ) ; 
00283         
00284         coef_p[base_p]( deg,  dim, (cf->t) ) ;
00285     }
00286     else{   // Cas np=1 : mise a zero des coefficients k=1 et k=2 :
00287         for (int i=nrnt; i<3*nrnt; i++) {
00288         cf->t[i] = 0 ; 
00289         }       
00290     }
00291 
00292     // Transformation en theta:
00293     // ------------------------
00294 
00295     if ( nt > 1 ) {
00296         assert( admissible_fft(nt-1) ) ; 
00297         bool pair = ( (vbase_t == T_LEG_PP) || (vbase_t == T_LEG_IP)
00298               || (vbase_t == T_LEG_MP) ) ;
00299         bool impair = ( (vbase_t == T_LEG_PI) || (vbase_t == T_LEG_II)
00300                 || (vbase_t == T_LEG_MI) ) ;
00301 
00302         if ((pair && (vbase_p == P_COSSIN_I)) ||
00303         (impair && (vbase_p == P_COSSIN_P)) )
00304           pasprevu_t(deg, dim, (cf->t), dim, (cf->t) ) ;
00305         else        
00306           coef_t[base_t](deg, dim, (cf->t), dim, (cf->t)) ;
00307     }
00308     else {
00309         if ((vbase_t == T_LEG_PP) || (vbase_t == T_LEG_PI) || 
00310         (vbase_t == T_LEG_IP) || (vbase_t == T_LEG_II) ||
00311         (vbase_t == T_LEG_P) || (vbase_t == T_LEG_I) ||
00312         (vbase_t == T_LEG) || (vbase_t == T_LEG_MP)
00313         || (vbase_t == T_LEG_MI) ) {
00314            
00315               *c_cf->t[l] *=sqrt(2.) ;      
00316         }
00317     }
00318     
00319 
00320     // Transformation en r:
00321     // --------------------
00322     if ( nr > 1 ) {
00323         assert( admissible_fft(nr-1) ) ; 
00324         coef_r[base_r](deg, dim, (cf->t), dim, (cf->t)) ;
00325     }   
00326        
00327     }  // fin de la boucle sur les differentes zones
00328     
00329 }
00330 
00331             //------------------------//
00332             // Les machins pas prevus //
00333             //------------------------//
00334 
00335 void pasprevu_r(const int*, const int*, double*, const int*, double*) {
00336     cout << "Valeur::coef: the required expansion basis in r " << endl ;
00337     cout << "  is not implemented !" << endl ;
00338     abort() ;
00339 }
00340 
00341 void pasprevu_t(const int*, const int*, double*, const int*, double*) {
00342     cout << "Valeur::coef: the required expansion basis in theta " << endl ;
00343     cout << "  is not implemented !" << endl ;
00344     abort() ;
00345 }
00346 
00347 void pasprevu_p(const int*, const int*, double*) {
00348     cout << "Valeur::coef: the required expansion basis in phi " << endl ;
00349     cout << "  is not implemented !" << endl ;
00350     abort() ;
00351 }
00352 
00353 void base_non_def_r(const int*, const int*, double*, const int*, double*) {
00354     cout << "Valeur::coef: the expansion basis in r is undefined !" << endl ;
00355     abort() ;
00356 }
00357 
00358 void base_non_def_t(const int*, const int*, double*, const int*, double*) {
00359     cout << "Valeur::coef: the expansion basis in theta is undefined !" << endl ;
00360     abort() ;
00361 }
00362 
00363 void base_non_def_p(const int*, const int*, double*) {
00364     cout << "Valeur::coef: the expansion basis in phi is undefined !" << endl ;
00365     abort() ;
00366 }
00367 

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