File: som_asymy.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (383 lines) | stat: -rw-r--r-- 9,888 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/*
 *   Copyright (c) 2000-2001 Eric Gourgoulhon
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


char som_asymy_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_asymy.C,v 1.3 2014/10/13 08:53:26 j_novak Exp $" ;

/*
 * Ensemble des routine pour la sommation directe en r, theta et phi dans
 * le cas symetrie equatoriale (plan z=0) + antisymetrie par rapport au plan y=0
 * 
 *   SYNOPSYS:
 *     double som_r_XX_asymy
 *	(double* ti, int nr, int nt, int np, double x, double* trtp)
 *
 *     x est l'argument du polynome de Chebychev: x in [0, 1] ou x in [-1, 1]
 *
 *
 *     double som_tet_XX_asymy
 *	(double* ti, int nt, int np, double tet, double* to)
 * 
 *     double som_phi_XX_asymy
 *	(double* ti, int np, double phi, double* xo)
 *
 *   ATTENTION: np est suppose etre le nombre de points (sans le +2)
 *		on suppose que trtp tient compte de ca.
 */

/*
 * $Id: som_asymy.C,v 1.3 2014/10/13 08:53:26 j_novak Exp $
 * $Log: som_asymy.C,v $
 * Revision 1.3  2014/10/13 08:53:26  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.2  2014/10/06 15:16:06  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
 * LORENE
 *
 * Revision 2.0  2000/03/06  10:27:45  eric
 * *** empty log message ***
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_asymy.C,v 1.3 2014/10/13 08:53:26 j_novak Exp $
 *
 */


// Headers C
#include <cmath>

namespace Lorene {

//****************************************************************************
//			    Sommation en r
//****************************************************************************

			//////////////////
			/// Cas R_CHEB ///
			//////////////////

void som_r_cheb_asymy(double* ti, const int nr, const int nt, const int np, 
		      const double x, double* trtp) {

// Variables diverses
int i, j, k ;
double* pi = ti ;	    // pointeur courant sur l'entree
double* po = trtp ;	    // pointeur courant sur la sortie
    
    // Valeurs des polynomes de Chebyshev au point x demande
    double* cheb = new double [nr] ;
    cheb[0] = 1. ;
    cheb[1] = x ;
    for (i=2; i<nr; i++) {
	cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;	    
    }
    
    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nr*nt ;
    po += 3*nt ;
        
    // Sommation sur les phi suivants (pour k=3,...,np)
    //  en sautant les cosinus (d'ou le k+=2)
    for (k=3 ; k<np+1 ; k+=2) {
	for (j=0 ; j<nt ; j++) {
	    // Sommation sur r
	    *po = 0 ;
	    for (i=0 ; i<nr ; i++) {
		*po += (*pi) * cheb[i] ;
		pi++ ;	// R suivant
	    }
	    po++ ;	// Theta suivant
	}
	// On saute le cos(m*phi) : 
	pi += nr*nt ;
	po += nt ;
    }
    
    // Menage
    delete [] cheb ;
}



			///////////////////
			/// Cas R_CHEBU ///
			///////////////////

void som_r_chebu_asymy(double* ti, const int nr, const int nt, const int np, 
		       const double x, double* trtp) {

// Variables diverses
int i, j, k ;
double* pi = ti ;	    // pointeur courant sur l'entree
double* po = trtp ;	    // pointeur courant sur la sortie
    
    // Valeurs des polynomes de Chebyshev au point x demande
    double* cheb = new double [nr] ;
    cheb[0] = 1. ;
    cheb[1] = x ;
    for (i=2; i<nr; i++) {
	cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;	    
    }
    
    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nr*nt ;
    po += 3*nt ;
    
    // Sommation sur les phi suivants (pour k=3,...,np)
    //  en sautant les cosinus (d'ou le k+=2)
    for (k=3 ; k<np+1 ; k+=2) {
	for (j=0 ; j<nt ; j++) {
	    // Sommation sur r
	    *po = 0 ;
	    for (i=0 ; i<nr ; i++) {
		*po += (*pi) * cheb[i] ;
		pi++ ;	// R suivant
	    }
	    po++ ;	// Theta suivant
	}
	// On saute le cos(m*phi) : 
	pi += nr*nt ;
	po += nt ;
    }

    // Menage
    delete [] cheb ;
    
}



			///////////////////////
			/// Cas R_CHEBPIM_P ///
			///////////////////////

void som_r_chebpim_p_asymy(double* ti, const int nr, const int nt, 
			   const int np, const double x, double* trtp) {

// Variables diverses
int i, j, k ;
double* pi = ti ;	    // pointeur courant sur l'entree
double* po = trtp ;	    // pointeur courant sur la sortie
    
    // Valeurs des polynomes de Chebyshev au point x demande
    double* cheb = new double [2*nr] ;
    cheb[0] = 1. ;
    cheb[1] = x ;
    for (i=2 ; i<2*nr ; i++) {
	cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;	    
    }
    

    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nr*nt ;
    po += 3*nt ;
    
    // Sommation sur les phi suivants (pour k=3,...,np)
    //  en sautant les cosinus (d'ou le k+=2)
    for (k=3 ; k<np+1 ; k+=2) {
	int m = (k/2) % 2 ;		    // parite: 0 <-> 1
	for (j=0 ; j<nt ; j++) {
	    // Sommation sur r
	    *po = 0 ;
	    for (i=0 ; i<nr ; i++) {
		*po += (*pi) * cheb[2*i + m] ;
		pi++ ;	// R suivant
	    }
	    po++ ;	// Theta suivant
	}
	// On saute le cos(m*phi) : 
	pi += nr*nt ;
	po += nt ;
    }
    

    // Menage
   delete [] cheb ;
    
}

			///////////////////////
			/// Cas R_CHEBPIM_I ///
			///////////////////////

void som_r_chebpim_i_asymy(double* ti, const int nr, const int nt, 
			   const int np, const double x, double* trtp) {

// Variables diverses
int i, j, k ;
double* pi = ti ;	    // pointeur courant sur l'entree
double* po = trtp ;	    // pointeur courant sur la sortie
    
    // Valeurs des polynomes de Chebyshev au point x demande
    double* cheb = new double [2*nr] ;
    cheb[0] = 1. ;
    cheb[1] = x ;
    for (i=2 ; i<2*nr ; i++) {
	cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;	    
    }
    
    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nr*nt ;
    po += 3*nt ;
        
    // Sommation sur les phi suivants (pour k=3,...,np)
    //  en sautant les cosinus (d'ou le k+=2)
    for (k=3 ; k<np+1 ; k+=2) {
	int m = (k/2) % 2 ;		    // parite: 0 <-> 1
	for (j=0 ; j<nt ; j++) {
	    // Sommation sur r
	    *po = 0 ;
	    for (i=0 ; i<nr ; i++) {
		*po += (*pi) * cheb[2*i + 1 - m] ;
		pi++ ;	// R suivant
	    }
	    po++ ;	// Theta suivant
	}
	// On saute le cos(m*phi) : 
	pi += nr*nt ;
	po += nt ;
    }
    
    // Menage
    delete [] cheb ;
    
}



//****************************************************************************
//			    Sommation en theta
//****************************************************************************

			///////////////////////
			/// Cas T_COSSIN_CP ///
			///////////////////////

void som_tet_cossin_cp_asymy(double* ti, const int nt, const int np,
			     const double tet, double* to) {
    
// Variables diverses
int j, k ;
double* pi = ti ;	    // Pointeur courant sur l'entree
double* po = to ;	    // Pointeur courant sur la sortie

    // Initialisation des tables trigo
    double* cossin = new double [2*nt] ;
    for (j=0 ; j<2*nt ; j +=2) {
	cossin[j] = cos(j * tet) ;
	cossin[j+1] = sin((j+1) * tet) ;
    }
    
    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nt ;
    po += 3 ;

    // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
    for (k=3 ; k<np+1 ; k+=2) {
	int m = (k/2) % 2 ;	    // parite: 0 <-> 1
	(*po) = 0 ;
	for (j=0 ; j<nt ; j++) {
	    *po += (*pi) * cossin[2*j + m] ;
	    pi++ ;  // Theta suivant
	}
	po++ ;	    // Phi suivant

	// On saute le cos(m*phi) : 
	pi += nt ;
	po++ ;

    }

    // Menage
    delete [] cossin ;
}

			///////////////////////
			/// Cas T_COSSIN_CI ///
			///////////////////////

void som_tet_cossin_ci_asymy(double* ti, const int nt, const int np,
			     const double tet, double* to) {
    
// Variables diverses
int j, k ;
double* pi = ti ;	    // Pointeur courant sur l'entree
double* po = to ;	    // Pointeur courant sur la sortie

    // Initialisation des tables trigo
    double* cossin = new double [2*nt] ;
    for (j=0 ; j<2*nt ; j +=2) {
	cossin[j] = cos((j+1) * tet) ;
	cossin[j+1] = sin(j * tet) ;
    }
    
    // On saute les 3 premiers coef. en phi, qui sont respectivemment
    //  cos(0 phi), sin(0 phi) et cos(phi)
    pi += 3*nt ;
    po += 3 ;

    // Sommation sur le reste des phi (pour k=3,...,np), suivant parite de m
    for (k=3 ; k<np+1 ; k+=2) {
	int m = (k/2) % 2 ;	    // parite: 0 <-> 1
	(*po) = 0 ;
	for (j=0 ; j<nt ; j++) {
	    *po += (*pi) * cossin[2*j + m] ;
	    pi++ ;  // Theta suivant
	}
	po++ ;	    // Phi suivant

	// On saute le cos(m*phi) : 
	pi += nt ;
	po++ ;

    }

    // Menage
    delete [] cossin ;
}


//****************************************************************************
//			    Sommation en phi
//****************************************************************************

void som_phi_cossin_asymy(double* ti, const int np, const double phi, 
			  double* xo) {
    
    *xo = 0 ; 

    // Sommation sur les sinus seulement
    for (int k=3 ; k<np+1 ; k +=2 ) {
	int m = k/2 ;
	*xo += ti[k] * sin(m * phi) ;
    }

}

}