mtbl_cf_vp_asymy.C

00001 /*
00002  * Member functions of the Mtbl_cf class for computing the value of a field
00003  *  at an arbitrary point, when the field is antisymmetric with respect to the
00004  *  y=0 plane.
00005  *
00006  * (see file mtbl_cf.h for the documentation).
00007  */
00008 
00009 /*
00010  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 char mtbl_cf_vp_asymy_C[] = "$Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_vp_asymy.C,v 1.2 2012/01/17 15:09:14 j_penner Exp $" ;
00031 
00032 /*
00033  * $Id: mtbl_cf_vp_asymy.C,v 1.2 2012/01/17 15:09:14 j_penner Exp $
00034  * $Log: mtbl_cf_vp_asymy.C,v $
00035  * Revision 1.2  2012/01/17 15:09:14  j_penner
00036  * using MAX_BASE_2 for the phi coordinate
00037  *
00038  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00039  * LORENE
00040  *
00041  * Revision 2.3  2000/09/08  16:07:26  eric
00042  * Ajout de la base P_COSSIN_I
00043  *
00044  * Revision 2.2  2000/03/06  15:59:03  eric
00045  * *** empty log message ***
00046  *
00047  * Revision 2.1  2000/03/06  15:57:29  eric
00048  * *** empty log message ***
00049  *
00050  * Revision 2.0  2000/03/06  10:26:54  eric
00051  * *** empty log message ***
00052  *
00053  *
00054  * $Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_vp_asymy.C,v 1.2 2012/01/17 15:09:14 j_penner Exp $
00055  *
00056  */
00057 
00058 
00059 // Headers Lorene
00060 #include "mtbl_cf.h"
00061 #include "proto.h"
00062 
00063     //-------------------------------------------------------------//
00064     //      version for an arbitrary point in (xi,theta',phi')     //
00065     //-------------------------------------------------------------//
00066 
00067 double Mtbl_cf::val_point_asymy(int l, double x, double theta, double phi) 
00068              const {
00069 
00070 // Routines de sommation
00071 static void (*som_r[MAX_BASE])
00072         (double*, const int, const int, const int, const double, double*) ;
00073 static void (*som_tet[MAX_BASE])
00074         (double*, const int, const int, const double, double*) ;
00075 static void (*som_phi[MAX_BASE_2])
00076         (double*, const int, const double, double*) ;
00077 static int premier_appel = 1 ;
00078 
00079 // Initialisations au premier appel
00080 // --------------------------------
00081     if (premier_appel == 1) {
00082 
00083     premier_appel = 0 ;
00084 
00085     for (int i=0 ; i<MAX_BASE ; i++) {
00086         if(i%2==0){
00087         som_phi[i/2] = som_phi_pas_prevu ;
00088         }
00089         som_tet[i] = som_tet_pas_prevu ;
00090         som_r[i]   = som_r_pas_prevu ;
00091     }
00092 
00093     som_r[R_CHEB >> TRA_R] = som_r_cheb_asymy ;
00094     som_r[R_CHEBP >> TRA_R] = som_r_chebp ;
00095     som_r[R_CHEBI >> TRA_R] = som_r_chebi ;
00096     som_r[R_CHEBU >> TRA_R] = som_r_chebu_asymy ;
00097     som_r[R_CHEBPIM_P >> TRA_R] = som_r_chebpim_p_asymy ;
00098     som_r[R_CHEBPIM_I >> TRA_R] = som_r_chebpim_i_asymy ;
00099 
00100     som_tet[T_COS >> TRA_T] = som_tet_cos ;
00101     som_tet[T_SIN >> TRA_T] = som_tet_sin ;
00102     som_tet[T_COS_P >> TRA_T] = som_tet_cos_p ;
00103     som_tet[T_SIN_P >> TRA_T] = som_tet_sin_p ;
00104     som_tet[T_COSSIN_CP >> TRA_T] = som_tet_cossin_cp_asymy ;
00105     som_tet[T_COSSIN_CI >> TRA_T] = som_tet_cossin_ci_asymy ;
00106 
00107     som_phi[P_COSSIN >> TRA_P] = som_phi_cossin_asymy ;
00108     som_phi[P_COSSIN_P >> TRA_P] = som_phi_cossin_p ;
00109     som_phi[P_COSSIN_I >> TRA_P] = som_phi_cossin_i ;
00110 
00111     }   // fin des operations de premier appel
00112 
00113 
00114     assert (etat != ETATNONDEF) ; 
00115 
00116     double resu ;           // valeur de retour    
00117 
00118 // Cas ou tous les coefficients sont nuls :
00119     if (etat == ETATZERO ) {
00120     resu = 0 ;
00121     return resu ; 
00122     } 
00123  
00124 // Nombre de points en phi, theta et r :
00125     int np = mg->get_np(l) ;     
00126     int nt = mg->get_nt(l) ;
00127     int nr = mg->get_nr(l) ;
00128 
00129 // Bases de developpement : 
00130     int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
00131     int base_t = (base.b[l] & MSQ_T) >> TRA_T ;
00132     int base_p = (base.b[l] & MSQ_P) >> TRA_P ;
00133     
00134 //--------------------------------------
00135 // Calcul de la valeur au point demande
00136 //--------------------------------------
00137 
00138 // Pointeur sur le tableau contenant les coefficients: 
00139 
00140     assert(etat == ETATQCQ) ; 
00141     Tbl* tbcf = t[l] ; 
00142     
00143     if (tbcf->get_etat() == ETATZERO ) {
00144     resu = 0 ;
00145     return resu ; 
00146     } 
00147 
00148 
00149     assert(tbcf->get_etat() == ETATQCQ) ; 
00150 
00151     double* cf = tbcf->t ;
00152 
00153     // Tableaux de travail 
00154     double* trp = new double [np+2] ;
00155     double* trtp = new double [(np+2)*nt] ;
00156  
00157     if (nr == 1) {
00158     
00159 // Cas particulier nr = 1 (Fonction purement angulaire) : 
00160 // ----------------------
00161     
00162     som_tet[base_t](cf, nt, np, theta, trp) ;   // sommation sur theta
00163     }
00164     else {
00165 
00166 // Cas general
00167 // -----------
00168 
00169     som_r[base_r](cf, nr, nt, np, x, trtp) ;    // sommation sur r
00170     som_tet[base_t](trtp, nt, np, theta, trp) ; // sommation sur theta
00171     }
00172 
00173 // Sommation sur phi
00174 // -----------------
00175 
00176     if (np == 1) {
00177     resu = trp[0] ;     // cas axisymetrique
00178     }
00179     else {
00180     som_phi[base_p](trp, np, phi, &resu) ;      // sommation sur phi
00181     }
00182 
00183     // Menage
00184     delete [] trp ;
00185     delete [] trtp ;
00186     
00187     // Termine
00188     return resu ;  
00189  
00190 }
00191  
00192 
00193 
00194     //-------------------------------------------------------------//
00195     //      version for an arbitrary point in xi           //
00196     //      but collocation point in (theta',phi')         //
00197     //-------------------------------------------------------------//
00198 
00199 double Mtbl_cf::val_point_jk_asymy(int l, double x, int j0, int k0) const {
00200 
00201 // Routines de sommation
00202 static void (*som_r[MAX_BASE])
00203         (double*, const int, const int, const int, const double, double*) ;
00204 static int premier_appel = 1 ;
00205 
00206 // Initialisations au premier appel
00207 // --------------------------------
00208     if (premier_appel == 1) {
00209 
00210     premier_appel = 0 ;
00211 
00212     for (int i=0 ; i<MAX_BASE ; i++) {
00213         som_r[i]   = som_r_pas_prevu ;
00214     }
00215 
00216     som_r[R_CHEB >> TRA_R] = som_r_cheb_asymy ;
00217     som_r[R_CHEBP >> TRA_R] = som_r_chebp ;
00218     som_r[R_CHEBI >> TRA_R] = som_r_chebi ;
00219     som_r[R_CHEBU >> TRA_R] = som_r_chebu_asymy ;
00220     som_r[R_CHEBPIM_P >> TRA_R] = som_r_chebpim_p_asymy ;
00221     som_r[R_CHEBPIM_I >> TRA_R] = som_r_chebpim_i_asymy ;
00222 
00223     }   // fin des operations de premier appel
00224 
00225     assert (etat != ETATNONDEF) ; 
00226 
00227     double resu ;           // valeur de retour    
00228 
00229 // Cas ou tous les coefficients sont nuls :
00230     if (etat == ETATZERO ) {
00231     resu = 0 ;
00232     return resu ; 
00233     } 
00234  
00235 // Nombre de points en phi, theta et r :
00236     int np = mg->get_np(l) ;     
00237     int nt = mg->get_nt(l) ;
00238     int nr = mg->get_nr(l) ;
00239 
00240 // Bases de developpement : 
00241     int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
00242 
00243 //------------------------------------------------------------------------
00244 //  Valeurs des fonctions de base en phi aux points de collocation en phi
00245 //   et des fonctions de base en theta aux points de collocation en theta
00246 //------------------------------------------------------------------------
00247 
00248     Tbl tab_phi = base.phi_functions(l, np) ; 
00249     Tbl tab_theta = base.theta_functions(l, nt) ; 
00250 
00251     
00252 //--------------------------------------
00253 // Calcul de la valeur au point demande
00254 //--------------------------------------
00255 
00256 // Pointeur sur le tableau contenant les coefficients: 
00257 
00258     assert(etat == ETATQCQ) ; 
00259     Tbl* tbcf = t[l] ; 
00260     
00261     if (tbcf->get_etat() == ETATZERO ) {
00262     resu = 0 ;
00263     return resu ; 
00264     } 
00265 
00266 
00267     assert(tbcf->get_etat() == ETATQCQ) ; 
00268 
00269     double* cf = tbcf->t ;
00270 
00271     // Tableau de travail 
00272     double* coef_tp = new double [(np+2)*nt] ;
00273  
00274 
00275 // 1/ Sommation sur r
00276 // ------------------
00277 
00278     som_r[base_r](cf, nr, nt, np, x, coef_tp) ;
00279 
00280 
00281 // 2/ Sommation sur theta et phi
00282 // -----------------------------
00283     double* pi = coef_tp ;  // pointeur courant sur les coef en theta et phi
00284 
00285     resu = 0 ; 
00286  
00287     if (np > 1) {   // sommation sur phi
00288 
00289     // On saute les coef k=0 (cos(0 phi), k=1 (sin(0 phi) et k=2
00290     pi += 3*nt ; 
00291 
00292     // Sommation sur le reste des phi (pour k=3,...,np)
00293 
00294     int base_t = base.b[l] & MSQ_T ;
00295 
00296     switch (base_t) {
00297                         
00298         case T_COSSIN_CP : {
00299 
00300         for (int k=3 ; k<np+1 ; k+=2) { // k+=2 : on saute les cos(m phi)
00301             int m_par = (k/2)%2 ;   // 0 pour m pair, 1 pour m impair
00302             double somt = 0 ;
00303             for (int j=0 ; j<nt ; j++) {
00304             somt += (*pi) * tab_theta(m_par, j, j0) ;
00305             pi++ ;  // theta suivant
00306             }
00307             resu += somt * tab_phi(k, k0) ;
00308 
00309             // On saute le cos(k*phi) : 
00310             pi += nt ;
00311         }
00312         break ;
00313         }
00314      
00315         default: {
00316         cout << "Mtbl_cf::val_point_jk_asymy: unknown theta basis ! " 
00317              << endl ;
00318         abort () ;
00319         }
00320            
00321     }   // fin des cas sur base_t 
00322     
00323     }   // fin du cas np > 1 
00324 
00325 
00326     // Menage
00327     delete [] coef_tp ;
00328     
00329     // Termine
00330     return resu ;  
00331  
00332 }
00333  
00334 

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