som_asymy.C

00001 /*
00002  *   Copyright (c) 2000-2001 Eric Gourgoulhon
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 som_asymy_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_asymy.C,v 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon Exp $" ;
00024 
00025 /*
00026  * Ensemble des routine pour la sommation directe en r, theta et phi dans
00027  * le cas symetrie equatoriale (plan z=0) + antisymetrie par rapport au plan y=0
00028  * 
00029  *   SYNOPSYS:
00030  *     double som_r_XX_asymy
00031  *  (double* ti, int nr, int nt, int np, double x, double* trtp)
00032  *
00033  *     x est l'argument du polynome de Chebychev: x in [0, 1] ou x in [-1, 1]
00034  *
00035  *
00036  *     double som_tet_XX_asymy
00037  *  (double* ti, int nt, int np, double tet, double* to)
00038  * 
00039  *     double som_phi_XX_asymy
00040  *  (double* ti, int np, double phi, double* xo)
00041  *
00042  *   ATTENTION: np est suppose etre le nombre de points (sans le +2)
00043  *      on suppose que trtp tient compte de ca.
00044  */
00045 
00046 /*
00047  * $Id: som_asymy.C,v 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon Exp $
00048  * $Log: som_asymy.C,v $
00049  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00050  * LORENE
00051  *
00052  * Revision 2.0  2000/03/06  10:27:45  eric
00053  * *** empty log message ***
00054  *
00055  *
00056  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_asymy.C,v 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon Exp $
00057  *
00058  */
00059 
00060 
00061 // Headers C
00062 #include <math.h>
00063 
00064 //****************************************************************************
00065 //              Sommation en r
00066 //****************************************************************************
00067 
00071 
00072 void som_r_cheb_asymy(double* ti, const int nr, const int nt, const int np, 
00073               const double x, double* trtp) {
00074 
00075 // Variables diverses
00076 int i, j, k ;
00077 double* pi = ti ;       // pointeur courant sur l'entree
00078 double* po = trtp ;     // pointeur courant sur la sortie
00079     
00080     // Valeurs des polynomes de Chebyshev au point x demande
00081     double* cheb = new double [nr] ;
00082     cheb[0] = 1. ;
00083     cheb[1] = x ;
00084     for (i=2; i<nr; i++) {
00085     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00086     }
00087     
00088     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00089     //  cos(0 phi), sin(0 phi) et cos(phi)
00090     pi += 3*nr*nt ;
00091     po += 3*nt ;
00092         
00093     // Sommation sur les phi suivants (pour k=3,...,np)
00094     //  en sautant les cosinus (d'ou le k+=2)
00095     for (k=3 ; k<np+1 ; k+=2) {
00096     for (j=0 ; j<nt ; j++) {
00097         // Sommation sur r
00098         *po = 0 ;
00099         for (i=0 ; i<nr ; i++) {
00100         *po += (*pi) * cheb[i] ;
00101         pi++ ;  // R suivant
00102         }
00103         po++ ;  // Theta suivant
00104     }
00105     // On saute le cos(m*phi) : 
00106     pi += nr*nt ;
00107     po += nt ;
00108     }
00109     
00110     // Menage
00111     delete [] cheb ;
00112 }
00113 
00114 
00115 
00119 
00120 void som_r_chebu_asymy(double* ti, const int nr, const int nt, const int np, 
00121                const double x, double* trtp) {
00122 
00123 // Variables diverses
00124 int i, j, k ;
00125 double* pi = ti ;       // pointeur courant sur l'entree
00126 double* po = trtp ;     // pointeur courant sur la sortie
00127     
00128     // Valeurs des polynomes de Chebyshev au point x demande
00129     double* cheb = new double [nr] ;
00130     cheb[0] = 1. ;
00131     cheb[1] = x ;
00132     for (i=2; i<nr; i++) {
00133     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00134     }
00135     
00136     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00137     //  cos(0 phi), sin(0 phi) et cos(phi)
00138     pi += 3*nr*nt ;
00139     po += 3*nt ;
00140     
00141     // Sommation sur les phi suivants (pour k=3,...,np)
00142     //  en sautant les cosinus (d'ou le k+=2)
00143     for (k=3 ; k<np+1 ; k+=2) {
00144     for (j=0 ; j<nt ; j++) {
00145         // Sommation sur r
00146         *po = 0 ;
00147         for (i=0 ; i<nr ; i++) {
00148         *po += (*pi) * cheb[i] ;
00149         pi++ ;  // R suivant
00150         }
00151         po++ ;  // Theta suivant
00152     }
00153     // On saute le cos(m*phi) : 
00154     pi += nr*nt ;
00155     po += nt ;
00156     }
00157 
00158     // Menage
00159     delete [] cheb ;
00160     
00161 }
00162 
00163 
00164 
00168 
00169 void som_r_chebpim_p_asymy(double* ti, const int nr, const int nt, 
00170                const int np, const double x, double* trtp) {
00171 
00172 // Variables diverses
00173 int i, j, k ;
00174 double* pi = ti ;       // pointeur courant sur l'entree
00175 double* po = trtp ;     // pointeur courant sur la sortie
00176     
00177     // Valeurs des polynomes de Chebyshev au point x demande
00178     double* cheb = new double [2*nr] ;
00179     cheb[0] = 1. ;
00180     cheb[1] = x ;
00181     for (i=2 ; i<2*nr ; i++) {
00182     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00183     }
00184     
00185 
00186     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00187     //  cos(0 phi), sin(0 phi) et cos(phi)
00188     pi += 3*nr*nt ;
00189     po += 3*nt ;
00190     
00191     // Sommation sur les phi suivants (pour k=3,...,np)
00192     //  en sautant les cosinus (d'ou le k+=2)
00193     for (k=3 ; k<np+1 ; k+=2) {
00194     int m = (k/2) % 2 ;         // parite: 0 <-> 1
00195     for (j=0 ; j<nt ; j++) {
00196         // Sommation sur r
00197         *po = 0 ;
00198         for (i=0 ; i<nr ; i++) {
00199         *po += (*pi) * cheb[2*i + m] ;
00200         pi++ ;  // R suivant
00201         }
00202         po++ ;  // Theta suivant
00203     }
00204     // On saute le cos(m*phi) : 
00205     pi += nr*nt ;
00206     po += nt ;
00207     }
00208     
00209 
00210     // Menage
00211    delete [] cheb ;
00212     
00213 }
00214 
00218 
00219 void som_r_chebpim_i_asymy(double* ti, const int nr, const int nt, 
00220                const int np, const double x, double* trtp) {
00221 
00222 // Variables diverses
00223 int i, j, k ;
00224 double* pi = ti ;       // pointeur courant sur l'entree
00225 double* po = trtp ;     // pointeur courant sur la sortie
00226     
00227     // Valeurs des polynomes de Chebyshev au point x demande
00228     double* cheb = new double [2*nr] ;
00229     cheb[0] = 1. ;
00230     cheb[1] = x ;
00231     for (i=2 ; i<2*nr ; i++) {
00232     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00233     }
00234     
00235     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00236     //  cos(0 phi), sin(0 phi) et cos(phi)
00237     pi += 3*nr*nt ;
00238     po += 3*nt ;
00239         
00240     // Sommation sur les phi suivants (pour k=3,...,np)
00241     //  en sautant les cosinus (d'ou le k+=2)
00242     for (k=3 ; k<np+1 ; k+=2) {
00243     int m = (k/2) % 2 ;         // parite: 0 <-> 1
00244     for (j=0 ; j<nt ; j++) {
00245         // Sommation sur r
00246         *po = 0 ;
00247         for (i=0 ; i<nr ; i++) {
00248         *po += (*pi) * cheb[2*i + 1 - m] ;
00249         pi++ ;  // R suivant
00250         }
00251         po++ ;  // Theta suivant
00252     }
00253     // On saute le cos(m*phi) : 
00254     pi += nr*nt ;
00255     po += nt ;
00256     }
00257     
00258     // Menage
00259     delete [] cheb ;
00260     
00261 }
00262 
00263 
00264 
00265 //****************************************************************************
00266 //              Sommation en theta
00267 //****************************************************************************
00268 
00272 
00273 void som_tet_cossin_cp_asymy(double* ti, const int nt, const int np,
00274                  const double tet, double* to) {
00275     
00276 // Variables diverses
00277 int j, k ;
00278 double* pi = ti ;       // Pointeur courant sur l'entree
00279 double* po = to ;       // Pointeur courant sur la sortie
00280 
00281     // Initialisation des tables trigo
00282     double* cossin = new double [2*nt] ;
00283     for (j=0 ; j<2*nt ; j +=2) {
00284     cossin[j] = cos(j * tet) ;
00285     cossin[j+1] = sin((j+1) * tet) ;
00286     }
00287     
00288     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00289     //  cos(0 phi), sin(0 phi) et cos(phi)
00290     pi += 3*nt ;
00291     po += 3 ;
00292 
00293     // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
00294     for (k=3 ; k<np+1 ; k+=2) {
00295     int m = (k/2) % 2 ;     // parite: 0 <-> 1
00296     (*po) = 0 ;
00297     for (j=0 ; j<nt ; j++) {
00298         *po += (*pi) * cossin[2*j + m] ;
00299         pi++ ;  // Theta suivant
00300     }
00301     po++ ;      // Phi suivant
00302 
00303     // On saute le cos(m*phi) : 
00304     pi += nt ;
00305     po++ ;
00306 
00307     }
00308 
00309     // Menage
00310     delete [] cossin ;
00311 }
00312 
00316 
00317 void som_tet_cossin_ci_asymy(double* ti, const int nt, const int np,
00318                  const double tet, double* to) {
00319     
00320 // Variables diverses
00321 int j, k ;
00322 double* pi = ti ;       // Pointeur courant sur l'entree
00323 double* po = to ;       // Pointeur courant sur la sortie
00324 
00325     // Initialisation des tables trigo
00326     double* cossin = new double [2*nt] ;
00327     for (j=0 ; j<2*nt ; j +=2) {
00328     cossin[j] = cos((j+1) * tet) ;
00329     cossin[j+1] = sin(j * tet) ;
00330     }
00331     
00332     // On saute les 3 premiers coef. en phi, qui sont respectivemment
00333     //  cos(0 phi), sin(0 phi) et cos(phi)
00334     pi += 3*nt ;
00335     po += 3 ;
00336 
00337     // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
00338     for (k=3 ; k<np+1 ; k+=2) {
00339     int m = (k/2) % 2 ;     // parite: 0 <-> 1
00340     (*po) = 0 ;
00341     for (j=0 ; j<nt ; j++) {
00342         *po += (*pi) * cossin[2*j + m] ;
00343         pi++ ;  // Theta suivant
00344     }
00345     po++ ;      // Phi suivant
00346 
00347     // On saute le cos(m*phi) : 
00348     pi += nt ;
00349     po++ ;
00350 
00351     }
00352 
00353     // Menage
00354     delete [] cossin ;
00355 }
00356 
00357 
00358 //****************************************************************************
00359 //              Sommation en phi
00360 //****************************************************************************
00361 
00362 void som_phi_cossin_asymy(double* ti, const int np, const double phi, 
00363               double* xo) {
00364     
00365     *xo = 0 ; 
00366 
00367     // Sommation sur les sinus seulement
00368     for (int k=3 ; k<np+1 ; k +=2 ) {
00369     int m = k/2 ;
00370     *xo += ti[k] * sin(m * phi) ;
00371     }
00372 
00373 }
00374 

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