00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char solp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/solp.C,v 1.9 2008/07/11 13:20:54 j_novak 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 #include <stdio.h>
00110 #include <stdlib.h>
00111 #include <math.h>
00112
00113 #include "matrice.h"
00114 #include "type_parite.h"
00115 #include "proto.h"
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 Tbl _solp_pas_prevu (const Matrice &lap, const Matrice &nondege, double alpha,
00135 double beta, const Tbl &source, int puis) {
00136 cout << " Solution particuliere pas prevue ..... : "<< endl ;
00137 cout << " Laplacien : " << endl << lap << endl ;
00138 cout << " Non degenere : " << endl << nondege << endl ;
00139 cout << " Source : " << &source << endl ;
00140 cout << " Alpha : " << alpha << endl ;
00141 cout << " Beta : " << beta << endl ;
00142 cout << " Puiss : " << puis << endl ;
00143 abort() ;
00144 exit(-1) ;
00145 Tbl res(1) ;
00146 return res;
00147 }
00148
00149
00150
00151
00152
00153
00154 Tbl _solp_r_cheb (const Matrice &lap, const Matrice &nondege, double alpha,
00155 double beta, const Tbl &source, int) {
00156
00157 int n = lap.get_dim(0) ;
00158 int dege = n-nondege.get_dim(0) ;
00159 assert (dege ==2) ;
00160
00161 Tbl source_aux(source*alpha*alpha) ;
00162 Tbl xso(source_aux) ;
00163 Tbl xxso(source_aux) ;
00164 multx_1d(n, &xso.t, R_CHEB) ;
00165 multx_1d(n, &xxso.t, R_CHEB) ;
00166 multx_1d(n, &xxso.t, R_CHEB) ;
00167 source_aux = beta*beta/alpha/alpha*source_aux+2*beta/alpha*xso+xxso ;
00168 source_aux = combinaison(source_aux, 0, R_CHEB) ;
00169
00170 Tbl so(n-dege) ;
00171 so.set_etat_qcq() ;
00172 for (int i=0 ; i<n-dege ; i++)
00173 so.set(i) = source_aux(i) ;
00174
00175 Tbl auxi(nondege.inverse(so)) ;
00176
00177 Tbl res(n) ;
00178 res.set_etat_qcq() ;
00179 for (int i=dege ; i<n ; i++)
00180 res.set(i) = auxi(i-dege) ;
00181
00182 for (int i=0 ; i<dege ; i++)
00183 res.set(i) = 0 ;
00184 return res ;
00185 }
00186
00187
00188
00189
00190
00191 Tbl _solp_r_jaco02 (const Matrice &lap, const Matrice &nondege, double alpha,
00192 double, const Tbl &source, int) {
00193
00194 int n = lap.get_dim(0) ;
00195 int dege = n-nondege.get_dim(0) ;
00196 assert (dege ==2) ;
00197
00198 Tbl source_aux(source*alpha*alpha) ;
00199 source_aux = combinaison(source_aux, 0, R_JACO02) ;
00200
00201 Tbl so(n-dege) ;
00202 so.set_etat_qcq() ;
00203 for (int i=0 ; i<n-dege ; i++)
00204 so.set(i) = source_aux(i) ;
00205
00206 Tbl auxi(nondege.inverse(so)) ;
00207
00208 Tbl res(n) ;
00209 res.set_etat_qcq() ;
00210 for (int i=dege ; i<n ; i++)
00211 res.set(i) = auxi(i-dege) ;
00212
00213 for (int i=0 ; i<dege ; i++)
00214 res.set(i) = 0 ;
00215 return res ;
00216 }
00217
00218
00219
00220
00221
00222
00223 Tbl _solp_r_chebp (const Matrice &lap, const Matrice &nondege, double alpha,
00224 double , const Tbl &source, int) {
00225
00226 int n = lap.get_dim(0) ;
00227 int dege = n-nondege.get_dim(0) ;
00228 assert ((dege==2) || (dege == 1)) ;
00229 Tbl source_aux(alpha*alpha*source) ;
00230 source_aux = combinaison(source_aux, 0, R_CHEBP) ;
00231
00232 Tbl so(n-dege) ;
00233 so.set_etat_qcq() ;
00234 for (int i=0 ; i<n-dege ; i++)
00235 so.set(i) = source_aux(i);
00236
00237 Tbl auxi(nondege.inverse(so)) ;
00238
00239 Tbl res(n) ;
00240 res.set_etat_qcq() ;
00241 for (int i=dege ; i<n ; i++)
00242 res.set(i) = auxi(i-dege) ;
00243
00244 for (int i=0 ; i<dege ; i++)
00245 res.set(i) = 0 ;
00246
00247 if (dege==2) {
00248 double somme = 0 ;
00249 for (int i=0 ; i<n ; i++)
00250 if (i%2 == 0)
00251 somme -= res(i) ;
00252 else somme += res(i) ;
00253 res.set(0) = somme ;
00254 return res ;
00255 }
00256 else return res ;
00257 }
00258
00259
00260
00261
00262
00263
00264 Tbl _solp_r_chebi (const Matrice &lap, const Matrice &nondege, double alpha,
00265 double, const Tbl &source, int) {
00266
00267
00268 int n = lap.get_dim(0) ;
00269 int dege = n-nondege.get_dim(0) ;
00270 assert ((dege == 2) || (dege ==1)) ;
00271 Tbl source_aux(source*alpha*alpha) ;
00272 source_aux = combinaison(source_aux, 0, R_CHEBI) ;
00273
00274 Tbl so(n-dege) ;
00275 so.set_etat_qcq() ;
00276 for (int i=0 ; i<n-dege ; i++)
00277 so.set(i) = source_aux(i);
00278
00279 Tbl auxi(nondege.inverse(so)) ;
00280
00281 Tbl res(n) ;
00282 res.set_etat_qcq() ;
00283 for (int i=dege ; i<n ; i++)
00284 res.set(i) = auxi(i-dege) ;
00285
00286 for (int i=0 ; i<dege ; i++)
00287 res.set(i) = 0 ;
00288
00289 if (dege==2) {
00290 double somme = 0 ;
00291 for (int i=0 ; i<n ; i++)
00292 if (i%2 == 0)
00293 somme -= (2*i+1)*res(i) ;
00294 else somme += (2*i+1)*res(i) ;
00295 res.set(0) = somme ;
00296 return res ;
00297 }
00298 else return res ;
00299 }
00300
00301
00302
00303
00304
00305
00306
00307 Tbl _solp_r_chebu (const Matrice &lap, const Matrice &nondege, double alpha,
00308 double, const Tbl &source, int puis) {
00309 int n = lap.get_dim(0) ;
00310 Tbl res(n) ;
00311 res.set_etat_qcq() ;
00312
00313 switch (puis) {
00314 case 5 :
00315 res = _solp_r_chebu_cinq (lap, nondege, source) ;
00316 break ;
00317 case 4 :
00318 res = _solp_r_chebu_quatre (lap, nondege, alpha, source) ;
00319 break ;
00320 case 3 :
00321 res = _solp_r_chebu_trois (lap, nondege, alpha, source) ;
00322 break ;
00323 case 2 :
00324 res = _solp_r_chebu_deux (lap, nondege, source) ;
00325 break ;
00326 default :
00327 abort() ;
00328 exit(-1) ;
00329 }
00330 return res ;
00331 }
00332
00333
00334
00335 Tbl _solp_r_chebu_quatre (const Matrice &lap, const Matrice &nondege, double alpha,
00336 const Tbl &source) {
00337
00338 int n = lap.get_dim(0) ;
00339 int dege = n-nondege.get_dim(0) ;
00340 assert ((dege==3) || (dege ==2)) ;
00341 Tbl source_aux(source*alpha*alpha) ;
00342 source_aux = combinaison(source_aux, 4, R_CHEBU) ;
00343
00344 Tbl so(n-dege) ;
00345 so.set_etat_qcq() ;
00346 for (int i=0 ; i<n-dege ; i++)
00347 so.set(i) = source_aux(i);
00348
00349 Tbl auxi(nondege.inverse(so)) ;
00350
00351 Tbl res(n) ;
00352 res.set_etat_qcq() ;
00353 for (int i=dege ; i<n ; i++)
00354 res.set(i) = auxi(i-dege) ;
00355
00356 for (int i=0 ; i<dege ; i++)
00357 res.set(i) = 0 ;
00358
00359 if (dege==3) {
00360 double somme = 0 ;
00361 for (int i=0 ; i<n ; i++)
00362 somme += i*i*res(i) ;
00363 double somme_deux = somme ;
00364 for (int i=0 ; i<n ; i++)
00365 somme_deux -= res(i) ;
00366 res.set(1) = -somme ;
00367 res.set(0) = somme_deux ;
00368 return res ;
00369 }
00370 else {
00371 double somme = 0 ;
00372 for (int i=0 ; i<n ; i++)
00373 somme += res(i) ;
00374 res.set(0) = -somme ;
00375 return res ;
00376 }
00377 }
00378
00379
00380 Tbl _solp_r_chebu_trois (const Matrice &lap, const Matrice &nondege, double alpha,
00381 const Tbl &source) {
00382
00383 int n = lap.get_dim(0) ;
00384 int dege = n-nondege.get_dim(0) ;
00385 assert (dege ==2) ;
00386
00387 Tbl source_aux(source*alpha) ;
00388 source_aux = combinaison(source_aux, 3, R_CHEBU) ;
00389
00390 Tbl so(n-dege) ;
00391 so.set_etat_qcq() ;
00392 for (int i=0 ; i<n-dege ; i++)
00393 so.set(i) = source_aux(i);
00394
00395 Tbl auxi(nondege.inverse(so)) ;
00396
00397 Tbl res(n) ;
00398 res.set_etat_qcq() ;
00399 for (int i=dege ; i<n ; i++)
00400 res.set(i) = auxi(i-dege) ;
00401
00402 for (int i=0 ; i<dege ; i++)
00403 res.set(i) = 0 ;
00404
00405 double somme = 0 ;
00406 for (int i=0 ; i<n ; i++)
00407 somme += res(i) ;
00408 res.set(0) = -somme ;
00409 return res ;
00410 }
00411
00412
00413
00414 Tbl _solp_r_chebu_deux (const Matrice &lap, const Matrice &nondege,
00415 const Tbl &source) {
00416
00417 int n = lap.get_dim(0) ;
00418 int dege = n-nondege.get_dim(0) ;
00419 assert ((dege==1) || (dege ==2)) ;
00420 Tbl source_aux(combinaison(source, 2, R_CHEBU)) ;
00421
00422 Tbl so(n-dege) ;
00423 so.set_etat_qcq() ;
00424 for (int i=0 ; i<n-dege ; i++)
00425 so.set(i) = source_aux(i);
00426
00427 Tbl auxi(nondege.inverse(so)) ;
00428
00429 Tbl res(n) ;
00430 res.set_etat_qcq() ;
00431 for (int i=dege ; i<n ; i++)
00432 res.set(i) = auxi(i-dege) ;
00433
00434 for (int i=0 ; i<dege ; i++)
00435 res.set(i) = 0 ;
00436
00437 if (dege == 2) {
00438 double somme = 0 ;
00439 for (int i=0 ; i<n ; i++)
00440 somme+=res(i) ;
00441
00442 res.set(0) = -somme ;
00443 }
00444
00445 return res ;
00446 }
00447
00448
00449 Tbl _solp_r_chebu_cinq (const Matrice &lap, const Matrice &nondege,
00450 const Tbl &source) {
00451
00452 int n = lap.get_dim(0) ;
00453 int dege = n-nondege.get_dim(0) ;
00454
00455 Tbl source_aux(combinaison(source, 5, R_CHEBU)) ;
00456
00457 Tbl so(n-dege) ;
00458 so.set_etat_qcq() ;
00459 for (int i=0 ; i<n-dege ; i++)
00460 so.set(i) = source_aux(i);
00461
00462 Tbl auxi(nondege.inverse(so)) ;
00463
00464 Tbl res(n) ;
00465 res.set_etat_qcq() ;
00466 for (int i=dege ; i<n ; i++)
00467 res.set(i) = auxi(i-dege) ;
00468
00469 for (int i=0 ; i<dege ; i++)
00470 res.set(i) = 0 ;
00471
00472 if (dege == 2) {
00473 double somme = 0 ;
00474 for (int i=0 ; i<n ; i++)
00475 somme+=res(i) ;
00476
00477 res.set(0) = -somme ;
00478 }
00479
00480 return res ;
00481 }
00482
00483
00484
00485
00486
00487
00488
00489 Tbl solp(const Matrice &lap, const Matrice &nondege, double alpha,
00490 double beta, const Tbl &source, int puis, int base_r) {
00491
00492
00493 static Tbl (*solp[MAX_BASE])(const Matrice&, const Matrice&, double, double,
00494 const Tbl&, int) ;
00495 static int nap = 0 ;
00496
00497
00498 if (nap==0) {
00499 nap = 1 ;
00500 for (int i=0 ; i<MAX_BASE ; i++) {
00501 solp[i] = _solp_pas_prevu ;
00502 }
00503
00504 solp[R_CHEB >> TRA_R] = _solp_r_cheb ;
00505 solp[R_CHEBU >> TRA_R] = _solp_r_chebu ;
00506 solp[R_CHEBP >> TRA_R] = _solp_r_chebp ;
00507 solp[R_CHEBI >> TRA_R] = _solp_r_chebi ;
00508 solp[R_JACO02 >> TRA_R] = _solp_r_jaco02 ;
00509 }
00510
00511 return solp[base_r](lap, nondege, alpha, beta, source, puis) ;
00512 }