00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char laplacien_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/laplacien_mat.C,v 1.9 2007/12/11 15:28:22 jl_cornou Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 #include <stdio.h>
00111 #include <stdlib.h>
00112
00113 #include "diff.h"
00114 #include "proto.h"
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 Matrice _laplacien_mat_pas_prevu(int n, int l, double echelle, int puis) {
00145 cout << "laplacien pas prevu..." << endl ;
00146 cout << "n : " << n << endl ;
00147 cout << "l : " << l << endl ;
00148 cout << "puissance : " << puis << endl ;
00149 cout << "echelle : " << echelle << endl ;
00150 abort() ;
00151 exit(-1) ;
00152 Matrice res(1, 1) ;
00153 return res;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 Matrice _laplacien_mat_r_jaco02 (int n, int l, double, int) {
00163
00164 const int nmax = 200 ;
00165 static Matrice* tab[nmax] ;
00166 static int nb_dejafait = 0 ;
00167 static int l_dejafait[nmax] ;
00168 static int nr_dejafait[nmax] ;
00169
00170 int indice = -1 ;
00171
00172
00173 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00174 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00175 indice = conte ;
00176
00177
00178 if (indice == -1) {
00179 if (nb_dejafait >= nmax) {
00180 cout << "_laplacien_mat_r_jaco02 : trop de matrices" << endl ;
00181 abort() ;
00182 exit (-1) ;
00183 }
00184
00185
00186 l_dejafait[nb_dejafait] = l ;
00187 nr_dejafait[nb_dejafait] = n ;
00188
00189 Diff_dsdx2 d2(R_JACO02, n) ;
00190 Diff_sxdsdx sxd(R_JACO02, n) ;
00191 Diff_sx2 sx2(R_JACO02, n) ;
00192
00193 tab[nb_dejafait] = new Matrice(d2 + 2.*sxd -(l*(l+1))*sx2) ;
00194
00195 indice = nb_dejafait ;
00196 nb_dejafait ++ ;
00197 }
00198
00199 return *tab[indice] ;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208 Matrice _laplacien_mat_r_chebp (int n, int l, double, int) {
00209
00210 const int nmax = 200 ;
00211 static Matrice* tab[nmax] ;
00212 static int nb_dejafait = 0 ;
00213 static int l_dejafait[nmax] ;
00214 static int nr_dejafait[nmax] ;
00215
00216 int indice = -1 ;
00217
00218
00219 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00220 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00221 indice = conte ;
00222
00223
00224 if (indice == -1) {
00225 if (nb_dejafait >= nmax) {
00226 cout << "_laplacien_mat_r_chebp : trop de matrices" << endl ;
00227 abort() ;
00228 exit (-1) ;
00229 }
00230
00231
00232 l_dejafait[nb_dejafait] = l ;
00233 nr_dejafait[nb_dejafait] = n ;
00234
00235 Diff_dsdx2 d2(R_CHEBP, n) ;
00236 Diff_sxdsdx sxd(R_CHEBP, n) ;
00237 Diff_sx2 sx2(R_CHEBP, n) ;
00238
00239 tab[nb_dejafait] = new Matrice(d2 + 2.*sxd -(l*(l+1))*sx2) ;
00240
00241 indice = nb_dejafait ;
00242 nb_dejafait ++ ;
00243 }
00244
00245 return *tab[indice] ;
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255 Matrice _laplacien_mat_r_chebi (int n, int l, double, int) {
00256
00257 const int nmax = 200 ;
00258 static Matrice* tab[nmax] ;
00259 static int nb_dejafait = 0 ;
00260 static int l_dejafait[nmax] ;
00261 static int nr_dejafait[nmax] ;
00262
00263 int indice = -1 ;
00264
00265
00266 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00267 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00268 indice = conte ;
00269
00270
00271 if (indice == -1) {
00272 if (nb_dejafait >= nmax) {
00273 cout << "_laplacien_mat_r_chebi : trop de matrices" << endl ;
00274 abort() ;
00275 exit (-1) ;
00276 }
00277
00278
00279 l_dejafait[nb_dejafait] = l ;
00280 nr_dejafait[nb_dejafait] = n ;
00281
00282 Diff_dsdx2 d2(R_CHEBI, n) ;
00283 Diff_sxdsdx sxd(R_CHEBI, n) ;
00284 Diff_sx2 sx2(R_CHEBI, n) ;
00285
00286 tab[nb_dejafait] = new Matrice(d2 + 2.*sxd - (l*(l+1))*sx2) ;
00287 indice = nb_dejafait ;
00288 nb_dejafait ++ ;
00289 }
00290
00291 return *tab[indice] ;
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301 Matrice _laplacien_mat_r_chebu( int n, int l, double, int puis) {
00302 Matrice res(n, n) ;
00303 res.set_etat_qcq() ;
00304 switch (puis) {
00305 case 4 :
00306 res = _laplacien_mat_r_chebu_quatre (n, l) ;
00307 break ;
00308 case 3 :
00309 res = _laplacien_mat_r_chebu_trois (n, l) ;
00310 break ;
00311 case 2 :
00312 res = _laplacien_mat_r_chebu_deux (n, l) ;
00313 break ;
00314 case 5 :
00315 res = _laplacien_mat_r_chebu_cinq (n, l) ;
00316 break ;
00317 default :
00318 abort() ;
00319 exit(-1) ;
00320 }
00321 return res ;
00322 }
00323
00324
00325 Matrice _laplacien_mat_r_chebu_quatre (int n, int l) {
00326
00327 const int nmax = 200 ;
00328 static Matrice* tab[nmax] ;
00329 static int nb_dejafait = 0 ;
00330 static int l_dejafait[nmax] ;
00331 static int nr_dejafait[nmax] ;
00332
00333 int indice = -1 ;
00334
00335
00336 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00337 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00338 indice = conte ;
00339
00340
00341 if (indice == -1) {
00342 if (nb_dejafait >= nmax) {
00343 cout << "_laplacien_mat_r_chebu_quatre : trop de matrices" << endl ;
00344 abort() ;
00345 exit (-1) ;
00346 }
00347
00348
00349 l_dejafait[nb_dejafait] = l ;
00350 nr_dejafait[nb_dejafait] = n ;
00351
00352 Diff_dsdx2 dd(R_CHEBU, n) ;
00353 Diff_sx2 xx(R_CHEBU, n) ;
00354
00355 tab[nb_dejafait] = new Matrice(dd-(l*(l+1))*xx) ;
00356 indice = nb_dejafait ;
00357 nb_dejafait ++ ;
00358 }
00359
00360 return *tab[indice] ;
00361 }
00362
00363
00364 Matrice _laplacien_mat_r_chebu_trois (int n, int l) {
00365
00366 const int nmax = 200 ;
00367 static Matrice* tab[nmax] ;
00368 static int nb_dejafait = 0 ;
00369 static int l_dejafait[nmax] ;
00370 static int nr_dejafait[nmax] ;
00371
00372 int indice = -1 ;
00373
00374
00375 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00376 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00377 indice = conte ;
00378
00379
00380 if (indice == -1) {
00381 if (nb_dejafait >= nmax) {
00382 cout << "_laplacien_mat_r_chebu_trois : trop de matrices" << endl ;
00383 abort() ;
00384 exit (-1) ;
00385 }
00386
00387
00388 l_dejafait[nb_dejafait] = l ;
00389 nr_dejafait[nb_dejafait] = n ;
00390
00391 Diff_xdsdx2 xd2(R_CHEBU, n) ;
00392 Diff_sx sx(R_CHEBU, n) ;
00393
00394 tab[nb_dejafait] = new Matrice(xd2 -(l*(l+1))*sx) ;
00395
00396 indice = nb_dejafait ;
00397 nb_dejafait ++ ;
00398 }
00399
00400 return *tab[indice] ;
00401 }
00402
00403
00404
00405 Matrice _laplacien_mat_r_chebu_deux (int n, int l) {
00406
00407 const int nmax = 200 ;
00408 static Matrice* tab[nmax] ;
00409 static int nb_dejafait = 0 ;
00410 static int l_dejafait[nmax] ;
00411 static int nr_dejafait[nmax] ;
00412
00413 int indice = -1 ;
00414
00415
00416 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00417 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00418 indice = conte ;
00419
00420
00421 if (indice == -1) {
00422 if (nb_dejafait >= nmax) {
00423 cout << "_laplacien_mat_r_chebu_deux : trop de matrices" << endl ;
00424 abort() ;
00425 exit (-1) ;
00426 }
00427
00428
00429 l_dejafait[nb_dejafait] = l ;
00430 nr_dejafait[nb_dejafait] = n ;
00431
00432 Diff_x2dsdx2 x2dd(R_CHEBU, n) ;
00433 Diff_id id(R_CHEBU, n) ;
00434
00435 tab[nb_dejafait] = new Matrice(x2dd - (l*(l+1))*id) ;
00436
00437 indice = nb_dejafait ;
00438 nb_dejafait ++ ;
00439 }
00440
00441 return *tab[indice] ;
00442 }
00443
00444
00445 Matrice _laplacien_mat_r_chebu_cinq (int n, int l) {
00446
00447 const int nmax = 200 ;
00448 static Matrice* tab[nmax] ;
00449 static int nb_dejafait = 0 ;
00450 static int l_dejafait[nmax] ;
00451 static int nr_dejafait[nmax] ;
00452
00453 int indice = -1 ;
00454
00455
00456 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00457 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00458 indice = conte ;
00459
00460
00461 if (indice == -1) {
00462 if (nb_dejafait >= nmax) {
00463 cout << "_laplacien_mat_r_chebu_cinq : trop de matrices" << endl ;
00464 abort() ;
00465 exit (-1) ;
00466 }
00467
00468
00469 l_dejafait[nb_dejafait] = l ;
00470 nr_dejafait[nb_dejafait] = n ;
00471
00472 Diff_x2dsdx2 x2dd(R_CHEBU, n) ;
00473 Diff_xdsdx xd1(R_CHEBU, n) ;
00474 Diff_id id(R_CHEBU, n) ;
00475
00476 tab[nb_dejafait] = new Matrice( x2dd + 6.*xd1 + (6-l*(l+1))*id ) ;
00477
00478 indice = nb_dejafait ;
00479 nb_dejafait ++ ;
00480 }
00481
00482 return *tab[indice] ;
00483 }
00484
00485
00486
00487
00488
00489
00490 Matrice _laplacien_mat_r_cheb (int n, int l, double echelle, int) {
00491
00492 const int nmax = 200 ;
00493 static Matrice* tab[nmax] ;
00494 static int nb_dejafait = 0 ;
00495 static int l_dejafait[nmax] ;
00496 static int nr_dejafait[nmax] ;
00497 static double vieux_echelle = 0;
00498
00499
00500 if (vieux_echelle != echelle) {
00501 for (int i=0 ; i<nb_dejafait ; i++) {
00502 l_dejafait[i] = -1 ;
00503 nr_dejafait[i] = -1 ;
00504 delete tab[i] ;
00505 }
00506
00507 nb_dejafait = 0 ;
00508 vieux_echelle = echelle ;
00509 }
00510
00511 int indice = -1 ;
00512
00513
00514 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00515 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00516 indice = conte ;
00517
00518
00519 if (indice == -1) {
00520 if (nb_dejafait >= nmax) {
00521 cout << "_laplacien_mat_r_cheb : trop de matrices" << endl ;
00522 abort() ;
00523 exit (-1) ;
00524 }
00525
00526
00527 l_dejafait[nb_dejafait] = l ;
00528 nr_dejafait[nb_dejafait] = n ;
00529
00530 Diff_dsdx2 d2(R_CHEB, n) ;
00531 Diff_xdsdx2 xd2(R_CHEB, n) ;
00532 Diff_x2dsdx2 x2d2(R_CHEB, n) ;
00533 Diff_dsdx d1(R_CHEB, n) ;
00534 Diff_xdsdx xd1(R_CHEB, n) ;
00535 Diff_id id(R_CHEB, n) ;
00536
00537 tab[nb_dejafait] =
00538 new Matrice(x2d2 + (2*echelle)*xd2 + (echelle*echelle)*d2
00539 + 2*xd1 + (2*echelle)*d1 - (l*(l+1))*id) ;
00540 indice = nb_dejafait ;
00541 nb_dejafait ++ ;
00542 }
00543
00544 return *tab[indice] ;
00545 }
00546
00547
00548
00549
00550
00551 Matrice laplacien_mat(int n, int l, double echelle, int puis, int base_r)
00552 {
00553
00554
00555 static Matrice (*laplacien_mat[MAX_BASE])(int, int, double, int) ;
00556 static int nap = 0 ;
00557
00558
00559 if (nap==0) {
00560 nap = 1 ;
00561 for (int i=0 ; i<MAX_BASE ; i++) {
00562 laplacien_mat[i] = _laplacien_mat_pas_prevu ;
00563 }
00564
00565 laplacien_mat[R_CHEB >> TRA_R] = _laplacien_mat_r_cheb ;
00566 laplacien_mat[R_CHEBU >> TRA_R] = _laplacien_mat_r_chebu ;
00567 laplacien_mat[R_CHEBP >> TRA_R] = _laplacien_mat_r_chebp ;
00568 laplacien_mat[R_CHEBI >> TRA_R] = _laplacien_mat_r_chebi ;
00569 laplacien_mat[R_JACO02 >> TRA_R] = _laplacien_mat_r_jaco02 ;
00570 }
00571
00572 return laplacien_mat[base_r](n, l, echelle, puis) ;
00573 }
00574