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 cipcossini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cipcossini.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $" ; 00024 00025 /* 00026 * Transformation de Fourier inverse sur le premier indice d'un tableau 3-D 00027 * Cas d'une fonction antisymetrique par la transformation phi --> phi + Pi 00028 * 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 3^q 5^r 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) = c_0 cos(phi) + c_2 sin(phi) 00058 * + som_{l=1}^{np/2-1} c_{2l+1} cos( (2l+1) phi ) 00059 * + c_{2l+2} sin( (2l+1) phi ), 00060 * 00061 * En particulier: c_1 = 0 et c_{np+1} = 0 00062 * 00063 * !!!! CE TABLEAU EST DETRUIT EN SORTIE !!!!! 00064 * 00065 * Sortie: 00066 * ------- 00067 * double* ff : tableau des valeurs de la fonction aux points de 00068 * de collocation 00069 * 00070 * phi_k = Pi k/np 0 <= k <= np-1 00071 * 00072 * suivant la convention de stokage: 00073 * ff[ dimf[2]*dimf[1]*k + dimf[2]*j + i ] = f(phi_k) 0 <= k <= np-1, 00074 * les indices j et i correspondant respectivement 00075 * a theta et a r. 00076 * L'espace memoire correspondant a ce 00077 * pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit 00078 * avoir ete alloue avant l'appel a la routine. 00079 */ 00080 00081 /* 00082 * $Id: cipcossini.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $ 00083 * $Log: cipcossini.C,v $ 00084 * Revision 1.1 2004/12/21 17:06:02 j_novak 00085 * Added all files for using fftw3. 00086 * 00087 * Revision 1.2 2002/10/16 14:36:53 j_novak 00088 * Reorganization of #include instructions of standard C++, in order to 00089 * use experimental version 3 of gcc. 00090 * 00091 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon 00092 * LORENE 00093 * 00094 * Revision 2.1 2000/09/08 15:55:21 eric 00095 * Premiere version testee. 00096 * 00097 * Revision 2.0 2000/09/07 15:15:17 eric 00098 * *** empty log message *** 00099 * 00100 * 00101 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cipcossini.C,v 1.1 2004/12/21 17:06:02 j_novak Exp $ 00102 * 00103 */ 00104 00105 // Headers C 00106 #include <stdlib.h> 00107 00108 #include "headcpp.h" 00109 00110 // Headers Lorene 00111 #include "proto.h" 00112 00113 //***************************************************************************** 00114 00115 void cipcossini(const int* deg, const int* dimc, const int* dimf, 00116 double* cf, double* ff) 00117 { 00118 00119 // Nombres de degres de liberte en phi: 00120 int np = deg[0] ; 00121 00122 // Tableaux pour echantillonnage sur [0,2 Pi[ : 00123 int np2 = 2*np ; 00124 00125 int deg2[] = {np2, deg[1], deg[2]} ; 00126 int dimc2[] = {np2+2, dimc[1], dimc[2]} ; 00127 int dimf2[] = {np2, dimf[1], dimf[2]} ; 00128 00129 double* cf2 = new double[ dimc2[0]*dimc2[1]*dimc2[2] ] ; 00130 double* ff2 = new double[ dimf2[0]*dimf2[1]*dimf2[2] ] ; 00131 00132 // Recopie des coefficients dans cf2 : 00133 int ntnrc = dimc[1] * dimc[2] ; 00134 00135 // Harmonique m=0 (cosinus et sinus) mise a zero 00136 for (int ij = 0; ij <2*ntnrc; ij++) { 00137 cf2[ij] = 0 ; 00138 } 00139 00140 // Harmonique m=1 (cosinus) 00141 for (int ij = 0; ij <ntnrc; ij++) { 00142 cf2[2*ntnrc + ij] = cf[ij] ; 00143 } 00144 00145 // Harmonique m=1 (sinus) 00146 for (int ij = 0; ij <ntnrc; ij++) { 00147 cf2[3*ntnrc + ij] = cf[2*ntnrc + ij] ; 00148 } 00149 00150 for (int k2=4; k2<np2; k2 +=4) { 00151 // Harmoniques paires : 00152 for (int ij = 0; ij <2*ntnrc; ij++) { 00153 cf2[k2*ntnrc + ij] = 0 ; 00154 } 00155 00156 // Harmoniques impaires (cosinus et sinus) 00157 int k = k2 / 2 + 1 ; 00158 for (int ij = 0; ij <2*ntnrc; ij++) { 00159 cf2[(k2+2)*ntnrc + ij] = cf[k*ntnrc + ij] ; 00160 } 00161 } 00162 00163 // Mise a zero des deux derniers coefficients: 00164 for (int ij = 0; ij <2*ntnrc; ij++) { 00165 cf2[np2*ntnrc + ij] = 0 ; 00166 } 00167 00168 // Transformation de Fourier inverse sur [0, 2 Pi] 00169 cipcossin(deg2, dimc2, dimf2, cf2, ff2) ; 00170 00171 // Recopie des valeurs de la fonction dans ff : 00172 int ntnrf = dimf[1] * dimf[2] ; 00173 for (int k=0; k<np; k++) { 00174 for (int ij = 0; ij <ntnrf; ij++) { 00175 ff[k*ntnrf + ij] = ff2[k*ntnrf + ij] ; 00176 } 00177 } 00178 00179 00180 // Menage 00181 delete [] cf2 ; 00182 delete [] ff2 ; 00183 00184 00185 }
1.4.6