som_symy.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_symy_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_symy.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) + symetrie par rapport au plan y=0
00028  * 
00029  *   SYNOPSYS:
00030  *     double som_r_XX_symy
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_symy
00037  *  (double* ti, int nt, int np, double tet, double* to)
00038  * 
00039  *     double som_phi_XX_symy
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_symy.C,v 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon Exp $
00048  * $Log: som_symy.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:53  eric
00053  * *** empty log message ***
00054  *
00055  *
00056  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_symy.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 //****************************************************************************
00066 //              Sommation en r
00067 //****************************************************************************
00068 
00069 
00073 
00074 void som_r_cheb_symy
00075     (double* ti, const int nr, const int nt, const int np, const double x, 
00076     double* trtp) {
00077 
00078 // Variables diverses
00079 int i, j, k ;
00080 double* pi = ti ;       // pointeur courant sur l'entree
00081 double* po = trtp ;     // pointeur courant sur la sortie
00082     
00083     // Valeurs des polynomes de Chebyshev au point x demande
00084     double* cheb = new double [nr] ;
00085     cheb[0] = 1. ;
00086     cheb[1] = x ;
00087     for (i=2; i<nr; i++) {
00088     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00089     }
00090     
00091     // Sommation pour le premier phi, k=0
00092     for (j=0 ; j<nt ; j++) {
00093     *po = 0 ;
00094     // Sommation sur r
00095     for (i=0 ; i<nr ; i++) {
00096         *po += (*pi) * cheb[i] ;
00097         pi++ ;  // R suivant
00098     }
00099     po++ ;      // Theta suivant
00100     }
00101     
00102     if (np > 1) {   
00103 
00104     // On saute le deuxieme phi (sin(0)), k=1
00105     pi += nr*nt ;
00106     po += nt ;
00107     
00108     // Sommation sur les phi suivants (pour k=2,...,np)
00109     //  en sautant les sinus (d'ou le k+=2)
00110     for (k=2 ; k<np+1 ; k+=2) {
00111     for (j=0 ; j<nt ; j++) {
00112         // Sommation sur r
00113         *po = 0 ;
00114         for (i=0 ; i<nr ; i++) {
00115         *po += (*pi) * cheb[i] ;
00116         pi++ ;  // R suivant
00117         }
00118         po++ ;  // Theta suivant
00119     }
00120     // On saute le sin(k*phi) : 
00121     pi += nr*nt ;
00122     po += nt ;
00123     }
00124     
00125     }   // fin du cas np > 1 
00126 
00127     // Menage
00128     delete [] cheb ;
00129 }
00130 
00131 
00132 
00136 
00137 void som_r_chebu_symy
00138     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00139 
00140 // Variables diverses
00141 int i, j, k ;
00142 double* pi = ti ;       // pointeur courant sur l'entree
00143 double* po = trtp ;     // pointeur courant sur la sortie
00144     
00145     // Valeurs des polynomes de Chebyshev au point x demande
00146     double* cheb = new double [nr] ;
00147     cheb[0] = 1. ;
00148     cheb[1] = x ;
00149     for (i=2; i<nr; i++) {
00150     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00151     }
00152     
00153     // Sommation pour le premier phi, k=0
00154     for (j=0 ; j<nt ; j++) {
00155     *po = 0 ;
00156     // Sommation sur r
00157     for (i=0 ; i<nr ; i++) {
00158         *po += (*pi) * cheb[i] ;
00159         pi++ ;  // R suivant
00160     }
00161     po++ ;      // Theta suivant
00162     }
00163     
00164     if (np > 1) {   
00165 
00166     // On saute le deuxieme phi (sin(0)), k=1
00167     pi += nr*nt ;
00168     po += nt ;
00169     
00170     // Sommation sur les phi suivants (pour k=2,...,np)
00171     //  en sautant les sinus (d'ou le k+=2)
00172     for (k=2 ; k<np+1 ; k+=2) {
00173     for (j=0 ; j<nt ; j++) {
00174         // Sommation sur r
00175         *po = 0 ;
00176         for (i=0 ; i<nr ; i++) {
00177         *po += (*pi) * cheb[i] ;
00178         pi++ ;  // R suivant
00179         }
00180         po++ ;  // Theta suivant
00181     }
00182     // On saute le sin(k*phi) : 
00183     pi += nr*nt ;
00184     po += nt ;
00185     }
00186 
00187     }   // fin du cas np > 1 
00188 
00189     // Menage
00190     delete [] cheb ;
00191     
00192 }
00193 
00197 
00198 void som_r_chebpim_p_symy
00199     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00200 
00201 // Variables diverses
00202 int i, j, k ;
00203 double* pi = ti ;       // pointeur courant sur l'entree
00204 double* po = trtp ;     // pointeur courant sur la sortie
00205     
00206     // Valeurs des polynomes de Chebyshev au point x demande
00207     double* cheb = new double [2*nr] ;
00208     cheb[0] = 1. ;
00209     cheb[1] = x ;
00210     for (i=2 ; i<2*nr ; i++) {
00211     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00212     }
00213     
00214     // Sommation pour le premier phi, k=0
00215     int m = 0;
00216     for (j=0 ; j<nt ; j++) {
00217     *po = 0 ;
00218     // Sommation sur r
00219     for (i=0 ; i<nr ; i++) {
00220         *po += (*pi) * cheb[2*i] ;
00221         pi++ ;  // R suivant
00222     }
00223     po++ ;      // Theta suivant
00224     }
00225     
00226     if (np > 1) {   
00227 
00228     // On saute le deuxieme phi (sin(0)), k=1
00229     pi += nr*nt ;
00230     po += nt ;
00231     
00232     // Sommation sur les phi suivants (pour k=2,...,np)
00233     //  en sautant les sinus (d'ou le k+=2)
00234     for (k=2 ; k<np+1 ; k+=2) {
00235     m = (k/2) % 2 ;         // parite: 0 <-> 1
00236     for (j=0 ; j<nt ; j++) {
00237         // Sommation sur r
00238         *po = 0 ;
00239         for (i=0 ; i<nr ; i++) {
00240         *po += (*pi) * cheb[2*i + m] ;
00241         pi++ ;  // R suivant
00242         }
00243         po++ ;  // Theta suivant
00244     }
00245     // On saute le sin(k*phi) : 
00246     pi += nr*nt ;
00247     po += nt ;
00248     }
00249     
00250     }   // fin du cas np > 1 
00251 
00252     // Menage
00253    delete [] cheb ;
00254     
00255 }
00256 
00260 
00261 void som_r_chebpim_i_symy
00262     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00263 
00264 // Variables diverses
00265 int i, j, k ;
00266 double* pi = ti ;       // pointeur courant sur l'entree
00267 double* po = trtp ;     // pointeur courant sur la sortie
00268     
00269     // Valeurs des polynomes de Chebyshev au point x demande
00270     double* cheb = new double [2*nr] ;
00271     cheb[0] = 1. ;
00272     cheb[1] = x ;
00273     for (i=2 ; i<2*nr ; i++) {
00274     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00275     }
00276     
00277     // Sommation pour le premier phi, k=0
00278     int m = 0;
00279     for (j=0 ; j<nt ; j++) {
00280     *po = 0 ;
00281     // Sommation sur r
00282     for (i=0 ; i<nr ; i++) {
00283         *po += (*pi) * cheb[2*i+1] ;
00284         pi++ ;  // R suivant
00285     }
00286     po++ ;      // Theta suivant
00287     }
00288     
00289     if (np > 1) {   
00290 
00291     // On saute le deuxieme phi (sin(0)), k=1
00292     pi += nr*nt ;
00293     po += nt ;
00294     
00295     // Sommation sur les phi suivants (pour k=2,...,np)
00296     //  en sautant les sinus (d'ou le k+=2)
00297     for (k=2 ; k<np+1 ; k+=2) {
00298     m = (k/2) % 2 ;         // parite: 0 <-> 1
00299     for (j=0 ; j<nt ; j++) {
00300         // Sommation sur r
00301         *po = 0 ;
00302         for (i=0 ; i<nr ; i++) {
00303         *po += (*pi) * cheb[2*i + 1 - m] ;
00304         pi++ ;  // R suivant
00305         }
00306         po++ ;  // Theta suivant
00307     }
00308     // On saute le sin(k*phi) : 
00309     pi += nr*nt ;
00310     po += nt ;
00311     }
00312     
00313     }   // fin du cas np > 1 
00314 
00315     // Menage
00316     delete [] cheb ;
00317     
00318 }
00319 
00320 
00321 
00322 //****************************************************************************
00323 //              Sommation en theta
00324 //****************************************************************************
00325 
00329 
00330 void som_tet_cossin_cp_symy
00331     (double* ti, const int nt, const int np,
00332     const double tet, double* to) {
00333     
00334 // Variables diverses
00335 int j, k ;
00336 double* pi = ti ;       // Pointeur courant sur l'entree
00337 double* po = to ;       // Pointeur courant sur la sortie
00338 
00339     // Initialisation des tables trigo
00340     double* cossin = new double [2*nt] ;
00341     for (j=0 ; j<2*nt ; j +=2) {
00342     cossin[j] = cos(j * tet) ;
00343     cossin[j+1] = sin((j+1) * tet) ;
00344     }
00345     
00346     // Sommation sur le premier phi -> cosinus, k=0
00347     *po = 0 ;
00348     for (j=0 ; j<nt ; j++) {
00349     *po += (*pi) * cossin[2*j] ;
00350     pi++ ;  // Theta suivant
00351     }
00352     po++ ;  // Phi suivant
00353     
00354     if (np > 1) {   
00355 
00356     // On saute le phi suivant (sin(0)), k=1
00357     pi += nt ;
00358     po++ ;
00359     
00360     // Sommation sur le reste des phi (pour k=2,...,np), suivant parite de m
00361     for (k=2 ; k<np+1 ; k+=2) {
00362     int m = (k/2) % 2 ;     // parite: 0 <-> 1
00363     (*po) = 0 ;
00364     for (j=0 ; j<nt ; j++) {
00365         *po += (*pi) * cossin[2*j + m] ;
00366         pi++ ;  // Theta suivant
00367     }
00368     po++ ;      // Phi suivant
00369 
00370     // On saute le sin(k*phi) : 
00371     pi += nt ;
00372     po++ ;
00373 
00374     }
00375     }   // fin du cas np > 1 
00376 
00377     // Menage
00378     delete [] cossin ;
00379 }
00380 
00384 
00385 void som_tet_cossin_ci_symy
00386     (double* ti, const int nt, const int np,
00387     const double tet, double* to) {
00388     
00389 // Variables diverses
00390 int j, k ;
00391 double* pi = ti ;       // Pointeur courant sur l'entree
00392 double* po = to ;       // Pointeur courant sur la sortie
00393 
00394     // Initialisation des tables trigo
00395     double* cossin = new double [2*nt] ;
00396     for (j=0 ; j<2*nt ; j +=2) {
00397     cossin[j] = cos((j+1) * tet) ;
00398     cossin[j+1] = sin(j * tet) ;
00399     }
00400     
00401     // Sommation sur le premier phi -> cosinus, k=0
00402     *po = 0 ;
00403     for (j=0 ; j<nt ; j++) {
00404     *po += (*pi) * cossin[2*j] ;
00405     pi++ ;  // Theta suivant
00406     }
00407     po++ ;  // Phi suivant
00408     
00409     if (np > 1) {   
00410 
00411     // On saute le phi suivant (sin(0)), k=1
00412     pi += nt ;
00413     po++ ;
00414     
00415     // Sommation sur le reste des phi (pour k=2,...,np), suivant parite de m
00416     for (k=2 ; k<np+1 ; k+=2) {
00417     int m = (k/2) % 2 ;     // parite: 0 <-> 1
00418     (*po) = 0 ;
00419     for (j=0 ; j<nt ; j++) {
00420         *po += (*pi) * cossin[2*j + m] ;
00421         pi++ ;  // Theta suivant
00422     }
00423     po++ ;      // Phi suivant
00424 
00425     // On saute le sin(k*phi) : 
00426     pi += nt ;
00427     po++ ;
00428 
00429     }
00430     }   // fin du cas np > 1 
00431 
00432     // Menage
00433     delete [] cossin ;
00434 }
00435 
00436 
00437 //****************************************************************************
00438 //              Sommation en phi
00439 //****************************************************************************
00440 
00441 void som_phi_cossin_symy
00442     (double* ti, const int np, const double phi, double* xo) {
00443     
00444     *xo = ti[0] ;   // premier element
00445 
00446     // Sommation sur les cosinus seulement
00447     for (int k=2 ; k<np-1 ; k +=2 ) {
00448     int m = k/2 ;
00449     *xo += ti[k] * cos(m * phi) ;
00450     }
00451     *xo += ti[np] * cos(np/2 * phi) ;
00452 }
00453 

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