mtbl_cf_vp_symy.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 symmetric 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 
00031 char mtbl_cf_vp_symy_C[] = "$Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_vp_symy.C,v 1.2 2012/01/17 15:09:22 j_penner Exp $" ;
00032 
00033 /*
00034  * $Id: mtbl_cf_vp_symy.C,v 1.2 2012/01/17 15:09:22 j_penner Exp $
00035  * $Log: mtbl_cf_vp_symy.C,v $
00036  * Revision 1.2  2012/01/17 15:09:22  j_penner
00037  * using MAX_BASE_2 for the phi coordinate
00038  *
00039  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00040  * LORENE
00041  *
00042  * Revision 2.2  2000/09/08  16:07:36  eric
00043  * Ajout de la base P_COSSIN_I
00044  *
00045  * Revision 2.1  2000/03/06  15:57:34  eric
00046  * *** empty log message ***
00047  *
00048  * Revision 2.0  2000/03/06  10:27:02  eric
00049  * *** empty log message ***
00050  *
00051  *
00052  * $Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_vp_symy.C,v 1.2 2012/01/17 15:09:22 j_penner Exp $
00053  *
00054  */
00055 
00056 
00057 // Headers Lorene
00058 #include "mtbl_cf.h"
00059 #include "proto.h"
00060 
00061     //-------------------------------------------------------------//
00062     //      version for an arbitrary point in (xi,theta',phi')     //
00063     //-------------------------------------------------------------//
00064 
00065 double Mtbl_cf::val_point_symy(int l, double x, double theta, double phi) 
00066              const {
00067 
00068 // Routines de sommation
00069 static void (*som_r[MAX_BASE])
00070         (double*, const int, const int, const int, const double, double*) ;
00071 static void (*som_tet[MAX_BASE])
00072         (double*, const int, const int, const double, double*) ;
00073 static void (*som_phi[MAX_BASE_2])
00074         (double*, const int, const double, double*) ;
00075 static int premier_appel = 1 ;
00076 
00077 // Initialisations au premier appel
00078 // --------------------------------
00079     if (premier_appel == 1) {
00080 
00081     premier_appel = 0 ;
00082 
00083     for (int i=0 ; i<MAX_BASE ; i++) {
00084         if(i%2==0){
00085         som_phi[i/2] = som_phi_pas_prevu ;
00086         }
00087         som_tet[i] = som_tet_pas_prevu ;
00088         som_r[i]   = som_r_pas_prevu ;
00089     }
00090 
00091     som_r[R_CHEB >> TRA_R] = som_r_cheb_symy ;
00092     som_r[R_CHEBP >> TRA_R] = som_r_chebp ;
00093     som_r[R_CHEBI >> TRA_R] = som_r_chebi ;
00094     som_r[R_CHEBU >> TRA_R] = som_r_chebu_symy ;
00095     som_r[R_CHEBPIM_P >> TRA_R] = som_r_chebpim_p_symy ;
00096     som_r[R_CHEBPIM_I >> TRA_R] = som_r_chebpim_i_symy ;
00097 
00098     som_tet[T_COS >> TRA_T] = som_tet_cos ;
00099     som_tet[T_SIN >> TRA_T] = som_tet_sin ;
00100     som_tet[T_COS_P >> TRA_T] = som_tet_cos_p ;
00101     som_tet[T_SIN_P >> TRA_T] = som_tet_sin_p ;
00102     som_tet[T_COSSIN_CP >> TRA_T] = som_tet_cossin_cp_symy ;
00103     som_tet[T_COSSIN_CI >> TRA_T] = som_tet_cossin_ci_symy ;
00104 
00105     som_phi[P_COSSIN >> TRA_P] = som_phi_cossin_symy ;
00106     som_phi[P_COSSIN_P >> TRA_P] = som_phi_cossin_p ;
00107     som_phi[P_COSSIN_I >> TRA_P] = som_phi_cossin_i ;
00108 
00109     }   // fin des operations de premier appel
00110 
00111 
00112     assert (etat != ETATNONDEF) ; 
00113 
00114     double resu ;           // valeur de retour    
00115 
00116 // Cas ou tous les coefficients sont nuls :
00117     if (etat == ETATZERO ) {
00118     resu = 0 ;
00119     return resu ; 
00120     } 
00121  
00122 // Nombre de points en phi, theta et r :
00123     int np = mg->get_np(l) ;     
00124     int nt = mg->get_nt(l) ;
00125     int nr = mg->get_nr(l) ;
00126 
00127 // Bases de developpement : 
00128     int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
00129     int base_t = (base.b[l] & MSQ_T) >> TRA_T ;
00130     int base_p = (base.b[l] & MSQ_P) >> TRA_P ;
00131     
00132 //--------------------------------------
00133 // Calcul de la valeur au point demande
00134 //--------------------------------------
00135 
00136 // Pointeur sur le tableau contenant les coefficients: 
00137 
00138     assert(etat == ETATQCQ) ; 
00139     Tbl* tbcf = t[l] ; 
00140     
00141     if (tbcf->get_etat() == ETATZERO ) {
00142     resu = 0 ;
00143     return resu ; 
00144     } 
00145 
00146 
00147     assert(tbcf->get_etat() == ETATQCQ) ; 
00148 
00149     double* cf = tbcf->t ;
00150 
00151     // Tableaux de travail 
00152     double* trp = new double [np+2] ;
00153     double* trtp = new double [(np+2)*nt] ;
00154  
00155     if (nr == 1) {
00156     
00157 // Cas particulier nr = 1 (Fonction purement angulaire) : 
00158 // ----------------------
00159     
00160     som_tet[base_t](cf, nt, np, theta, trp) ;   // sommation sur theta
00161     }
00162     else {
00163 
00164 // Cas general
00165 // -----------
00166 
00167     som_r[base_r](cf, nr, nt, np, x, trtp) ;    // sommation sur r
00168     som_tet[base_t](trtp, nt, np, theta, trp) ; // sommation sur theta
00169     }
00170 
00171 // Sommation sur phi
00172 // -----------------
00173 
00174     if (np == 1) {
00175     resu = trp[0] ;     // cas axisymetrique
00176     }
00177     else {
00178     som_phi[base_p](trp, np, phi, &resu) ;      // sommation sur phi
00179     }
00180 
00181     // Menage
00182     delete [] trp ;
00183     delete [] trtp ;
00184     
00185     // Termine
00186     return resu ;  
00187  
00188 }
00189  
00190 
00191 
00192     //-------------------------------------------------------------//
00193     //      version for an arbitrary point in xi           //
00194     //      but collocation point in (theta',phi')         //
00195     //-------------------------------------------------------------//
00196 
00197 double Mtbl_cf::val_point_jk_symy(int l, double x, int j0, int k0) const {
00198 
00199 // Routines de sommation
00200 static void (*som_r[MAX_BASE])
00201         (double*, const int, const int, const int, const double, double*) ;
00202 static int premier_appel = 1 ;
00203 
00204 // Initialisations au premier appel
00205 // --------------------------------
00206     if (premier_appel == 1) {
00207 
00208     premier_appel = 0 ;
00209 
00210     for (int i=0 ; i<MAX_BASE ; i++) {
00211         som_r[i]   = som_r_pas_prevu ;
00212     }
00213 
00214     som_r[R_CHEB >> TRA_R] = som_r_cheb_symy ;
00215     som_r[R_CHEBP >> TRA_R] = som_r_chebp ;
00216     som_r[R_CHEBI >> TRA_R] = som_r_chebi ;
00217     som_r[R_CHEBU >> TRA_R] = som_r_chebu_symy ;
00218     som_r[R_CHEBPIM_P >> TRA_R] = som_r_chebpim_p_symy ;
00219     som_r[R_CHEBPIM_I >> TRA_R] = som_r_chebpim_i_symy ;
00220 
00221     }   // fin des operations de premier appel
00222 
00223     assert (etat != ETATNONDEF) ; 
00224 
00225     double resu ;           // valeur de retour    
00226 
00227 // Cas ou tous les coefficients sont nuls :
00228     if (etat == ETATZERO ) {
00229     resu = 0 ;
00230     return resu ; 
00231     } 
00232  
00233 // Nombre de points en phi, theta et r :
00234     int np = mg->get_np(l) ;     
00235     int nt = mg->get_nt(l) ;
00236     int nr = mg->get_nr(l) ;
00237 
00238 // Bases de developpement : 
00239     int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
00240 
00241 //------------------------------------------------------------------------
00242 //  Valeurs des fonctions de base en phi aux points de collocation en phi
00243 //   et des fonctions de base en theta aux points de collocation en theta
00244 //------------------------------------------------------------------------
00245 
00246     Tbl tab_phi = base.phi_functions(l, np) ; 
00247     Tbl tab_theta = base.theta_functions(l, nt) ; 
00248 
00249     
00250 //--------------------------------------
00251 // Calcul de la valeur au point demande
00252 //--------------------------------------
00253 
00254 // Pointeur sur le tableau contenant les coefficients: 
00255 
00256     assert(etat == ETATQCQ) ; 
00257     Tbl* tbcf = t[l] ; 
00258     
00259     if (tbcf->get_etat() == ETATZERO ) {
00260     resu = 0 ;
00261     return resu ; 
00262     } 
00263 
00264 
00265     assert(tbcf->get_etat() == ETATQCQ) ; 
00266 
00267     double* cf = tbcf->t ;
00268 
00269     // Tableau de travail 
00270     double* coef_tp = new double [(np+2)*nt] ;
00271  
00272 
00273 // 1/ Sommation sur r
00274 // ------------------
00275 
00276     som_r[base_r](cf, nr, nt, np, x, coef_tp) ;
00277 
00278 
00279 // 2/ Sommation sur theta et phi
00280 // -----------------------------
00281     double* pi = coef_tp ;  // pointeur courant sur les coef en theta et phi
00282 
00283 // Sommation sur le premier phi, k=0
00284 
00285     double somt = 0 ;
00286     for (int j=0 ; j<nt ; j++) {
00287     somt += (*pi) * tab_theta(0, j, j0) ;
00288     pi++ ;  // theta suivant
00289     }
00290     resu = somt * tab_phi(0, k0)    ;
00291  
00292     if (np > 1) {   // sommation sur phi
00293 
00294     // On saute le phi suivant (sin(0)), k=1
00295     pi += nt ;
00296 
00297     // Sommation sur le reste des phi (pour k=2,...,np)
00298 
00299     int base_t = base.b[l] & MSQ_T ;
00300 
00301     switch (base_t) {
00302                         
00303         case T_COSSIN_CP : {
00304 
00305         for (int k=2 ; k<np+1 ; k+=2) {  // k+=2 : on saute les sin(m phi)
00306             int m_par = (k/2)%2 ;   // 0 pour m pair, 1 pour m impair
00307             somt = 0 ;
00308             for (int j=0 ; j<nt ; j++) {
00309             somt += (*pi) * tab_theta(m_par, j, j0) ;
00310             pi++ ;  // theta suivant
00311             }
00312             resu += somt * tab_phi(k, k0) ;
00313 
00314             // On saute le sin(k*phi) : 
00315             pi += nt ;
00316         }
00317         break ;
00318         }
00319      
00320         default: {
00321         cout << "Mtbl_cf::val_point_jk_symy: unknown theta basis ! " 
00322              << endl ;
00323         abort () ;
00324         }
00325            
00326     }   // fin des cas sur base_t 
00327     
00328     }   // fin du cas np > 1 
00329 
00330 
00331     // Menage
00332     delete [] coef_tp ;
00333     
00334     // Termine
00335     return resu ;  
00336  
00337 }
00338  
00339 

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