5 #include "utilitaires.h" 16 void tensorellipticCt( Scalar source, Scalar& resu,
double fit,
double fit2,
double fit0d2,
double fit1d2,
double fit0d3,
double fit1d3) {
19 const int nz = (*source.get_mp().get_mg()).get_nzone();
20 int nr = (*source.get_mp().get_mg()).get_nr(1);
21 int nt = (*source.get_mp().get_mg()).get_nt(1);
22 int np = (*source.get_mp().get_mg()).get_np(1);
23 const Map_af* map =
dynamic_cast<const Map_af*
>(&source.get_mp()) ;
24 const Mg3d* mgrid = (*map).get_mg();
30 const Coord& rr = (*map).r ;
33 rrr.set_spectral_va().set_base(source.get_spectral_va().base);
35 Scalar source_coq = source ;
38 source.set_spectral_va().ylm() ;
39 source_coq.set_spectral_va().ylm() ;
40 Scalar phi(source.get_mp()) ;
43 phi.set_spectral_va().set_base(source.get_spectral_va().base) ;
44 phi.set_spectral_va().ylm() ;
45 Mtbl_cf& sol_coef = (*phi.set_spectral_va().c_cf) ;
47 const Base_val& base = source.get_spectral_base() ;
48 Mtbl_cf sol_part(mgrid, base) ; sol_part.annule_hard() ;
49 Mtbl_cf sol_hom1(mgrid, base) ; sol_hom1.annule_hard() ;
50 Mtbl_cf sol_hom2(mgrid, base) ; sol_hom2.annule_hard() ;
52 int l_q, m_q, base_r ;
55 for (
int k=0; k < np; k++)
56 for (
int j=0; j<nt; j++) {
57 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
58 if (nullite_plm(j, nt, k, np, base) == 1) {
59 for (
int ii=0 ; ii<nr ; ii++){
60 sol_hom1.set(lz, k, j, ii) = 0 ;
61 sol_part.set(lz, k, j, ii) = 0 ;
70 double alpha = (*map).get_alpha()[lz] ;
71 double beta = (*map).get_beta()[lz] ;
72 double ech = beta / alpha ;
73 for (
int k=0; k < np; k++)
74 for (
int j=0; j<nt; j++) {
75 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
76 if (nullite_plm(j, nt, k, np, base) == 1) {
83 Diff_dsdx dx(base_r, nr) ;
const Matrice& mdx = dx.get_matrice() ;
84 Diff_dsdx2 dx2(base_r, nr) ;
const Matrice& mdx2 = dx2.get_matrice() ;
85 Diff_id id(base_r, nr) ;
const Matrice& mid =
id.get_matrice() ;
86 Diff_xdsdx xdx(base_r, nr) ;
const Matrice& mxdx = xdx.get_matrice() ;
87 Diff_xdsdx2 xdx2(base_r, nr) ;
const Matrice& mxdx2 = xdx2.get_matrice() ;
88 Diff_x2dsdx2 x2dx2(base_r, nr) ;
const Matrice& mx2dx2 = x2dx2.get_matrice() ;
89 Diff_x3dsdx2 x3dx2 (base_r, nr);
const Matrice& mx3dx2 = x3dx2.get_matrice();
90 Diff_x4dsdx2 x4dx2 (base_r, nr);
const Matrice& mx4dx2 = x4dx2.get_matrice();
105 ope = mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2 + 2*(mxdx + ech*mdx)
106 - l_q*(l_q+1)*mid -2*(l_q+1)*mid - ((mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) -(fit)*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) + (fit)*beta*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2)
107 + (fit)*alpha*(mx3dx2 + 2*ech*mx2dx2 + ech*ech*mxdx2) + fit2*alpha*alpha*(mx4dx2 + 2*ech*mx3dx2 + ech*ech*mx2dx2)
108 + fit2*alpha*(beta-1.)*(mx3dx2 + 2*ech*mx2dx2 + ech*ech*mxdx2) + fit2*alpha*(beta- rrr.val_grid_point(1,0,0, nr-1))*(mx3dx2 + 2*ech*mx2dx2 + ech*ech*mxdx2)+ fit2*(beta-1.)*(beta- rrr.val_grid_point(1,0,0,nr -1))*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2));
113 for (
int col=0; col<nr; col++)
114 ope.set(nr-1, col) = 0 ;
115 ope.set(nr-1, 0) = 1 ;
120 for (
int i=0; i<nr; i++)
121 rhs.set(i) = (*source_coq.get_spectral_va().c_cf)(1, k, j, i) ;
124 Tbl sol = ope.inverse(rhs) ;
127 for (
int i=0; i<nr; i++)
128 sol_part.set(1, k, j, i) = sol(i) ;
132 sol = ope.inverse(rhs) ;
135 for (
int i=0; i<nr; i++)
136 sol_hom1.set(1, k, j, i) = sol(i) ;
150 double alpha = (*map).get_alpha()[lz] ;
151 double beta = (*map).get_beta()[lz] ;
152 double ech = beta / alpha ;
154 for (
int k=0; k < np; k++)
155 for (
int j=0; j<nt; j++) {
156 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
157 if (nullite_plm(j, nt, k, np, base) == 1) {
162 Diff_dsdx dx(base_r, nr) ;
const Matrice& mdx = dx.get_matrice() ;
163 Diff_dsdx2 dx2(base_r, nr) ;
const Matrice& mdx2 = dx2.get_matrice() ;
164 Diff_id id(base_r, nr) ;
const Matrice& mid =
id.get_matrice() ;
165 Diff_xdsdx xdx(base_r, nr) ;
const Matrice& mxdx = xdx.get_matrice() ;
166 Diff_xdsdx2 xdx2(base_r, nr) ;
const Matrice& mxdx2 = xdx2.get_matrice() ;
167 Diff_x2dsdx2 x2dx2(base_r, nr) ;
const Matrice& mx2dx2 = x2dx2.get_matrice() ;
168 Diff_x3dsdx2 x3dx2 (base_r, nr);
const Matrice& mx3dx2 = x3dx2.get_matrice();
170 ope = mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2 + 2*(mxdx + ech*mdx)
171 - l_q*(l_q+1)*mid -2*(l_q+1)*mid - fit0d2*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) + (fit1d2)*(rrr.val_grid_point(lz, 0, 0, 0))*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) - (fit1d2)*beta*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) - (fit1d2)*alpha*(mx3dx2 + 2*ech*mx2dx2 + ech*ech*mxdx2) ;
178 for (
int col=0; col<nr; col++)
179 ope.set(nr-1, col) = 0 ;
180 ope.set(nr-1, 0) = 1 ;
181 for (
int col=0; col<nr; col++) {
182 ope.set(nr-2, col) = 0 ;
184 ope.set(nr-2, 1) = 1 ;
188 for (
int i=0; i<nr; i++)
189 rhs.set(i) = (*source_coq.get_spectral_va().c_cf)(lz, k, j, i) ;
193 Tbl sol = ope.inverse(rhs) ;
195 for (
int i=0; i<nr; i++)
196 sol_part.set(lz, k, j, i) = sol(i) ;
200 sol = ope.inverse(rhs) ;
201 for (
int i=0; i<nr; i++)
202 sol_hom1.set(lz, k, j, i) = sol(i) ;
206 sol = ope.inverse(rhs) ;
207 for (
int i=0; i<nr; i++)
208 sol_hom2.set(lz, k, j, i) = sol(i) ;
219 double alpha = (*map).get_alpha()[lz] ;
220 double beta = (*map).get_beta()[lz] ;
221 double ech = beta / alpha ;
223 for (
int k=0; k < np; k++)
224 for (
int j=0; j<nt; j++) {
225 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
226 if (nullite_plm(j, nt, k, np, base) == 1) {
231 Diff_dsdx dx(base_r, nr) ;
const Matrice& mdx = dx.get_matrice() ;
232 Diff_dsdx2 dx2(base_r, nr) ;
const Matrice& mdx2 = dx2.get_matrice() ;
233 Diff_id id(base_r, nr) ;
const Matrice& mid =
id.get_matrice() ;
234 Diff_xdsdx xdx(base_r, nr) ;
const Matrice& mxdx = xdx.get_matrice() ;
235 Diff_xdsdx2 xdx2(base_r, nr) ;
const Matrice& mxdx2 = xdx2.get_matrice() ;
236 Diff_x2dsdx2 x2dx2(base_r, nr) ;
const Matrice& mx2dx2 = x2dx2.get_matrice() ;
237 Diff_x3dsdx2 x3dx2 (base_r, nr);
const Matrice& mx3dx2 = x3dx2.get_matrice();
239 ope = mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2 + 2*(mxdx + ech*mdx)
240 - l_q*(l_q+1)*mid -2*(l_q+1)*mid - fit0d3*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) + (fit1d3)*(rrr.val_grid_point(lz, 0, 0, 0))*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) - (fit1d3)*beta*(mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2) - (fit1d3)*alpha*(mx3dx2 + 2*ech*mx2dx2 + ech*ech*mxdx2) ;
246 for (
int col=0; col<nr; col++)
247 ope.set(nr-1, col) = 0 ;
248 ope.set(nr-1, 0) = 1 ;
249 for (
int col=0; col<nr; col++) {
250 ope.set(nr-2, col) = 0 ;
252 ope.set(nr-2, 1) = 1 ;
256 for (
int i=0; i<nr; i++)
257 rhs.set(i) = (*source_coq.get_spectral_va().c_cf)(lz, k, j, i) ;
261 Tbl sol = ope.inverse(rhs) ;
263 for (
int i=0; i<nr; i++)
264 sol_part.set(lz, k, j, i) = sol(i) ;
268 sol = ope.inverse(rhs) ;
269 for (
int i=0; i<nr; i++)
270 sol_hom1.set(lz, k, j, i) = sol(i) ;
274 sol = ope.inverse(rhs) ;
275 for (
int i=0; i<nr; i++)
276 sol_hom2.set(lz, k, j, i) = sol(i) ;
287 for (
int lz=4; lz<nz-1; lz++) {
288 double ech = (*map).get_beta()[lz] / (*map).get_alpha()[lz] ;
289 for (
int k=0; k < np; k++)
290 for (
int j=0; j<nt; j++) {
291 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
292 if (nullite_plm(j, nt, k, np, base) == 1) {
297 Diff_dsdx dx(base_r, nr) ;
const Matrice& mdx = dx.get_matrice() ;
298 Diff_dsdx2 dx2(base_r, nr) ;
const Matrice& mdx2 = dx2.get_matrice() ;
299 Diff_id id(base_r, nr) ;
const Matrice& mid =
id.get_matrice() ;
300 Diff_xdsdx xdx(base_r, nr) ;
const Matrice& mxdx = xdx.get_matrice() ;
301 Diff_xdsdx2 xdx2(base_r, nr) ;
const Matrice& mxdx2 = xdx2.get_matrice() ;
302 Diff_x2dsdx2 x2dx2(base_r, nr) ;
const Matrice& mx2dx2 = x2dx2.get_matrice() ;
303 ope = mx2dx2 + 2*ech*mxdx2 + ech*ech*mdx2 + 2*(mxdx + ech*mdx)
304 - l_q*(l_q+1)*mid -2*(l_q+1)*mid;
306 for (
int col=0; col<nr; col++)
307 ope.set(nr-1, col) = 0 ;
308 ope.set(nr-1, 0) = 1 ;
309 for (
int col=0; col<nr; col++) {
310 ope.set(nr-2, col) = 0 ;
312 ope.set(nr-2, 1) = 1 ;
316 for (
int i=0; i<nr; i++)
317 rhs.set(i) = (*source_coq.get_spectral_va().c_cf)(lz, k, j, i) ;
321 Tbl sol = ope.inverse(rhs) ;
323 for (
int i=0; i<nr; i++)
324 sol_part.set(lz, k, j, i) = sol(i) ;
328 sol = ope.inverse(rhs) ;
329 for (
int i=0; i<nr; i++)
330 sol_hom1.set(lz, k, j, i) = sol(i) ;
334 sol = ope.inverse(rhs) ;
335 for (
int i=0; i<nr; i++)
336 sol_hom2.set(lz, k, j, i) = sol(i) ;
343 double alpha = (*map).get_alpha()[lz] ;
344 for (
int k=0; k < np; k++)
345 for (
int j=0; j<nt; j++) {
346 base.give_quant_numbers(lz, k, j, m_q, l_q, base_r) ;
347 if (nullite_plm(j, nt, k, np, base) == 1) {
351 Diff_dsdx2 dx2(base_r, nr) ;
const Matrice& mdx2 = dx2.get_matrice() ;
352 Diff_sx2 sx2(base_r, nr) ;
const Matrice& ms2 = sx2.get_matrice() ;
354 ope = (mdx2 - l_q*(l_q+1)*ms2 -2*(l_q+1)*ms2)/(alpha*alpha) ;
356 for (
int i=0; i<nr; i++)
357 ope.set(nr-1, i) = 0 ;
358 ope.set(nr-1, 0) = 1 ;
360 for (
int i=0; i<nr; i++) {
361 ope.set(nr-2, i) = 1 ;
365 for (
int i=0; i<nr; i++) {
366 ope.set(nr-3, i) = i*i ;
373 for (
int i=0; i<nr; i++)
374 rhs.set(i) = (*source.get_spectral_va().c_cf)(lz, k, j, i) ;
375 if (l_q>0) rhs.set(nr-3) = 0 ;
379 Tbl sol = ope.inverse(rhs) ;
381 for (
int i=0; i<nr; i++)
382 sol_part.set(lz, k, j, i) = sol(i) ;
386 sol = ope.inverse(rhs) ;
387 for (
int i=0; i<nr; i++)
388 sol_hom2.set(lz, k, j, i) = sol(i) ;
394 Mtbl_cf dpart = sol_part ; dpart.dsdx() ;
395 Mtbl_cf dhom1 = sol_hom1 ; dhom1.dsdx() ;
396 Mtbl_cf dhom2 = sol_hom2 ; dhom2.dsdx() ;
411 for (
int k=0; k < np; k++)
412 for (
int j=0; j<nt; j++) {
413 base.give_quant_numbers(0, k, j, m_q, l_q, base_r) ;
414 if (nullite_plm(j, nt, k, np, base) == 1) {
415 Matrice systeme(2*nz-4, 2*nz-4) ;
416 systeme.annule_hard() ;
424 double alpha = (*map).get_alpha()[1] ;
426 systeme.set(lin, col) += sol_hom1.val_out_bound_jk(1, j, k) ;
427 rhs.set(lin) -= sol_part.val_out_bound_jk(1, j, k) ;
430 systeme.set(lin, col) += dhom1.val_out_bound_jk(1, j, k) / alpha ;
431 rhs.set(lin) -= dpart.val_out_bound_jk(1, j, k) / alpha ;
435 for (
int lz=2; lz<nz-1; lz++) {
436 alpha = (*map).get_alpha()[lz] ;
438 systeme.set(lin,col) -= sol_hom1.val_in_bound_jk(lz, j, k) ;
439 systeme.set(lin,col+1) -= sol_hom2.val_in_bound_jk(lz, j, k) ;
440 rhs.set(lin) += sol_part.val_in_bound_jk(lz, j, k) ;
443 systeme.set(lin,col) -= dhom1.val_in_bound_jk(lz, j, k) / alpha ;
444 systeme.set(lin,col+1) -= dhom2.val_in_bound_jk(lz, j, k) / alpha ;
445 rhs.set(lin) += dpart.val_in_bound_jk(lz, j, k) / alpha;
448 systeme.set(lin, col) += sol_hom1.val_out_bound_jk(lz, j, k) ;
449 systeme.set(lin, col+1) += sol_hom2.val_out_bound_jk(lz, j, k) ;
450 rhs.set(lin) -= sol_part.val_out_bound_jk(lz, j, k) ;
453 systeme.set(lin, col) += dhom1.val_out_bound_jk(lz, j, k) / alpha ;
454 systeme.set(lin, col+1) += dhom2.val_out_bound_jk(lz, j, k) / alpha ;
455 rhs.set(lin) -= dpart.val_out_bound_jk(lz, j, k) / alpha ;
460 alpha = (*map).get_alpha()[nz-1] ;
462 systeme.set(lin,col) -= sol_hom2.val_in_bound_jk(nz-1, j, k) ;
463 rhs.set(lin) += sol_part.val_in_bound_jk(nz-1, j, k) ;
466 systeme.set(lin,col) -= (-4*alpha)*dhom2.val_in_bound_jk(nz-1, j, k) ;
467 rhs.set(lin) += (-4*alpha)*dpart.val_in_bound_jk(nz-1, j, k) ;
473 Tbl coef = systeme.inverse(rhs);
481 for (
int i=0; i<(*mgrid).get_nr(1); i++)
482 sol_coef.set(1, k, j, i) = sol_part(1, k, j, i)
483 +coef(indice)*sol_hom1(1, k, j, i) ;
487 for (
int lz=2; lz<nz-1; lz++) {
488 for (
int i=0; i<(*mgrid).get_nr(lz); i++)
489 sol_coef.set(lz, k, j, i) = sol_part(lz, k, j, i)
490 +coef(indice)*sol_hom1(lz, k, j, i)
491 +coef(indice+1)*sol_hom2(lz, k, j, i) ;
494 for (
int i=0; i<(*mgrid).get_nr(nz-1); i++)
495 sol_coef.set(nz-1, k, j, i) = sol_part(nz-1, k, j, i)
496 +coef(indice)*sol_hom2(nz-1, k, j, i) ;
510 for (
int lz=0; lz<nz; lz++) {
511 for (
int i=0; i<(*mgrid).get_nr(lz); i++)
513 sol_coef.set(lz,0,0,i) = 0.;
528 delete phi.set_spectral_va().c ;
529 phi.set_spectral_va().c = 0x0 ;
533 phi.annule_domain(nz-1);