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/FFTW3/cfpcossini.C,v 1.1 2004/12/21 17:06:02 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
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:02 j_novak Exp $
00068  * $Log: cfpcossini.C,v $
00069  * Revision 1.1  2004/12/21 17:06:02  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/FFTW3/cfpcossini.C,v 1.1 2004/12/21 17:06:02 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 void cfpcossini(const int* deg, const int* dim, double* cf) {
00099 
00100     // Dimensions du tableau cf :
00101     int n1 = dim[0] ;
00102     int nt = dim[1] ;
00103     int nr = dim[2] ;
00104     int ntnr = nt * nr ; 
00105 
00106     // Nombres de degres de liberte en phi :    
00107     int np = deg[0] ;
00108     
00109     // Tests de dimension:
00110     if (np+2 > n1) {
00111     cout << "cfpcossini: np+2 > n1 : np+2 = " << np+2 << " ,  n1 = " 
00112     << n1 << endl ;
00113     abort() ;
00114     }
00115 
00116     // Tableau contenant les points de 0 a 2 Pi (et non seulement de 0 a Pi)
00117     int np2 = 2*np ; 
00118     int deg2[] = {np2, nt, nr} ; 
00119     int dim2[] = {np2+2, nt, nr} ;
00120     
00121     double* cf2 = new double[(np2+2)*nt*nr] ; 
00122     
00123     // Recopie des valeurs pour phi dans [0, Pi[ :
00124     for (int k=0; k<np; k++) {
00125     for (int ij = 0; ij <ntnr; ij++) {
00126         cf2[k*ntnr + ij] = cf[k*ntnr + ij] ; 
00127     }
00128     }
00129     
00130     // Valeurs pour phi dans [Pi, 2Pi[ obtenues par antisymetrie:
00131     int npntnr = np * ntnr ; 
00132     for (int k=0; k<np; k++) {
00133     for (int ij = 0; ij <ntnr; ij++) {
00134         cf2[npntnr + k*ntnr + ij] = - cf[k*ntnr + ij] ; 
00135     }
00136     }
00137     
00138     // Transformation de Fourier sur cf2 : 
00139     cfpcossin(deg2, dim2, cf2) ;
00140     
00141     // Recopie des coefficients dans cf :
00142     
00143     // Terme k=0   cos(phi)
00144     for (int ij = 0; ij <ntnr; ij++) {
00145         cf[ij] = cf2[2*ntnr + ij] ; 
00146     }
00147     
00148     // Terme k=1
00149     for (int ij = 0; ij <ntnr; ij++) {
00150         cf[ntnr + ij] = 0 ; 
00151     }
00152     
00153     // Terme k=2   sin(phi)
00154     for (int ij = 0; ij <ntnr; ij++) {
00155         cf[2*ntnr + ij] = cf2[3*ntnr + ij] ; 
00156     }
00157     
00158     // Termes suivants:
00159     for (int k=3; k<np; k+=2) {
00160     int k2 = 2*(k-1) + 2 ;
00161     // Terme en cosinus 
00162     for (int ij = 0; ij <ntnr; ij++) {
00163         cf[k*ntnr + ij] = cf2[k2*ntnr + ij] ; 
00164     }
00165     // Terme en sinus
00166     k2++ ; 
00167     int k1 = k+1 ; 
00168     for (int ij = 0; ij <ntnr; ij++) {
00169         cf[k1*ntnr + ij] = cf2[k2*ntnr + ij] ; 
00170     }   
00171     }
00172     
00173     // Terme k=np+1 
00174     for (int ij = 0; ij <ntnr; ij++) {
00175         cf[(np+1)*ntnr + ij] = 0 ; 
00176     }
00177     
00178     
00179     
00180     // Menage
00181     delete [] cf2 ;    
00182  
00183 }

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