00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 char ope_poisson_pseudo_1d_solp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_solp.C,v 1.1 2004/08/24 09:14:48 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 _cl_poisson_pseudo_1d_pas_prevu (const Tbl &source) {
00039 cout << "Combinaison lineaire pas prevue..." << endl ;
00040 abort() ;
00041 exit(-1) ;
00042 return source;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051 Tbl _cl_poisson_pseudo_1d_r_cheb (const Tbl &source) {
00052 Tbl barre(source) ;
00053 int n = source.get_dim(0) ;
00054
00055 int dirac = 1 ;
00056 for (int i=0 ; i<n-2 ; i++) {
00057 barre.set(i) = ((1+dirac)*source(i)-source(i+2))
00058 /(i+1) ;
00059 if (i==0) dirac = 0 ;
00060 }
00061
00062 Tbl res(barre) ;
00063 for (int i=0 ; i<n-4 ; i++)
00064 res.set(i) = barre(i)-barre(i+2) ;
00065 return res ;
00066 }
00067
00068
00069
00070
00071
00072 Tbl _cl_poisson_pseudo_1d_r_chebp (const Tbl &source) {
00073 Tbl barre(source) ;
00074 int n = source.get_dim(0) ;
00075
00076 int dirac = 1 ;
00077 for (int i=0 ; i<n-2 ; i++) {
00078 barre.set(i) = (1+dirac)*source(i)-source(i+2) ;
00079 if (i==0) dirac = 0 ;
00080 }
00081
00082 Tbl tilde(barre) ;
00083 for (int i=0 ; i<n-4 ; i++)
00084 tilde.set(i) = barre(i)-barre(i+2) ;
00085
00086 Tbl res(tilde) ;
00087 for (int i=0 ; i<n-4 ; i++)
00088 res.set(i) = tilde(i)-tilde(i+1) ;
00089
00090 return res ;
00091 }
00092
00093
00094
00095
00096
00097
00098 Tbl _cl_poisson_pseudo_1d_r_chebi (const Tbl &source) {
00099 Tbl barre(source) ;
00100 int n = source.get_dim(0) ;
00101
00102 for (int i=0 ; i<n-2 ; i++)
00103 barre.set(i) = source(i)-source(i+2) ;
00104
00105 Tbl tilde(barre) ;
00106 for (int i=0 ; i<n-4 ; i++)
00107 tilde.set(i) = barre(i)-barre(i+2) ;
00108
00109 Tbl res(tilde) ;
00110 for (int i=0 ; i<n-4 ; i++)
00111 res.set(i) = tilde(i)-tilde(i+1) ;
00112
00113 return res ;
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123 Tbl cl_poisson_pseudo_1d (const Tbl &source, int base_r) {
00124
00125
00126 static Tbl (*cl_poisson_pseudo_1d[MAX_BASE])(const Tbl &) ;
00127 static int nap = 0 ;
00128
00129
00130 if (nap==0) {
00131 nap = 1 ;
00132 for (int i=0 ; i<MAX_BASE ; i++) {
00133 cl_poisson_pseudo_1d[i] = _cl_poisson_pseudo_1d_pas_prevu ;
00134 }
00135
00136 cl_poisson_pseudo_1d[R_CHEB >> TRA_R] = _cl_poisson_pseudo_1d_r_cheb ;
00137 cl_poisson_pseudo_1d[R_CHEBP >> TRA_R] = _cl_poisson_pseudo_1d_r_chebp ;
00138 cl_poisson_pseudo_1d[R_CHEBI >> TRA_R] = _cl_poisson_pseudo_1d_r_chebi ;
00139 }
00140
00141 Tbl res(cl_poisson_pseudo_1d[base_r](source)) ;
00142 return res ;
00143 }
00144
00145
00146
00147
00148
00149 Tbl _solp_poisson_pseudo_1d_pas_prevu (const Matrice &, const Matrice &,
00150 double, double, const Tbl &) {
00151 cout << " Solution homogene pas prevue ..... : "<< endl ;
00152 abort() ;
00153 exit(-1) ;
00154 Tbl res(1) ;
00155 return res;
00156 }
00157
00158
00159
00160
00161
00162
00163 Tbl _solp_poisson_pseudo_1d_r_cheb (const Matrice &lap,
00164 const Matrice &nondege,
00165 double alpha, double beta,
00166 const Tbl &source) {
00167
00168 int n = lap.get_dim(0) ;
00169 int dege = n-nondege.get_dim(0) ;
00170 assert (dege ==2) ;
00171
00172 Tbl source_aux(source*alpha*alpha) ;
00173 Tbl xso(source_aux) ;
00174 Tbl xxso(source_aux) ;
00175 multx_1d(n, &xso.t, R_CHEB) ;
00176 multx_1d(n, &xxso.t, R_CHEB) ;
00177 multx_1d(n, &xxso.t, R_CHEB) ;
00178 source_aux = beta*beta/alpha/alpha*source_aux+2*beta/alpha*xso+xxso ;
00179 source_aux = cl_poisson_pseudo_1d(source_aux, R_CHEB) ;
00180
00181 Tbl so(n-dege) ;
00182 so.set_etat_qcq() ;
00183 for (int i=0 ; i<n-dege ; i++)
00184 so.set(i) = source_aux(i) ;
00185
00186 Tbl auxi(nondege.inverse(so)) ;
00187
00188 Tbl res(n) ;
00189 res.set_etat_qcq() ;
00190 for (int i=dege ; i<n ; i++)
00191 res.set(i) = auxi(i-dege) ;
00192
00193 for (int i=0 ; i<dege ; i++)
00194 res.set(i) = 0 ;
00195 return res ;
00196 }
00197
00198
00199
00200
00201
00202
00203 Tbl _solp_poisson_pseudo_1d_r_chebp (const Matrice &lap,
00204 const Matrice &nondege,
00205 double alpha, double , const Tbl &source) {
00206
00207 int n = lap.get_dim(0) ;
00208 int dege = n-nondege.get_dim(0) ;
00209 assert ((dege==2) || (dege == 1)) ;
00210 Tbl source_aux(alpha*alpha*source) ;
00211 source_aux = cl_poisson_pseudo_1d(source_aux, R_CHEBP) ;
00212
00213 Tbl so(n-dege) ;
00214 so.set_etat_qcq() ;
00215 for (int i=0 ; i<n-dege ; i++)
00216 so.set(i) = source_aux(i);
00217
00218 Tbl auxi(nondege.inverse(so)) ;
00219
00220 Tbl res(n) ;
00221 res.set_etat_qcq() ;
00222 for (int i=dege ; i<n ; i++)
00223 res.set(i) = auxi(i-dege) ;
00224
00225 for (int i=0 ; i<dege ; i++)
00226 res.set(i) = 0 ;
00227
00228 if (dege==2) {
00229 double somme = 0 ;
00230 for (int i=0 ; i<n ; i++)
00231 if (i%2 == 0)
00232 somme -= res(i) ;
00233 else somme += res(i) ;
00234 res.set(0) = somme ;
00235 return res ;
00236 }
00237 else return res ;
00238 }
00239
00240
00241
00242
00243
00244
00245 Tbl _solp_poisson_pseudo_1d_r_chebi (const Matrice &lap,
00246 const Matrice &nondege,
00247 double alpha, double, const Tbl &source) {
00248
00249
00250 int n = lap.get_dim(0) ;
00251 int dege = n-nondege.get_dim(0) ;
00252 assert ((dege==2) || (dege == 1)) ;
00253 Tbl source_aux(source*alpha*alpha) ;
00254 source_aux = cl_poisson_pseudo_1d(source_aux, R_CHEBI) ;
00255
00256 Tbl so(n-dege) ;
00257 so.set_etat_qcq() ;
00258 for (int i=0 ; i<n-dege ; i++)
00259 so.set(i) = source_aux(i);
00260
00261 Tbl auxi(nondege.inverse(so)) ;
00262
00263 Tbl res(n) ;
00264 res.set_etat_qcq() ;
00265 for (int i=dege ; i<n ; i++)
00266 res.set(i) = auxi(i-dege) ;
00267
00268 for (int i=0 ; i<dege ; i++)
00269 res.set(i) = 0 ;
00270
00271 if (dege==2) {
00272 double somme = 0 ;
00273 for (int i=0 ; i<n ; i++)
00274 if (i%2 == 0)
00275 somme -= (2*i+1)*res(i) ;
00276 else somme += (2*i+1)*res(i) ;
00277 res.set(0) = somme ;
00278 return res ;
00279 }
00280 else return res ;
00281 }
00282
00283
00284 Tbl Ope_poisson_pseudo_1d::get_solp (const Tbl& so) const {
00285
00286 if (non_dege == 0x0)
00287 do_non_dege() ;
00288
00289
00290 static Tbl (*solp_poisson_pseudo_1d[MAX_BASE]) (const Matrice&,
00291 const Matrice&,
00292 double, double,const Tbl&) ;
00293 static int nap = 0 ;
00294
00295
00296 if (nap==0) {
00297 nap = 1 ;
00298 for (int i=0 ; i<MAX_BASE ; i++) {
00299 solp_poisson_pseudo_1d[i] = _solp_poisson_pseudo_1d_pas_prevu ;
00300 }
00301
00302 solp_poisson_pseudo_1d[R_CHEB >> TRA_R] = _solp_poisson_pseudo_1d_r_cheb ;
00303 solp_poisson_pseudo_1d[R_CHEBP >> TRA_R] = _solp_poisson_pseudo_1d_r_chebp ;
00304 solp_poisson_pseudo_1d[R_CHEBI >> TRA_R] = _solp_poisson_pseudo_1d_r_chebi ;
00305 }
00306
00307 Tbl res(solp_poisson_pseudo_1d[base_r] (*ope_mat, *non_dege,
00308 alpha, beta, so)) ;
00309
00310 Tbl valeurs (val_solp (res, alpha, base_r)) ;
00311 valeurs *= sqrt(double(2)) ;
00312 sp_plus = valeurs(0) ;
00313 sp_minus = valeurs(1) ;
00314 dsp_plus = valeurs(2) ;
00315 dsp_minus = valeurs(3) ;
00316
00317 return res ;
00318 }