LORENE
op_mult_cp.C
1/*
2 * Sets of routines for multiplication by cos(phi)
3 * (internal use)
4 *
5 * void _mult_cp_XXXX(Tbl * t, int & b)
6 * t pointer on the Tbl containing the spectral coefficients
7 * b spectral base
8 *
9 */
10
11/*
12 * Copyright (c) 2000-2001 Eric Gourgoulhon
13 *
14 * This file is part of LORENE.
15 *
16 * LORENE is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * LORENE is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with LORENE; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 */
31
32
33
34
35/*
36 * $Id: op_mult_cp.C,v 1.6 2016/12/05 16:18:08 j_novak Exp $
37 * $Log: op_mult_cp.C,v $
38 * Revision 1.6 2016/12/05 16:18:08 j_novak
39 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
40 *
41 * Revision 1.5 2014/10/13 08:53:25 j_novak
42 * Lorene classes and functions now belong to the namespace Lorene.
43 *
44 * Revision 1.4 2007/12/14 10:19:33 jl_cornou
45 * *** empty log message ***
46 *
47 * Revision 1.3 2007/10/05 12:37:20 j_novak
48 * Corrected a few errors in the theta-nonsymmetric case (bases T_COSSIN_C and
49 * T_COSSIN_S).
50 *
51 * Revision 1.2 2004/11/23 15:16:01 m_forot
52 *
53 * Added the bases for the cases without any equatorial symmetry
54 * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
55 *
56 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
57 * LORENE
58 *
59 * Revision 2.4 2000/11/14 15:11:45 eric
60 * Traitement du cas np=1
61 *
62 * Revision 2.3 2000/09/18 10:14:42 eric
63 * Ajout des bases P_COSSIN_P et P_COSSIN_I
64 *
65 * Revision 2.2 2000/09/12 13:36:11 eric
66 * Met les bonnes bases meme dans le cas ETATZERO
67 *
68 * Revision 2.1 2000/09/12 08:28:47 eric
69 * Traitement des bases qui dependent de la parite de m
70 *
71 * Revision 2.0 2000/09/11 13:53:32 eric
72 * *** empty log message ***
73 *
74 *
75 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_mult_cp.C,v 1.6 2016/12/05 16:18:08 j_novak Exp $
76 *
77 */
78
79// Headers Lorene
80#include "tbl.h"
81
82 //-----------------------------------
83 // Routine for unknown cases
84 //-----------------------------------
85
86namespace Lorene {
87void _mult_cp_pas_prevu(Tbl* , int& base) {
88 cout << "mult_cp() is not not implemented for the basis " << base << " !"
89 << endl ;
90 abort() ;
91}
92
93 //----------------
94 // basis P_COSSIN
95 //----------------
96
97void _mult_cp_p_cossin(Tbl* tb, int& base) {
98
99 assert(tb->get_etat() != ETATNONDEF) ; // Protection
100
101 // The spectral bases in r and theta which depend on the parity of m
102 // are changed
103 // -----------------------------------------------------------------
104
105 int base_r = base & MSQ_R ;
106 int base_t = base & MSQ_T ;
107 const int base_p = base & MSQ_P ;
108
109 switch (base_r) {
110
111 case R_CHEBPIM_P : {
112 base_r = R_CHEBPIM_I ;
113 break ;
114 }
115
116 case R_CHEBPIM_I : {
117 base_r = R_CHEBPIM_P ;
118 break ;
119 }
120 case R_CHEBPI_P : {
121 break ;
122 }
123
124 case R_CHEBPI_I : {
125 break ;
126 }
127
128
129 case R_CHEB : {
130 break ;
131 }
132
133 case R_JACO02 : {
134 break ;
135 }
136
137 case R_CHEBU : {
138 break ;
139 }
140
141 default : {
142 cout << "_mult_cp_p_cossin : unknown basis in r !" << endl ;
143 cout << " base_r = " << hex << base_r << endl ;
144 abort() ;
145 }
146 }
147
148 switch (base_t) {
149
150 case T_COSSIN_CP : {
151 base_t = T_COSSIN_SI ;
152 break ;
153 }
154
155 case T_COSSIN_SI : {
156 base_t = T_COSSIN_CP ;
157 break ;
158 }
159
160 case T_COSSIN_CI : {
161 base_t = T_COSSIN_SP ;
162 break ;
163 }
164
165 case T_COSSIN_SP : {
166 base_t = T_COSSIN_CI ;
167 break ;
168 }
169
170 case T_COSSIN_S : {
171 base_t = T_COSSIN_C ;
172 break ;
173 }
174 case T_COSSIN_C : {
175 base_t = T_COSSIN_S ;
176 break ;
177 }
178
179 default : {
180 cout << "_mult_cp_p_cossin : unknown basis in theta !" << endl ;
181 cout << " base_t = " << hex << base_t << endl ;
182 abort() ;
183 }
184 }
185
186 base = base_r | base_t | base_p ;
187
188 //----------------------------------
189 // Start of computation
190 //----------------------------------
191
192 // Nothing to do ?
193 if (tb->get_etat() == ETATZERO) {
194 return ;
195 }
196
197 assert(tb->get_etat() == ETATQCQ) ; // Protection
198
199 // Number of degrees of freedom
200 int nr = tb->get_dim(0) ;
201 int nt = tb->get_dim(1) ;
202 int np = tb->get_dim(2) - 2 ;
203
204 // Special case np = 1 (axisymmetry) --> identity
205 // ---------------------------------
206
207 if (np==1) {
208 return ;
209 }
210
211 assert(np >= 4) ;
212
213 int ntnr = nt*nr ;
214
215 double* const cf = tb->t ; // input coefficients
216 double* const resu = new double[ tb->get_taille() ] ; // final result
217 double* co = resu ; // initial position
218
219 // Case k=0 (m=0)
220 // --------------
221
222 int q = 2 * ntnr ;
223 for (int i=0; i<ntnr; i++) {
224 co[i] = 0.5 * cf[q + i] ;
225 }
226 co += ntnr ;
227
228 // Case k = 1
229 // ----------
230
231 for (int i=0; i<ntnr; i++) {
232 co[i] = 0 ;
233 }
234 co += ntnr ;
235
236 // Case k = 2
237 // ----------
238
239 q = 4*ntnr ;
240 for (int i=0; i<ntnr; i++) {
241 co[i] = cf[i] + 0.5 * cf[q+i] ;
242 }
243 co += ntnr ;
244
245 if (np==4) {
246
247 // Case k = 3 for np=4
248 // ----------
249
250 for (int i=0; i<ntnr; i++) {
251 co[i] = 0 ;
252 }
253 co += ntnr ;
254 }
255 else {
256
257 // Case k = 3 for np>4
258 // ----------
259
260 q = 5*ntnr ;
261 for (int i=0; i<ntnr; i++) {
262 co[i] = 0.5 * cf[q+i] ;
263 }
264 co += ntnr ;
265
266 // Cases 4 <= k <= np-2
267 // --------------------
268
269 for (int k=4; k<np-1; k++) {
270 int q1 = (k-2)*ntnr ;
271 int q2 = (k+2)*ntnr ;
272 for (int i=0; i<ntnr; i++) {
273 co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ;
274 }
275 co += ntnr ;
276 }
277
278 // Case k = np - 1 for np>4
279 // ---------------
280
281 q = (np-3)*ntnr ;
282 for (int i=0; i<ntnr; i++) {
283 co[i] = 0.5 * cf[q+i] ;
284 }
285 co += ntnr ;
286
287 } // End of case np > 4
288
289
290 // Case k = np
291 // -----------
292
293 q = (np-2)*ntnr ;
294 for (int i=0; i<ntnr; i++) {
295 co[i] = 0.5 * cf[q+i] ;
296 }
297 co += ntnr ;
298
299 // Case k = np+1
300 // -------------
301
302 for (int i=0; i<ntnr; i++) {
303 co[i] = 0 ;
304 }
305
306 //## verif :
307 co += ntnr ;
308 assert( co == resu + (np+2)*ntnr ) ;
309
310
311 // The result is set to tb :
312 // -----------------------
313 delete [] tb->t ;
314 tb->t = resu ;
315
316 return ;
317}
318
319
320 //-----------------
321 // basis P_COSSIN_P
322 //-----------------
323
324void _mult_cp_p_cossin_p(Tbl* tb, int& base) {
325
326 assert(tb->get_etat() != ETATNONDEF) ; // Protection
327
328 // New spectral bases
329 // ------------------
330 int base_r = base & MSQ_R ;
331 int base_t = base & MSQ_T ;
332 base = base_r | base_t | P_COSSIN_I ;
333
334 //----------------------------------
335 // Start of computation
336 //----------------------------------
337
338 // Nothing to do ?
339 if (tb->get_etat() == ETATZERO) {
340 return ;
341 }
342
343 assert(tb->get_etat() == ETATQCQ) ; // Protection
344
345 // Number of degrees of freedom
346 int nr = tb->get_dim(0) ;
347 int nt = tb->get_dim(1) ;
348 int np = tb->get_dim(2) - 2 ;
349
350 // Special case np = 1 (axisymmetry) --> identity
351 // ---------------------------------
352
353 if (np==1) {
354 return ;
355 }
356
357 assert(np >= 4) ;
358
359 int ntnr = nt*nr ;
360
361 double* const cf = tb->t ; // input coefficients
362 double* const resu = new double[ tb->get_taille() ] ; // final result
363 double* co = resu ; // initial position
364
365 // Case k=0
366 // --------
367
368 int q = 2 * ntnr ;
369 for (int i=0; i<ntnr; i++) {
370 co[i] = cf[i] + 0.5 * cf[q + i] ;
371 }
372 co += ntnr ;
373
374 // Case k = 1
375 // ----------
376
377 for (int i=0; i<ntnr; i++) {
378 co[i] = 0 ;
379 }
380 co += ntnr ;
381
382 // Case k = 2
383 // ----------
384
385 q = 3*ntnr ;
386 for (int i=0; i<ntnr; i++) {
387 co[i] = 0.5 * cf[q+i] ;
388 }
389 co += ntnr ;
390
391
392 // Cases 3 <= k <= np-1
393 // --------------------
394
395 for (int k=3; k<np; k++) {
396 int q1 = (k-1)*ntnr ;
397 int q2 = (k+1)*ntnr ;
398 for (int i=0; i<ntnr; i++) {
399 co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ;
400 }
401 co += ntnr ;
402 }
403
404 // Case k = np
405 // -----------
406
407 q = (np-1)*ntnr ;
408 for (int i=0; i<ntnr; i++) {
409 co[i] = 0.5 * cf[q+i] ;
410 }
411 co += ntnr ;
412
413 // Case k = np+1
414 // -------------
415
416 for (int i=0; i<ntnr; i++) {
417 co[i] = 0 ;
418 }
419
420 //## verif :
421 co += ntnr ;
422 assert( co == resu + (np+2)*ntnr ) ;
423
424 // The result is set to tb :
425 // -----------------------
426 delete [] tb->t ;
427 tb->t = resu ;
428
429 return ;
430}
431
432
433
434 //-----------------
435 // basis P_COSSIN_I
436 //-----------------
437
438void _mult_cp_p_cossin_i(Tbl* tb, int& base) {
439
440 assert(tb->get_etat() != ETATNONDEF) ; // Protection
441
442 // New spectral bases
443 // ------------------
444 int base_r = base & MSQ_R ;
445 int base_t = base & MSQ_T ;
446 base = base_r | base_t | P_COSSIN_P ;
447
448 //----------------------------------
449 // Start of computation
450 //----------------------------------
451
452 // Nothing to do ?
453 if (tb->get_etat() == ETATZERO) {
454 return ;
455 }
456
457 assert(tb->get_etat() == ETATQCQ) ; // Protection
458
459 // Number of degrees of freedom
460 int nr = tb->get_dim(0) ;
461 int nt = tb->get_dim(1) ;
462 int np = tb->get_dim(2) - 2 ;
463
464 // Special case np = 1 (axisymmetry) --> identity
465 // ---------------------------------
466
467 if (np==1) {
468 return ;
469 }
470
471 assert(np >= 4) ;
472
473 int ntnr = nt*nr ;
474
475 double* const cf = tb->t ; // input coefficients
476 double* const resu = new double[ tb->get_taille() ] ; // final result
477 double* co = resu ; // initial position
478
479 // Case k=0
480 // --------
481
482 for (int i=0; i<ntnr; i++) {
483 co[i] = 0.5 * cf[i] ;
484 }
485 co += ntnr ;
486
487 // Case k = 1
488 // ----------
489
490 for (int i=0; i<ntnr; i++) {
491 co[i] = 0 ;
492 }
493 co += ntnr ;
494
495 // Case k = 2
496 // ----------
497
498 int q = 3*ntnr ;
499 for (int i=0; i<ntnr; i++) {
500 co[i] = 0.5 * ( cf[i] + cf[q+i] ) ;
501 }
502 co += ntnr ;
503
504 // Cases 3 <= k <= np-1
505 // --------------------
506
507 for (int k=3; k<np; k++) {
508 int q1 = (k-1)*ntnr ;
509 int q2 = (k+1)*ntnr ;
510 for (int i=0; i<ntnr; i++) {
511 co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ;
512 }
513 co += ntnr ;
514 }
515
516 // Case k = np
517 // -----------
518
519 q = (np-1)*ntnr ;
520 for (int i=0; i<ntnr; i++) {
521 co[i] = 0.5 * cf[q+i] ;
522 }
523 co += ntnr ;
524
525 // Case k = np+1
526 // -------------
527
528 for (int i=0; i<ntnr; i++) {
529 co[i] = 0 ;
530 }
531
532 //## verif :
533 co += ntnr ;
534 assert( co == resu + (np+2)*ntnr ) ;
535
536 // The result is set to tb :
537 // -----------------------
538 delete [] tb->t ;
539 tb->t = resu ;
540
541 return ;
542}
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561}
Basic array class.
Definition tbl.h:161
#define P_COSSIN_P
dev. sur Phi = 2*phi, freq. paires
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define T_COSSIN_SP
sin pair-cos impair alternes, sin pour m=0
#define MSQ_R
Extraction de l'info sur R.
#define T_COSSIN_S
dev. cos-sin alternes, sin pour m=0
#define R_CHEBPIM_I
Cheb. pair-impair suivant m, impair pour m=0.
#define T_COSSIN_SI
sin impair-cos pair alternes, sin pour m=0
#define R_CHEBPI_I
Cheb. pair-impair suivant l impair pour l=0.
#define T_COSSIN_CI
cos impair-sin pair alternes, cos pour m=0
#define P_COSSIN_I
dev. sur Phi = 2*phi, freq. impaires
#define R_CHEBPIM_P
Cheb. pair-impair suivant m, pair pour m=0.
#define MSQ_T
Extraction de l'info sur Theta.
#define T_COSSIN_CP
cos pair-sin impair alternes, cos pour m=0
#define R_CHEB
base de Chebychev ordinaire (fin)
#define MSQ_P
Extraction de l'info sur Phi.
#define T_COSSIN_C
dev. cos-sin alternes, cos pour m=0
#define R_CHEBPI_P
Cheb. pair-impair suivant l pair pour l=0.
Lorene prototypes.
Definition app_hor.h:67