cfpcossini.C

00001 /*
00002  *   Copyright (c) 1999-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 cfpcossini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cfpcossini.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $" ;
00024 
00025 /*
00026  * Transformation de Fourier sur le premier indice d'un tableau 3-D
00027  * Cas d'une fonction antisymetrique par la transformation phi --> phi + Pi
00028  *
00029  * Entree:
00030  * -------
00031  *   int* deg   : tableau du nombre effectif de degres de liberte dans chacune 
00032  *        des 3 dimensions: le nombre de points de collocation
00033  *        en phi est  np = deg[0] et doit etre de la forme
00034  *          np = 2^p 3^q 5^r 
00035  *   int* dim   : tableau du nombre d'elements de ff dans chacune des trois 
00036  *            dimensions.
00037  *        On doit avoir  dim[0] >= deg[0] + 2  = np + 2. 
00038  *
00039  * Entree/Sortie : 
00040  * ---------------
00041  *   double* cf : entree: tableau des valeurs de la fonction f aux np points de
00042  *                        de collocation 
00043  *              phi_k = Pi k/np      0 <= k <= np-1
00044  *            La convention de stokage utilisee est la suivante
00045  *  cf[ dim[2]*dim[1]*k + dim[2]*j + i ] = f(phi_k)    0 <= k <= np-1,
00046  *           les indices j et i correspondant respectivement
00047  *            a theta et a r. 
00048  *            L'espace memoire correspondant au
00049  *                        pointeur cf doit etre dim[0]*dim[1]*dim[2] et doit 
00050  *            etre alloue avant l'appel a la routine.   
00051  * 
00052  *        sortie: tableau des coefficients de la fonction suivant    
00053  *            la convention de stokage
00054  *      cf[ dim[2]*dim[1]*k + dim[2]*j + i ] = c_k      0<= k < np,
00055  *            ou les indices j et i correspondent respectivement
00056  *            a theta et a r et ou les c_k sont les coefficients 
00057  *            du developpement de f en series de Fourier:
00058  *
00059  *          f(phi) = c_0 cos(phi) + c_2 sin(phi)
00060  *              + som_{l=1}^{np/2-1} c_{2l+1} cos( (2l+1) phi )
00061  *               + c_{2l+2} sin( (2l+1) phi ),
00062  *
00063  *          En particulier: c_1 = 0 et c_{np+1} = 0
00064  */
00065 
00066 /*
00067  * $Id: cfpcossini.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $
00068  * $Log: cfpcossini.C,v $
00069  * Revision 1.1  2004/12/21 17:06:01  j_novak
00070  * Added all files for using fftw3.
00071  *
00072  * Revision 1.2  2002/10/16 14:36:43  j_novak
00073  * Reorganization of #include instructions of standard C++, in order to
00074  * use experimental version 3 of gcc.
00075  *
00076  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00077  * LORENE
00078  *
00079  * Revision 2.1  2000/09/08  15:55:04  eric
00080  * Premiere version testee.
00081  *
00082  * Revision 2.0  2000/09/07  15:15:06  eric
00083  * *** empty log message ***
00084  *
00085  *
00086  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cfpcossini.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $
00087  *
00088  */
00089 
00090 // Headers C
00091 #include <stdlib.h>
00092 
00093 // Headers Lorene
00094 #include "headcpp.h"
00095 #include "proto.h"
00096 
00097 //*****************************************************************************
00098 
00099 void cfpcossini(const int* deg, const int* dim, double* cf) {
00100 
00101     // Dimensions du tableau cf :
00102     int n1 = dim[0] ;
00103     int nt = dim[1] ;
00104     int nr = dim[2] ;
00105     int ntnr = nt * nr ; 
00106 
00107     // Nombres de degres de liberte en phi :    
00108     int np = deg[0] ;
00109     
00110     // Tests de dimension:
00111     if (np+2 > n1) {
00112     cout << "cfpcossini: np+2 > n1 : np+2 = " << np+2 << " ,  n1 = " 
00113     << n1 << endl ;
00114     abort() ;
00115     }
00116 
00117     // Tableau contenant les points de 0 a 2 Pi (et non seulement de 0 a Pi)
00118     int np2 = 2*np ; 
00119     int deg2[] = {np2, nt, nr} ; 
00120     int dim2[] = {np2+2, nt, nr} ;
00121     
00122     double* cf2 = new double[(np2+2)*nt*nr] ; 
00123     
00124     // Recopie des valeurs pour phi dans [0, Pi[ :
00125     for (int k=0; k<np; k++) {
00126     for (int ij = 0; ij <ntnr; ij++) {
00127         cf2[k*ntnr + ij] = cf[k*ntnr + ij] ; 
00128     }
00129     }
00130     
00131     // Valeurs pour phi dans [Pi, 2Pi[ obtenues par antisymetrie:
00132     int npntnr = np * ntnr ; 
00133     for (int k=0; k<np; k++) {
00134     for (int ij = 0; ij <ntnr; ij++) {
00135         cf2[npntnr + k*ntnr + ij] = - cf[k*ntnr + ij] ; 
00136     }
00137     }
00138     
00139     // Transformation de Fourier sur cf2 : 
00140     cfpcossin(deg2, dim2, cf2) ;
00141     
00142     // Recopie des coefficients dans cf :
00143     
00144     // Terme k=0   cos(phi)
00145     for (int ij = 0; ij <ntnr; ij++) {
00146         cf[ij] = cf2[2*ntnr + ij] ; 
00147     }
00148     
00149     // Terme k=1
00150     for (int ij = 0; ij <ntnr; ij++) {
00151         cf[ntnr + ij] = 0 ; 
00152     }
00153     
00154     // Terme k=2   sin(phi)
00155     for (int ij = 0; ij <ntnr; ij++) {
00156         cf[2*ntnr + ij] = cf2[3*ntnr + ij] ; 
00157     }
00158     
00159     // Termes suivants:
00160     for (int k=3; k<np; k+=2) {
00161     int k2 = 2*(k-1) + 2 ;
00162     // Terme en cosinus 
00163     for (int ij = 0; ij <ntnr; ij++) {
00164         cf[k*ntnr + ij] = cf2[k2*ntnr + ij] ; 
00165     }
00166     // Terme en sinus
00167     k2++ ; 
00168     int k1 = k+1 ; 
00169     for (int ij = 0; ij <ntnr; ij++) {
00170         cf[k1*ntnr + ij] = cf2[k2*ntnr + ij] ; 
00171     }   
00172     }
00173     
00174     // Terme k=np+1 
00175     for (int ij = 0; ij <ntnr; ij++) {
00176         cf[(np+1)*ntnr + ij] = 0 ; 
00177     }
00178     
00179     
00180     
00181     // Menage
00182     delete [] cf2 ;    
00183  
00184 }

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