LORENE
FFTW3/cipcossin.C
1/*
2 * Copyright (c) 1999-2002 Eric Gourgoulhon
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * LORENE is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with LORENE; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22
23
24
25
26/*
27 * Transformation de Fourier inverse sur le premier indice d'un tableau 3-D
28 * par le biais de la routine FFT Fortran FFT991
29 *
30 * Entree:
31 * -------
32 * int* deg : tableau du nombre effectif de degres de liberte dans chacune
33 * des 3 dimensions: le nombre de points de collocation
34 * en phi est np = deg[0] et doit etre de la forme
35 * np = 2*p
36 * int* dimc : tableau du nombre d'elements dans chacune des trois
37 * dimensions du tableau cf
38 * On doit avoir dimc[0] >= deg[0] + 2 = np + 2.
39 *
40 * int* dimf : tableau du nombre d'elements dans chacune des trois
41 * dimensions du tableau ff
42 * On doit avoir dimf[0] >= deg[0] = np .
43 *
44 *
45 * Entree / sortie :
46 * -----------------
47 * double* cf : entree: tableau des coefficients de la fonction f;
48 * L'espace memoire correspondant a ce
49 * pointeur doit etre dimc[0]*dimc[1]*dimc[2] et doit
50 * avoir ete alloue avant l'appel a la routine.
51 * La convention de stokage est la suivante:
52 * cf[ dimc[2]*dimc[1]*k + dimc[2]*j + i ] = c_k 0<= k <= np,
53 * ou les indices j et i correspondent respectivement
54 * a theta et a r et ou les c_k sont les coefficients
55 * du developpement de f en series de Fourier:
56 *
57 * f(phi) = som_{l=0}^{np/2} c_{2l} cos( 2 pi/T l phi )
58 * + c_{2l+1} sin( 2 pi/T l phi ),
59 *
60 * ou T est la periode de f.
61 * En particulier cf[1] = 0.
62 * De plus, cf[np+1] n'est pas egal a c_{np+1}
63 * mais a zero.
64 * !!!! CE TABLEAU EST DETRUIT EN SORTIE !!!!!
65 *
66 * Sortie:
67 * -------
68 * double* ff : tableau des valeurs de la fonction aux points de
69 * de collocation
70 *
71 * phi_k = T k/np 0 <= k <= np-1
72 *
73 * suivant la convention de stokage:
74 * ff[ dimf[2]*dimf[1]*k + dimf[2]*j + i ] = f(phi_k) 0 <= k <= np-1,
75 * les indices j et i correspondant respectivement
76 * a theta et a r.
77 * L'espace memoire correspondant a ce
78 * pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit
79 * avoir ete alloue avant l'appel a la routine.
80 */
81
82/*
83 * $Id: cipcossin.C,v 1.4 2016/12/05 16:18:05 j_novak Exp $
84 * $Log: cipcossin.C,v $
85 * Revision 1.4 2016/12/05 16:18:05 j_novak
86 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
87 *
88 * Revision 1.3 2014/10/13 08:53:19 j_novak
89 * Lorene classes and functions now belong to the namespace Lorene.
90 *
91 * Revision 1.2 2014/10/06 15:18:49 j_novak
92 * Modified #include directives to use c++ syntax.
93 *
94 * Revision 1.1 2004/12/21 17:06:02 j_novak
95 * Added all files for using fftw3.
96 *
97 * Revision 1.4 2003/01/31 10:31:23 e_gourgoulhon
98 * Suppressed the directive #include <malloc.h> for malloc is defined
99 * in <stdlib.h>
100 *
101 * Revision 1.3 2002/10/16 14:36:53 j_novak
102 * Reorganization of #include instructions of standard C++, in order to
103 * use experimental version 3 of gcc.
104 *
105 * Revision 1.2 2002/09/09 13:00:40 e_gourgoulhon
106 * Modification of declaration of Fortran 77 prototypes for
107 * a better portability (in particular on IBM AIX systems):
108 * All Fortran subroutine names are now written F77_* and are
109 * defined in the new file C++/Include/proto_f77.h.
110 *
111 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
112 * LORENE
113 *
114 * Revision 2.0 1999/02/22 15:43:58 hyc
115 * *** empty log message ***
116 *
117 *
118 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFTW3/cipcossin.C,v 1.4 2016/12/05 16:18:05 j_novak Exp $
119 *
120 */
121
122
123// headers du C
124#include <cstdlib>
125#include <fftw3.h>
126
127//Lorene prototypes
128#include "tbl.h"
129
130// Prototypage des sous-routines utilisees:
131namespace Lorene {
132fftw_plan back_fft(int, Tbl*&) ;
133//*****************************************************************************
134
135void cipcossin(const int* deg, const int* dimc, const int* dimf,
136 double* cf, double* ff)
137{
138
139// Dimensions des tableaux ff et cf :
140 int n1f = dimf[0] ;
141 int n2f = dimf[1] ;
142 int n3f = dimf[2] ;
143 int n1c = dimc[0] ;
144 int n2c = dimc[1] ;
145 int n3c = dimc[2] ;
146
147// Nombres de degres de liberte en phi:
148 int np = deg[0] ;
149
150// Tests de dimension:
151 if (np+2 > n1c) {
152 cout << "cipcossin: np+2 > n1c : np = " << np << " , n1c = "
153 << n1c << endl ;
154 abort () ;
155 exit(-1) ;
156 }
157 if (np > n1f) {
158 cout << "cipcossin: np > n1f : np = " << np << " , n1f = "
159 << n1f << endl ;
160 abort () ;
161 exit(-1) ;
162 }
163 if (n3f > n3c) {
164 cout << "cipcossin: n3f > n3c : n3f = " << n3f << " , n3c = "
165 << n3c << endl ;
166 abort () ;
167 exit(-1) ;
168 }
169 if (n2f > n2c) {
170 cout << "cipcossin: n2f > n2c : n2f = " << n2f << " , n2c = "
171 << n2c << endl ;
172 abort () ;
173 exit(-1) ;
174 }
175
176 // Recherche des tables
177 Tbl* pg = 0x0 ;
178 fftw_plan p = back_fft(np, pg) ;
179 Tbl& g = *pg ;
180 int index ;
181 int n2n3c = n2c*n3c ;
182 int n2n3f = n2f*n3f ;
183
184// boucle sur r et theta
185
186 for (int j=0; j<n2c; j++) {
187 for (int k=0; k<n3c; k++) {
188 index = n3c * j + k ;
189 double* debut = cf + index ;
190 g.set(0) = *debut ;
191 debut += 2*n2n3c ;
192 for (int i=1; i<np/2; i++) {
193 int isym = np - i ;
194 g.set(i) = 0.5 * (*debut) ; debut += n2n3c ;
195 g.set(isym) = -0.5 * (*debut) ; debut += n2n3c ;
196 }
197 g.set(np/2) = *debut ;
198
199// FFT inverse
200
201 fftw_execute(p) ;
202
203// On range dans ff
204 if ((j<n2f) && (k<n3f)) {
205 debut = ff + n3f * j + k ;
206 for (int i=0; i<np; i++) {
207 *debut = g(i) ;
208 debut += n2n3f ;
209 }
210 }
211 } // fin de la boucle sur r
212 } // fin de la boucle sur theta
213
214}
215}
Basic array class.
Definition tbl.h:161
Lorene prototypes.
Definition app_hor.h:67