LORENE
FFT991/cipcossini.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 inverse sur le premier indice d'un tableau 3-D
27  * Cas d'une fonction antisymetrique par la transformation phi --> phi + Pi
28  *
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 3^q 5^r
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) = c_0 cos(phi) + c_2 sin(phi)
58  * + som_{l=1}^{np/2-1} c_{2l+1} cos( (2l+1) phi )
59  * + c_{2l+2} sin( (2l+1) phi ),
60  *
61  * En particulier: c_1 = 0 et c_{np+1} = 0
62  *
63  * !!!! CE TABLEAU EST DETRUIT EN SORTIE !!!!!
64  *
65  * Sortie:
66  * -------
67  * double* ff : tableau des valeurs de la fonction aux points de
68  * de collocation
69  *
70  * phi_k = Pi k/np 0 <= k <= np-1
71  *
72  * suivant la convention de stokage:
73  * ff[ dimf[2]*dimf[1]*k + dimf[2]*j + i ] = f(phi_k) 0 <= k <= np-1,
74  * les indices j et i correspondant respectivement
75  * a theta et a r.
76  * L'espace memoire correspondant a ce
77  * pointeur doit etre dimf[0]*dimf[1]*dimf[2] et doit
78  * avoir ete alloue avant l'appel a la routine.
79  */
80 
81 /*
82  * $Id: cipcossini.C,v 1.4 2016/12/05 16:18:03 j_novak Exp $
83  * $Log: cipcossini.C,v $
84  * Revision 1.4 2016/12/05 16:18:03 j_novak
85  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
86  *
87  * Revision 1.3 2014/10/13 08:53:16 j_novak
88  * Lorene classes and functions now belong to the namespace Lorene.
89  *
90  * Revision 1.2 2014/10/06 15:18:45 j_novak
91  * Modified #include directives to use c++ syntax.
92  *
93  * Revision 1.1 2004/12/21 17:06:01 j_novak
94  * Added all files for using fftw3.
95  *
96  * Revision 1.2 2002/10/16 14:36:53 j_novak
97  * Reorganization of #include instructions of standard C++, in order to
98  * use experimental version 3 of gcc.
99  *
100  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
101  * LORENE
102  *
103  * Revision 2.1 2000/09/08 15:55:21 eric
104  * Premiere version testee.
105  *
106  * Revision 2.0 2000/09/07 15:15:17 eric
107  * *** empty log message ***
108  *
109  *
110  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/cipcossini.C,v 1.4 2016/12/05 16:18:03 j_novak Exp $
111  *
112  */
113 
114 // Headers C
115 #include <cstdlib>
116 
117 #include "headcpp.h"
118 
119 // Headers Lorene
120 #include "proto.h"
121 
122 namespace Lorene {
123 //*****************************************************************************
124 
125 void cipcossini(const int* deg, const int* dimc, const int* dimf,
126  double* cf, double* ff)
127 {
128 
129  // Nombres de degres de liberte en phi:
130  int np = deg[0] ;
131 
132  // Tableaux pour echantillonnage sur [0,2 Pi[ :
133  int np2 = 2*np ;
134 
135  int deg2[] = {np2, deg[1], deg[2]} ;
136  int dimc2[] = {np2+2, dimc[1], dimc[2]} ;
137  int dimf2[] = {np2, dimf[1], dimf[2]} ;
138 
139  double* cf2 = new double[ dimc2[0]*dimc2[1]*dimc2[2] ] ;
140  double* ff2 = new double[ dimf2[0]*dimf2[1]*dimf2[2] ] ;
141 
142  // Recopie des coefficients dans cf2 :
143  int ntnrc = dimc[1] * dimc[2] ;
144 
145  // Harmonique m=0 (cosinus et sinus) mise a zero
146  for (int ij = 0; ij <2*ntnrc; ij++) {
147  cf2[ij] = 0 ;
148  }
149 
150  // Harmonique m=1 (cosinus)
151  for (int ij = 0; ij <ntnrc; ij++) {
152  cf2[2*ntnrc + ij] = cf[ij] ;
153  }
154 
155  // Harmonique m=1 (sinus)
156  for (int ij = 0; ij <ntnrc; ij++) {
157  cf2[3*ntnrc + ij] = cf[2*ntnrc + ij] ;
158  }
159 
160  for (int k2=4; k2<np2; k2 +=4) {
161  // Harmoniques paires :
162  for (int ij = 0; ij <2*ntnrc; ij++) {
163  cf2[k2*ntnrc + ij] = 0 ;
164  }
165 
166  // Harmoniques impaires (cosinus et sinus)
167  int k = k2 / 2 + 1 ;
168  for (int ij = 0; ij <2*ntnrc; ij++) {
169  cf2[(k2+2)*ntnrc + ij] = cf[k*ntnrc + ij] ;
170  }
171  }
172 
173  // Mise a zero des deux derniers coefficients:
174  for (int ij = 0; ij <2*ntnrc; ij++) {
175  cf2[np2*ntnrc + ij] = 0 ;
176  }
177 
178  // Transformation de Fourier inverse sur [0, 2 Pi]
179  cipcossin(deg2, dimc2, dimf2, cf2, ff2) ;
180 
181  // Recopie des valeurs de la fonction dans ff :
182  int ntnrf = dimf[1] * dimf[2] ;
183  for (int k=0; k<np; k++) {
184  for (int ij = 0; ij <ntnrf; ij++) {
185  ff[k*ntnrf + ij] = ff2[k*ntnrf + ij] ;
186  }
187  }
188 
189 
190  // Menage
191  delete [] cf2 ;
192  delete [] ff2 ;
193 
194 
195 }
196 }
Lorene prototypes.
Definition: app_hor.h:67