00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 char ope_poisson_2d_solh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_2d/ope_poisson_2d_solh.C,v 1.1 2004/08/24 09:14:47 p_grandclement Exp $" ;
00022
00023
00024
00025
00026
00027
00028 #include <math.h>
00029 #include <stdlib.h>
00030
00031 #include "proto.h"
00032 #include "ope_elementary.h"
00033
00034
00035
00036
00037
00038 Tbl _solh_poisson_2d_pas_prevu (int, int, double, double, Tbl&) {
00039
00040 cout << " Solution homogene pas prevue ..... : "<< endl ;
00041 exit(-1) ;
00042 Tbl res(1) ;
00043 return res;
00044 }
00045
00046
00047
00048
00049
00050
00051 Tbl _solh_poisson_2d_r_cheb (int n, int l, double alpha, double beta,
00052 Tbl& val_lim) {
00053
00054
00055 double echelle = beta / alpha ;
00056
00057
00058 if (l > 0) {
00059 val_lim.set(0,0) = pow(echelle-1, double(l)) ;
00060 val_lim.set(0,1) = double(l) * pow(echelle-1, double(l-1))/alpha ;
00061 val_lim.set(0,2) = pow(echelle+1, double(l)) ;
00062 val_lim.set(0,3) = double(l) * pow(echelle+1, double(l-1))/alpha ;
00063
00064
00065 val_lim.set(1,0) = pow(echelle-1, -double(l)) ;
00066 val_lim.set(1,1) = -double(l) * pow(echelle-1, -double(l+1))/alpha ;
00067 val_lim.set(1,2) = pow(echelle+1, -double(l)) ;
00068 val_lim.set(1,3) = -double(l) * pow(echelle+1, -double(l+1))/alpha ;
00069 }
00070
00071 else {
00072 val_lim.set(0,0) = 1. ;
00073 val_lim.set(0,1) = 0. ;
00074 val_lim.set(0,2) = 1. ;
00075 val_lim.set(0,3) = 0. ;
00076
00077 val_lim.set(1,0) = log(echelle-1) ;
00078 val_lim.set(1,1) = 1./(echelle-1)/alpha ;
00079 val_lim.set(1,2) = log(echelle+1) ;
00080 val_lim.set(1,3) = 1./(echelle+1)/alpha ;
00081 }
00082
00083 const int nmax = 200 ;
00084 static Tbl* tab[nmax] ;
00085 static int nb_dejafait = 0 ;
00086 static int l_dejafait[nmax] ;
00087 static int nr_dejafait[nmax] ;
00088 static double vieux_echelle = 0;
00089
00090
00091 if (vieux_echelle != echelle) {
00092 for (int i=0 ; i<nb_dejafait ; i++) {
00093 l_dejafait[i] = -1 ;
00094 nr_dejafait[i] = -1 ;
00095 delete tab[i] ;
00096 }
00097 nb_dejafait = 0 ;
00098 vieux_echelle = echelle ;
00099 }
00100
00101 int indice = -1 ;
00102
00103
00104 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00105 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00106 indice = conte ;
00107
00108
00109 if (indice == -1) {
00110 if (nb_dejafait >= nmax) {
00111 cout << "_solh_poisson_2d_r_cheb : trop de Tbl" << endl ;
00112 abort() ;
00113 exit (-1) ;
00114 }
00115
00116
00117 l_dejafait[nb_dejafait] = l ;
00118 nr_dejafait[nb_dejafait] = n ;
00119
00120 Tbl res(2, n) ;
00121 res.set_etat_qcq() ;
00122 double* coloc = new double[n] ;
00123
00124 int * deg = new int[3] ;
00125 deg[0] = 1 ;
00126 deg[1] = 1 ;
00127 deg[2] = n ;
00128
00129
00130
00131
00132 for (int i=0 ; i<n ; i++)
00133 if (l!=0)
00134 coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(l)) ;
00135 else
00136 coloc[i] = 1 ;
00137
00138 cfrcheb(deg, deg, coloc, deg, coloc) ;
00139 for (int i=0 ; i<n ;i++)
00140 res.set(0, i) = coloc[i] ;
00141
00142
00143
00144 for (int i=0 ; i<n ; i++)
00145 if (l != 0)
00146 coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), -double(l)) ;
00147 else
00148 coloc[i] = log(echelle-cos(M_PI*i/(n-1))) ;
00149
00150 cfrcheb(deg, deg, coloc, deg, coloc) ;
00151 for (int i=0 ; i<n ;i++)
00152 res.set(1, i) = coloc[i] ;
00153
00154
00155 delete [] coloc ;
00156 delete [] deg ;
00157 tab[nb_dejafait] = new Tbl(res) ;
00158 nb_dejafait ++ ;
00159 return res ;
00160 }
00161
00162 else return *tab[indice] ;
00163 }
00164
00165
00166
00167
00168
00169 Tbl _solh_poisson_2d_r_chebp (int n, int l, double alpha,
00170 double, Tbl& val_lim) {
00171
00172 val_lim.set(0,0) = (l!=0) ? 1 : 0 ;
00173 val_lim.set(0,1) = (l!=1) ? 0 : 1 ;
00174 val_lim.set(0,2) = 1. ;
00175 val_lim.set(0,3) = double(l)/alpha ;
00176
00177 const int nmax = 200 ;
00178 static Tbl* tab[nmax] ;
00179 static int nb_dejafait = 0 ;
00180 static int l_dejafait[nmax] ;
00181 static int nr_dejafait[nmax] ;
00182
00183 int indice = -1 ;
00184
00185
00186 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00187 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00188 indice = conte ;
00189
00190
00191 if (indice == -1) {
00192 if (nb_dejafait >= nmax) {
00193 cout << "_solh_poisson_2d_r_chebp : trop de Tbl" << endl ;
00194 abort() ;
00195 exit (-1) ;
00196 }
00197
00198
00199 l_dejafait[nb_dejafait] = l ;
00200 nr_dejafait[nb_dejafait] = n ;
00201
00202 assert (div(l, 2).rem ==0) ;
00203
00204 Tbl res(n) ;
00205 res.set_etat_qcq() ;
00206 double* coloc = new double[n] ;
00207
00208 int * deg = new int[3] ;
00209 deg[0] = 1 ;
00210 deg[1] = 1 ;
00211 deg[2] = n ;
00212
00213 for (int i=0 ; i<n ; i++)
00214 if (l!=0)
00215 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00216 else
00217 coloc[i] = 1 ;
00218
00219 cfrchebp(deg, deg, coloc, deg, coloc) ;
00220 for (int i=0 ; i<n ;i++)
00221 res.set(i) = coloc[i] ;
00222
00223 delete [] coloc ;
00224 delete [] deg ;
00225 tab[nb_dejafait] = new Tbl(res) ;
00226 nb_dejafait ++ ;
00227 return res ;
00228 }
00229
00230 else return *tab[indice] ;
00231 }
00232
00233
00234
00235
00236
00237
00238 Tbl _solh_poisson_2d_r_chebi (int n, int l,
00239 double alpha, double, Tbl& val_lim) {
00240
00241 val_lim.set(0,0) = 0 ;
00242 val_lim.set(0,1) = (l!=1) ? 0 : 1 ;
00243 val_lim.set(0,2) = 1. ;
00244 val_lim.set(0,3) = double(l)/alpha ;
00245
00246 const int nmax = 200 ;
00247 static Tbl* tab[nmax] ;
00248 static int nb_dejafait = 0 ;
00249 static int l_dejafait[nmax] ;
00250 static int nr_dejafait[nmax] ;
00251
00252 int indice = -1 ;
00253
00254
00255 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00256 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00257 indice = conte ;
00258
00259
00260 if (indice == -1) {
00261 if (nb_dejafait >= nmax) {
00262 cout << "_solh_r_chebi : trop de Tbl" << endl ;
00263 abort() ;
00264 exit (-1) ;
00265 }
00266
00267
00268 l_dejafait[nb_dejafait] = l ;
00269 nr_dejafait[nb_dejafait] = n ;
00270
00271
00272 assert (div(l, 2).rem == 1) ;
00273
00274 Tbl res(n) ;
00275 res.set_etat_qcq() ;
00276 double* coloc = new double[n] ;
00277
00278 int * deg = new int[3] ;
00279 deg[0] = 1 ;
00280 deg[1] = 1 ;
00281 deg[2] = n ;
00282
00283 for (int i=0 ; i<n ; i++)
00284 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00285
00286 cfrchebi(deg, deg, coloc, deg, coloc) ;
00287 for (int i=0 ; i<n ;i++)
00288 res.set(i) = coloc[i] ;
00289
00290 delete [] coloc ;
00291 delete [] deg ;
00292 tab[nb_dejafait] = new Tbl(res) ;
00293 nb_dejafait ++ ;
00294 return res ;
00295 }
00296
00297 else return *tab[indice] ;
00298 }
00299
00300
00301
00302
00303
00304
00305
00306 Tbl _solh_poisson_2d_r_chebu (int n, int l, double alpha,
00307 double, Tbl& val_lim) {
00308
00309
00310 if (l==0) {
00311 cout << "Case l=0 in 2D Poisson not defined in the external compactified domain..." << endl ;
00312 abort() ;
00313 }
00314
00315 val_lim.set(0,0) = pow(-2., double(l)) ;
00316 val_lim.set(0,1) = -double(l)*alpha*pow(-2, double(l+1.)) ;
00317 val_lim.set(0,2) = 0 ;
00318 val_lim.set(0,3) = 0 ;
00319
00320 const int nmax = 200 ;
00321 static Tbl* tab[nmax] ;
00322 static int nb_dejafait = 0 ;
00323 static int l_dejafait[nmax] ;
00324 static int nr_dejafait[nmax] ;
00325
00326 int indice = -1 ;
00327
00328
00329 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00330 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00331 indice = conte ;
00332
00333
00334 if (indice == -1) {
00335 if (nb_dejafait >= nmax) {
00336 cout << "_solh_poisson_2d_r_chebu : trop de Tbl" << endl ;
00337 abort() ;
00338 exit (-1) ;
00339 }
00340
00341
00342 l_dejafait[nb_dejafait] = l ;
00343 nr_dejafait[nb_dejafait] = n ;
00344
00345
00346
00347 Tbl res(n) ;
00348 res.set_etat_qcq() ;
00349 double* coloc = new double[n] ;
00350
00351 int * deg = new int[3] ;
00352 deg[0] = 1 ;
00353 deg[1] = 1 ;
00354 deg[2] = n ;
00355
00356 for (int i=0 ; i<n ; i++)
00357 coloc[i] = pow(-1-cos(M_PI*i/(n-1)), double(l)) ;
00358
00359 cfrcheb(deg, deg, coloc, deg, coloc) ;
00360 for (int i=0 ; i<n ;i++)
00361 res.set(i) = coloc[i] ;
00362
00363 delete [] coloc ;
00364 delete [] deg ;
00365 tab[nb_dejafait] = new Tbl(res) ;
00366 nb_dejafait ++ ;
00367 return res ;
00368 }
00369
00370 else return *tab[indice] ;
00371 }
00372
00373
00374 Tbl Ope_poisson_2d::get_solh () const {
00375
00376
00377 static Tbl (*solh_poisson_2d[MAX_BASE]) (int, int, double, double, Tbl&) ;
00378 static int nap = 0 ;
00379
00380
00381 if (nap==0) {
00382 nap = 1 ;
00383 for (int i=0 ; i<MAX_BASE ; i++) {
00384 solh_poisson_2d[i] = _solh_poisson_2d_pas_prevu ;
00385 }
00386
00387 solh_poisson_2d[R_CHEB >> TRA_R] = _solh_poisson_2d_r_cheb ;
00388 solh_poisson_2d[R_CHEBP >> TRA_R] = _solh_poisson_2d_r_chebp ;
00389 solh_poisson_2d[R_CHEBI >> TRA_R] = _solh_poisson_2d_r_chebi ;
00390 solh_poisson_2d[R_CHEBU >> TRA_R] = _solh_poisson_2d_r_chebu ;
00391 }
00392
00393 Tbl val_lim (2,4) ;
00394 val_lim.set_etat_qcq() ;
00395 Tbl res(solh_poisson_2d[base_r](nr,l_quant, alpha, beta, val_lim)) ;
00396
00397 s_one_minus = val_lim(0,0) ;
00398 ds_one_minus = val_lim(0,1) ;
00399 s_one_plus = val_lim(0,2) ;
00400 ds_one_plus = val_lim(0,3) ;
00401
00402 s_two_minus = val_lim(1,0) ;
00403 ds_two_minus = val_lim(1,1) ;
00404 s_two_plus = val_lim(1,2) ;
00405 ds_two_plus = val_lim(1,3) ;
00406
00407 return res ;
00408 }