valeur_coef_i.C

00001 /*
00002  *  Computations of the values at the collocation points from the spectral
00003  *   coefficients
00004  *
00005  */
00006 
00007 /*
00008  *   Copyright (c) 1999-2003 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
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 
00029 char valeur_coef_i_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_coef_i.C,v 1.14 2012/01/17 15:08:02 j_penner Exp $" ;
00030 
00031 /*
00032  * $Id: valeur_coef_i.C,v 1.14 2012/01/17 15:08:02 j_penner Exp $
00033  * $Log: valeur_coef_i.C,v $
00034  * Revision 1.14  2012/01/17 15:08:02  j_penner
00035  * using MAX_BASE_2 for the phi coordinate
00036  *
00037  * Revision 1.13  2009/10/23 12:56:29  j_novak
00038  * New base T_LEG_MI
00039  *
00040  * Revision 1.12  2009/10/13 13:49:58  j_novak
00041  * New base T_LEG_MP.
00042  *
00043  * Revision 1.11  2009/10/08 16:23:14  j_novak
00044  * Addition of new bases T_COS and T_SIN.
00045  *
00046  * Revision 1.10  2008/10/07 15:01:58  j_novak
00047  * The case nt=1 is now treated separately.
00048  *
00049  * Revision 1.9  2007/12/11 15:28:25  jl_cornou
00050  * Jacobi(0,2) polynomials partially implemented
00051  *
00052  * Revision 1.8  2004/11/23 15:17:19  m_forot
00053  * Added the bases for the cases without any equatorial symmetry
00054  *  (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
00055  *
00056  * Revision 1.7  2004/08/24 09:14:52  p_grandclement
00057  * Addition of some new operators, like Poisson in 2d... It now requieres the
00058  * GSL library to work.
00059  *
00060  * Also, the way a variable change is stored by a Param_elliptic is changed and
00061  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00062  * will requiere some modification. (It should concern only the ones about monopoles)
00063  *
00064  * Revision 1.6  2003/10/13 20:51:25  e_gourgoulhon
00065  * Replaced malloc by new
00066  *
00067  * Revision 1.5  2003/09/17 12:30:22  j_novak
00068  * New checks for changing to T_LEG* bases.
00069  *
00070  * Revision 1.4  2003/09/16 13:07:41  j_novak
00071  * New files for coefficient trnasformation to/from the T_LEG_II base.
00072  *
00073  * Revision 1.3  2002/11/12 17:44:35  j_novak
00074  * Added transformation function for T_COS basis.
00075  *
00076  * Revision 1.2  2002/10/16 14:37:15  j_novak
00077  * Reorganization of #include instructions of standard C++, in order to
00078  * use experimental version 3 of gcc.
00079  *
00080  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00081  * LORENE
00082  *
00083  * Revision 2.9  2000/10/04  14:41:40  eric
00084  * Ajout des bases T_LEG_IP et T_LEG_PI
00085  *
00086  * Revision 2.8  2000/09/07  15:14:44  eric
00087  * Ajout de la base P_COSSIN_I
00088  *
00089  * Revision 2.7  2000/08/16  10:33:04  eric
00090  * Suppression de Mtbl::dzpuis.
00091  *
00092  * Revision 2.6  1999/12/16  16:41:48  phil
00093  * *** empty log message ***
00094  *
00095  * Revision 2.5  1999/11/30  12:43:03  eric
00096  * Valeur::base est desormais du type Base_val et non plus Base_val*.
00097  *
00098  * Revision 2.4  1999/10/28  07:44:20  eric
00099  * Modif commentaires.
00100  *
00101  * Revision 2.3  1999/10/13  15:51:33  eric
00102  * Anglisation.
00103  *
00104  * Revision 2.2  1999/06/22  15:10:02  phil
00105  * ajout de dzpuis
00106  *
00107  * Revision 2.1  1999/02/22  15:40:25  hyc
00108  * *** empty log message ***
00109  *
00110  *
00111  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_coef_i.C,v 1.14 2012/01/17 15:08:02 j_penner Exp $
00112  *
00113  */
00114 
00115 #include <math.h>
00116 
00117 // Header Lorene
00118 #include "valeur.h"
00119 #include "proto.h"
00120 
00121 void c_est_pas_fait(char * ) ;
00122 
00123 void ipasprevu_r(const int*, const int*, double*, const int*, double*) ;
00124 void ipasprevu_t(const int*, const int*, double*, const int*, double*) ;
00125 void ipasprevu_p(const int* , const int* , const int* , double* , double* ) ;
00126 void ibase_non_def_r(const int*, const int*, double*, const int*, double*) ;
00127 void ibase_non_def_t(const int*, const int*, double*, const int*, double*) ;
00128 void ibase_non_def_p(const int* , const int* , const int* , double* , double* ) ;
00129 
00130 void Valeur::coef_i() const {
00131     
00132     // Variables statiques
00133     static void (*invcf_r[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00134     static void (*invcf_t[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00135     static void (*invcf_p[MAX_BASE_2])(const int* , const int* , const int*, double* , double* ) ;
00136     static int premier_appel = 1 ;
00137 
00138     // Premier appel
00139     if (premier_appel) {
00140     premier_appel = 0 ;
00141 
00142     for (int i=0; i<MAX_BASE; i++) {
00143         invcf_r[i] = ipasprevu_r ;
00144         invcf_t[i] = ipasprevu_t ;
00145         if(i%2==0){
00146         invcf_p[i/2] = ipasprevu_p ; // saves a loop
00147         }
00148     }   
00149 
00150     invcf_r[NONDEF] = ibase_non_def_r ;
00151     invcf_r[R_CHEB >> TRA_R] = circheb ;        
00152     invcf_r[R_CHEBU >> TRA_R] = circheb ;       
00153     invcf_r[R_CHEBP >> TRA_R] = circhebp ;      
00154     invcf_r[R_CHEBI >> TRA_R] = circhebi ;      
00155     invcf_r[R_CHEBPIM_P >> TRA_R] = circhebpimp ;       
00156     invcf_r[R_CHEBPIM_I >> TRA_R] = circhebpimi ;       
00157     invcf_r[R_CHEBPI_P >> TRA_R] = circhebpip ;     
00158     invcf_r[R_CHEBPI_I >> TRA_R] = circhebpii ;     
00159     invcf_r[R_JACO02 >> TRA_R] = cirjaco02 ;
00160 
00161     invcf_t[NONDEF] = ibase_non_def_t ;
00162     invcf_t[T_COS >> TRA_T] = citcos ;
00163     invcf_t[T_SIN >> TRA_T] = citsin ;
00164     invcf_t[T_COS_P >> TRA_T] = citcosp ;
00165     invcf_t[T_COS_I >> TRA_T] = citcosi ;
00166     invcf_t[T_SIN_P >> TRA_T] = citsinp ;
00167     invcf_t[T_SIN_I >> TRA_T] = citsini ;
00168     invcf_t[T_COSSIN_CP >> TRA_T] = citcossincp ;
00169     invcf_t[T_COSSIN_SI >> TRA_T] = citcossinsi ;
00170     invcf_t[T_COSSIN_SP >> TRA_T] = citcossinsp ;
00171     invcf_t[T_COSSIN_CI >> TRA_T] = citcossinci ;
00172     invcf_t[T_COSSIN_S >> TRA_T] = citcossins ;
00173     invcf_t[T_COSSIN_C >> TRA_T] = citcossinc ;
00174     invcf_t[T_LEG_P >> TRA_T] = citlegp ;
00175     invcf_t[T_LEG_PP >> TRA_T] = citlegpp ;
00176     invcf_t[T_LEG_I >> TRA_T] = citlegi ;
00177     invcf_t[T_LEG_IP >> TRA_T] = citlegip ;
00178     invcf_t[T_LEG_PI >> TRA_T] = citlegpi ;
00179     invcf_t[T_LEG_II >> TRA_T] = citlegii ; 
00180     invcf_t[T_LEG_MP >> TRA_T] = citlegmp ;
00181     invcf_t[T_LEG_MI >> TRA_T] = citlegmi ;
00182     invcf_t[T_LEG >> TRA_T] = citleg ;
00183 
00184     invcf_p[NONDEF] = ibase_non_def_p ;
00185     invcf_p[P_COSSIN >> TRA_P] = cipcossin ;
00186     invcf_p[P_COSSIN_P >> TRA_P] = cipcossin ;
00187     invcf_p[P_COSSIN_I >> TRA_P] = cipcossini ;
00188 
00189     }  // fin des operation de premier appel
00190 
00191         //------------------//
00192         // DEBUT DU CALCUL  //
00193         //------------------//      
00194        
00195     // Tout null ?
00196     if (etat == ETATZERO) {
00197     return ;
00198     }
00199     
00200     // Protection
00201     assert(etat != ETATNONDEF) ;
00202         
00203     // Peut-etre rien a faire
00204     if (c != 0x0) {
00205     return ;
00206     }
00207     
00208     // Il faut bosser
00209     assert(c_cf != 0x0) ;       // ..si on peut
00210     assert(c_cf->base == base) ;        // Consistence des bases
00211 
00212     c = new Mtbl(mg) ;
00213     c->set_etat_qcq() ;
00214     
00215     // Boucles sur les zones
00216     int nz = mg->get_nzone() ;
00217     for (int l=0; l<nz; l++) {
00218     
00219     // Initialisation des valeurs de this->c_cf avec celle de this->c :
00220     Tbl* f =  (c->t)[l]  ;
00221     const Tbl* cf =  (c_cf->t)[l]  ;
00222 
00223     if (cf->get_etat() == ETATZERO) {
00224         f->set_etat_zero() ;
00225         continue ; // on ne fait rien si le tbl(cf) = 0  
00226     }
00227 
00228     f->set_etat_qcq() ;
00229 
00230     int np = f->get_dim(2) ;
00231     int nt = f->get_dim(1) ;
00232     int nr = f->get_dim(0) ;
00233 
00234     int np_c = cf->get_dim(2) ;
00235     int nt_c = cf->get_dim(1) ;
00236     int nr_c = cf->get_dim(0) ;     
00237 
00238     // Attention a ce qui suit... (deg et dim)
00239     int deg[3] ;
00240     deg[0] = np ;
00241     deg[1] = nt ;
00242     deg[2] = nr ;
00243 
00244     int dimc[3] ;
00245     dimc[0] = np_c ;
00246     dimc[1] = nt_c ;
00247     dimc[2] = nr_c ;
00248 
00249     // Allocation de l'espace memoire pour le tableau de travail trav
00250     int ntot = cf->get_taille() ;
00251     double* trav = new double[ntot] ; 
00252 
00253     // On recupere les bases en r, theta et phi : 
00254     int base_r = ( base.b[l] & MSQ_R ) >> TRA_R ;
00255     int base_t = ( base.b[l] & MSQ_T ) >> TRA_T ;
00256     int base_p = ( base.b[l] & MSQ_P ) >> TRA_P ;
00257     int vbase_t = base.b[l] & MSQ_T ;
00258     int vbase_p = base.b[l] & MSQ_P ;
00259 
00260     assert(base_r < MAX_BASE) ; 
00261     assert(base_t < MAX_BASE) ; 
00262     assert(base_p < MAX_BASE_2) ; 
00263 
00264     // Transformation inverse en r:
00265     if ( nr == 1 ) {
00266         for (int i=0; i<ntot; i++) {
00267         trav[i] = cf->t[i] ;    // simple recopie cf --> trav
00268         }       
00269     }
00270     else {
00271         invcf_r[base_r]( deg, dimc, (cf->t), dimc, trav ) ;
00272     }
00273     
00274     // Partie angulaire
00275     if ( np == 1) {
00276         if (nt==1) {
00277         for (int i=0 ; i<f->get_taille() ; i++)
00278             f->t[i] = trav[i] ;
00279         if ((vbase_t == T_LEG_PP) || (vbase_t == T_LEG_PI) || 
00280             (vbase_t == T_LEG_IP) || (vbase_t == T_LEG_II) ||
00281             (vbase_t == T_LEG_P) || (vbase_t == T_LEG_I) ||
00282             (vbase_t == T_LEG_MP) || (vbase_t == T_LEG_MI) ||
00283             (vbase_t == T_LEG) ) {
00284             
00285             *f /=sqrt(2.) ;     
00286         }
00287         }
00288         
00289         else {
00290         bool pair = ( (vbase_t == T_LEG_PP) || (vbase_t == T_LEG_IP)
00291               || (vbase_t == T_LEG_MP) ) ;
00292         bool impair = ( (vbase_t == T_LEG_PI) || (vbase_t == T_LEG_II)
00293               || (vbase_t == T_LEG_MI)) ;
00294         
00295         if ((pair && (vbase_p == P_COSSIN_I)) ||
00296         (impair && (vbase_p == P_COSSIN_P)) )
00297           ipasprevu_t(deg, dimc, trav, deg, (f->t) ) ;
00298         else        
00299           invcf_t[base_t]( deg, dimc, trav, deg, (f->t) ) ;
00300       }
00301     }
00302     else {
00303       // Cas 3-D
00304       //  ...... Transformation inverse en theta:
00305       bool pair = ( (vbase_t == T_LEG_PP) || (vbase_t == T_LEG_IP)
00306             || (vbase_t == T_LEG_MP) ) ;
00307       bool impair = ( (vbase_t == T_LEG_PI) || (vbase_t == T_LEG_II)
00308               || (vbase_t == T_LEG_MI) ) ;
00309       
00310       if ((pair && (vbase_p == P_COSSIN_I)) ||
00311           (impair && (vbase_p == P_COSSIN_P)) )
00312         ipasprevu_t(deg, dimc, trav, dimc, trav ) ;
00313       else      
00314         invcf_t[base_t]( deg, dimc, trav, dimc, trav ) ;
00315       //  ...... Transformation inverse en phi:
00316       invcf_p[base_p]( deg, dimc, deg, trav, (f->t) ) ;
00317     }
00318     // Menage
00319     delete [] trav ;
00320     }  // fin de la boucle sur les differentes zones
00321 
00322 }
00323 
00324             //------------------------//
00325             // Les machins pas prevus //
00326             //------------------------//
00327 
00328 void ipasprevu_r(const int*, const int*, double*, const int*, double*) {
00329     cout << "Valeur::coef_i: the required expansion basis in r " << endl ;
00330     cout << "  is not implemented !" << endl ;
00331     abort() ; 
00332 }
00333 
00334 void ipasprevu_t(const int*, const int*, double*, const int*, double* ) {
00335     cout << "Valeur::coef_i: the required expansion basis in theta " << endl ;
00336     cout << "  is not implemented !" << endl ;
00337     abort() ; 
00338 }
00339 
00340 void ipasprevu_p(const int*, const int*, const int*, double*, double* ) {
00341     cout << "Valeur::coef_i: the required expansion basis in phi " << endl ;
00342     cout << "  is not implemented !" << endl ;
00343     abort() ; 
00344 }
00345 
00346 void ibase_non_def_r(const int*, const int*, double*, const int*, double*) {
00347     cout << "Valeur::coef_i: the expansion basis in r is undefined !" << endl ;
00348     abort() ; 
00349 }
00350 
00351 void ibase_non_def_t(const int*, const int*, double*, const int*, double*) {
00352     cout << "Valeur::coef_i: the expansion basis in theta is undefined !" 
00353      << endl ;
00354     abort() ; 
00355 }
00356 
00357 void ibase_non_def_p(const int*, const int*, const int*, double*, double*) {
00358     cout << "Valeur::coef_i: the expansion basis in phi is undefined !" << endl ;
00359     abort() ; 
00360 }
00361 

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