00001 /* 00002 * Copyright (c) 1999-2002 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 cipcossin_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cipcossin.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $" ; 00024 00025 00026 /* 00027 * Transformation de Fourier inverse sur le premier indice d'un tableau 3-D 00028 * par le biais de la routine FFT Fortran FFT991 00029 * 00030 * Entree: 00031 * ------- 00032 * int* deg : tableau du nombre effectif de degres de liberte dans chacune 00033 * des 3 dimensions: le nombre de points de collocation 00034 * en phi est np = deg[0] et doit etre de la forme 00035 * np = 2*p 00036 * int* dimc : tableau du nombre d'elements dans chacune des trois 00037 * dimensions du tableau cf 00038 * On doit avoir dimc[0] >= deg[0] + 2 = np + 2. 00039 * 00040 * int* dimf : tableau du nombre d'elements dans chacune des trois 00041 * dimensions du tableau ff 00042 * On doit avoir dimf[0] >= deg[0] = np . 00043 * 00044 * 00045 * Entree / sortie : 00046 * ----------------- 00047 * double* cf : entree: tableau des coefficients de la fonction f; 00048 * L'espace memoire correspondant a ce 00049 * pointeur doit etre dimc[0]*dimc[1]*dimc[2] et doit 00050 * avoir ete alloue avant l'appel a la routine. 00051 * La convention de stokage est la suivante: 00052 * cf[ dimc[2]*dimc[1]*k + dimc[2]*j + i ] = c_k 0<= k <= np, 00053 * ou les indices j et i correspondent respectivement 00054 * a theta et a r et ou les c_k sont les coefficients 00055 * du developpement de f en series de Fourier: 00056 * 00057 * f(phi) = som_{l=0}^{np/2} c_{2l} cos( 2 pi/T l phi ) 00058 * + c_{2l+1} sin( 2 pi/T l phi ), 00059 * 00060 * ou T est la periode de f. 00061 * En particulier cf[1] = 0. 00062 * De plus, cf[np+1] n'est pas egal a c_{np+1} 00063 * mais a zero. 00064 * !!!! CE TABLEAU EST DETRUIT EN SORTIE !!!!! 00065 * 00066 * Sortie: 00067 * ------- 00068 * double* ff : tableau des valeurs de la fonction aux points de 00069 * de collocation 00070 * 00071 * phi_k = T k/np 0 <= k <= np-1 00072 * 00073 * suivant la convention de stokage: 00074 * ff[ dimf[2]*dimf[1]*k + dimf[2]*j + i ] = f(phi_k) 0 <= k <= np-1, 00075 * les indices j et i correspondant respectivement 00076 * a theta et a r. 00077 * L'espace memoire correspondant a ce 00078 * pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit 00079 * avoir ete alloue avant l'appel a la routine. 00080 */ 00081 00082 /* 00083 * $Id: cipcossin.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $ 00084 * $Log: cipcossin.C,v $ 00085 * Revision 1.1 2004/12/21 17:06:02 j_novak 00086 * Added all files for using fftw3. 00087 * 00088 * Revision 1.4 2003/01/31 10:31:23 e_gourgoulhon 00089 * Suppressed the directive #include <malloc.h> for malloc is defined 00090 * in <stdlib.h> 00091 * 00092 * Revision 1.3 2002/10/16 14:36:53 j_novak 00093 * Reorganization of #include instructions of standard C++, in order to 00094 * use experimental version 3 of gcc. 00095 * 00096 * Revision 1.2 2002/09/09 13:00:40 e_gourgoulhon 00097 * Modification of declaration of Fortran 77 prototypes for 00098 * a better portability (in particular on IBM AIX systems): 00099 * All Fortran subroutine names are now written F77_* and are 00100 * defined in the new file C++/Include/proto_f77.h. 00101 * 00102 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon 00103 * LORENE 00104 * 00105 * Revision 2.0 1999/02/22 15:43:58 hyc 00106 * *** empty log message *** 00107 * 00108 * 00109 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cipcossin.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $ 00110 * 00111 */ 00112 00113 00114 // headers du C 00115 #include <stdlib.h> 00116 #include <fftw3.h> 00117 00118 //Lorene prototypes 00119 #include "tbl.h" 00120 00121 // Prototypage des sous-routines utilisees: 00122 fftw_plan back_fft(int, Tbl*&) ; 00123 //***************************************************************************** 00124 00125 void cipcossin(const int* deg, const int* dimc, const int* dimf, 00126 double* cf, double* ff) 00127 { 00128 00129 // Dimensions des tableaux ff et cf : 00130 int n1f = dimf[0] ; 00131 int n2f = dimf[1] ; 00132 int n3f = dimf[2] ; 00133 int n1c = dimc[0] ; 00134 int n2c = dimc[1] ; 00135 int n3c = dimc[2] ; 00136 00137 // Nombres de degres de liberte en phi: 00138 int np = deg[0] ; 00139 00140 // Tests de dimension: 00141 if (np+2 > n1c) { 00142 cout << "cipcossin: np+2 > n1c : np = " << np << " , n1c = " 00143 << n1c << endl ; 00144 abort () ; 00145 exit(-1) ; 00146 } 00147 if (np > n1f) { 00148 cout << "cipcossin: np > n1f : np = " << np << " , n1f = " 00149 << n1f << endl ; 00150 abort () ; 00151 exit(-1) ; 00152 } 00153 if (n3f > n3c) { 00154 cout << "cipcossin: n3f > n3c : n3f = " << n3f << " , n3c = " 00155 << n3c << endl ; 00156 abort () ; 00157 exit(-1) ; 00158 } 00159 if (n2f > n2c) { 00160 cout << "cipcossin: n2f > n2c : n2f = " << n2f << " , n2c = " 00161 << n2c << endl ; 00162 abort () ; 00163 exit(-1) ; 00164 } 00165 00166 // Recherche des tables 00167 Tbl* pg = 0x0 ; 00168 fftw_plan p = back_fft(np, pg) ; 00169 Tbl& g = *pg ; 00170 int index ; 00171 int n2n3c = n2c*n3c ; 00172 int n2n3f = n2f*n3f ; 00173 00174 // boucle sur r et theta 00175 00176 for (int j=0; j<n2c; j++) { 00177 for (int k=0; k<n3c; k++) { 00178 index = n3c * j + k ; 00179 double* debut = cf + index ; 00180 g.set(0) = *debut ; 00181 debut += 2*n2n3c ; 00182 for (int i=1; i<np/2; i++) { 00183 int isym = np - i ; 00184 g.set(i) = 0.5 * (*debut) ; debut += n2n3c ; 00185 g.set(isym) = -0.5 * (*debut) ; debut += n2n3c ; 00186 } 00187 g.set(np/2) = *debut ; 00188 00189 // FFT inverse 00190 00191 fftw_execute(p) ; 00192 00193 // On range dans ff 00194 if ((j<n2f) && (k<n3f)) { 00195 debut = ff + n3f * j + k ; 00196 for (int i=0; i<np; i++) { 00197 *debut = g(i) ; 00198 debut += n2n3f ; 00199 } 00200 } 00201 } // fin de la boucle sur r 00202 } // fin de la boucle sur theta 00203 00204 }
1.4.6