LORENE
FFT991/cfpcossini.C
1/*
2 * Copyright (c) 1999-2001 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 * Transformation de Fourier sur le premier indice d'un tableau 3-D
27 * Cas d'une fonction antisymetrique par la transformation phi --> phi + Pi
28 *
29 * Entree:
30 * -------
31 * int* deg : tableau du nombre effectif de degres de liberte dans chacune
32 * des 3 dimensions: le nombre de points de collocation
33 * en phi est np = deg[0] et doit etre de la forme
34 * np = 2^p 3^q 5^r
35 * int* dim : tableau du nombre d'elements de ff dans chacune des trois
36 * dimensions.
37 * On doit avoir dim[0] >= deg[0] + 2 = np + 2.
38 *
39 * Entree/Sortie :
40 * ---------------
41 * double* cf : entree: tableau des valeurs de la fonction f aux np points de
42 * de collocation
43 * phi_k = Pi k/np 0 <= k <= np-1
44 * La convention de stokage utilisee est la suivante
45 * cf[ dim[2]*dim[1]*k + dim[2]*j + i ] = f(phi_k) 0 <= k <= np-1,
46 * les indices j et i correspondant respectivement
47 * a theta et a r.
48 * L'espace memoire correspondant au
49 * pointeur cf doit etre dim[0]*dim[1]*dim[2] et doit
50 * etre alloue avant l'appel a la routine.
51 *
52 * sortie: tableau des coefficients de la fonction suivant
53 * la convention de stokage
54 * cf[ dim[2]*dim[1]*k + dim[2]*j + i ] = c_k 0<= k < np,
55 * ou les indices j et i correspondent respectivement
56 * a theta et a r et ou les c_k sont les coefficients
57 * du developpement de f en series de Fourier:
58 *
59 * f(phi) = c_0 cos(phi) + c_2 sin(phi)
60 * + som_{l=1}^{np/2-1} c_{2l+1} cos( (2l+1) phi )
61 * + c_{2l+2} sin( (2l+1) phi ),
62 *
63 * En particulier: c_1 = 0 et c_{np+1} = 0
64 */
65
66/*
67 * $Id: cfpcossini.C,v 1.4 2016/12/05 16:18:03 j_novak Exp $
68 * $Log: cfpcossini.C,v $
69 * Revision 1.4 2016/12/05 16:18:03 j_novak
70 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
71 *
72 * Revision 1.3 2014/10/13 08:53:15 j_novak
73 * Lorene classes and functions now belong to the namespace Lorene.
74 *
75 * Revision 1.2 2014/10/06 15:18:44 j_novak
76 * Modified #include directives to use c++ syntax.
77 *
78 * Revision 1.1 2004/12/21 17:06:01 j_novak
79 * Added all files for using fftw3.
80 *
81 * Revision 1.2 2002/10/16 14:36:43 j_novak
82 * Reorganization of #include instructions of standard C++, in order to
83 * use experimental version 3 of gcc.
84 *
85 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
86 * LORENE
87 *
88 * Revision 2.1 2000/09/08 15:55:04 eric
89 * Premiere version testee.
90 *
91 * Revision 2.0 2000/09/07 15:15:06 eric
92 * *** empty log message ***
93 *
94 *
95 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cfpcossini.C,v 1.4 2016/12/05 16:18:03 j_novak Exp $
96 *
97 */
98
99// Headers C
100#include <cstdlib>
101
102// Headers Lorene
103#include "headcpp.h"
104#include "proto.h"
105
106namespace Lorene {
107//*****************************************************************************
108
109void cfpcossini(const int* deg, const int* dim, double* cf) {
110
111 // Dimensions du tableau cf :
112 int n1 = dim[0] ;
113 int nt = dim[1] ;
114 int nr = dim[2] ;
115 int ntnr = nt * nr ;
116
117 // Nombres de degres de liberte en phi :
118 int np = deg[0] ;
119
120 // Tests de dimension:
121 if (np+2 > n1) {
122 cout << "cfpcossini: np+2 > n1 : np+2 = " << np+2 << " , n1 = "
123 << n1 << endl ;
124 abort() ;
125 }
126
127 // Tableau contenant les points de 0 a 2 Pi (et non seulement de 0 a Pi)
128 int np2 = 2*np ;
129 int deg2[] = {np2, nt, nr} ;
130 int dim2[] = {np2+2, nt, nr} ;
131
132 double* cf2 = new double[(np2+2)*nt*nr] ;
133
134 // Recopie des valeurs pour phi dans [0, Pi[ :
135 for (int k=0; k<np; k++) {
136 for (int ij = 0; ij <ntnr; ij++) {
137 cf2[k*ntnr + ij] = cf[k*ntnr + ij] ;
138 }
139 }
140
141 // Valeurs pour phi dans [Pi, 2Pi[ obtenues par antisymetrie:
142 int npntnr = np * ntnr ;
143 for (int k=0; k<np; k++) {
144 for (int ij = 0; ij <ntnr; ij++) {
145 cf2[npntnr + k*ntnr + ij] = - cf[k*ntnr + ij] ;
146 }
147 }
148
149 // Transformation de Fourier sur cf2 :
150 cfpcossin(deg2, dim2, cf2) ;
151
152 // Recopie des coefficients dans cf :
153
154 // Terme k=0 cos(phi)
155 for (int ij = 0; ij <ntnr; ij++) {
156 cf[ij] = cf2[2*ntnr + ij] ;
157 }
158
159 // Terme k=1
160 for (int ij = 0; ij <ntnr; ij++) {
161 cf[ntnr + ij] = 0 ;
162 }
163
164 // Terme k=2 sin(phi)
165 for (int ij = 0; ij <ntnr; ij++) {
166 cf[2*ntnr + ij] = cf2[3*ntnr + ij] ;
167 }
168
169 // Termes suivants:
170 for (int k=3; k<np; k+=2) {
171 int k2 = 2*(k-1) + 2 ;
172 // Terme en cosinus
173 for (int ij = 0; ij <ntnr; ij++) {
174 cf[k*ntnr + ij] = cf2[k2*ntnr + ij] ;
175 }
176 // Terme en sinus
177 k2++ ;
178 int k1 = k+1 ;
179 for (int ij = 0; ij <ntnr; ij++) {
180 cf[k1*ntnr + ij] = cf2[k2*ntnr + ij] ;
181 }
182 }
183
184 // Terme k=np+1
185 for (int ij = 0; ij <ntnr; ij++) {
186 cf[(np+1)*ntnr + ij] = 0 ;
187 }
188
189
190
191 // Menage
192 delete [] cf2 ;
193
194}
195}
Lorene prototypes.
Definition app_hor.h:67