78#include "type_parite.h"
81#include "utilitaires.h"
96Mtbl_cf sol_poisson_compact(
const Mtbl_cf& source,
double a,
double b,
100 assert (source.get_etat() != ETATNONDEF) ;
106 const int nmax = 200 ;
108 static int nb_deja_fait = 0 ;
109 static int l_deja_fait[nmax] ;
110 static int n_deja_fait[nmax] ;
113 for (
int i=0 ; i<nb_deja_fait ; i++)
118 int nz = source.get_mg()->get_nzone() ;
121 int nr = source.get_mg()->get_nr(0) ;
122 int nt = source.get_mg()->get_nt(0) ;
123 int np = source.get_mg()->get_np(0) ;
130 Mtbl_cf solution(source.get_mg(), source.base) ;
131 solution.set_etat_qcq() ;
132 solution.t[0]->set_etat_qcq() ;
134 for (
int k=0 ; k<np+1 ; k++)
135 for (
int j=0 ; j<nt ; j++)
136 if (nullite_plm(j, nt, k, np, source.base) == 1)
139 donne_lm(nz, 0, j, k, source.base, m_quant, l_quant, base_r) ;
144 for (
int i=0 ; i<nr ; i++)
145 solution.set(0, k, j, i) = 0 ;
154 int taille = (l_quant == 1) ? nr : nr-1 ;
156 Matrice operateur (taille, taille) ;
157 for (
int conte=0 ; conte<nb_deja_fait ; conte++)
158 if ((l_deja_fait[conte]== l_quant) && (n_deja_fait[conte] == nr))
162 if (nb_deja_fait >= nmax) {
163 cout <<
"sol_poisson_compact : trop de matrices ..." << endl;
167 operateur = a*lap_cpt_mat (nr, l_quant, base_r)
168 + b*xdsdx_mat(nr, l_quant, base_r) ;
169 operateur = combinaison_cpt (operateur, l_quant, base_r) ;
171 l_deja_fait[nb_deja_fait] = l_quant ;
172 n_deja_fait[nb_deja_fait] = nr ;
173 tab_op[nb_deja_fait] =
new Matrice(operateur) ;
179 operateur = *tab_op[indice] ;
185 for (
int i=0 ; i<taille ; i++)
186 so.set(i) = source(0, k, j, i) ;
187 so = combinaison_cpt (so, base_r) ;
189 Tbl part (operateur.inverse(so)) ;
192 for (
int i=0 ; i<nr ; i++)
193 solution.set(0, k, j, i) = part(i) ;
195 solution.set(0, k, j, nr-1) = 0 ;
196 for (
int i=nr-2 ; i>=0 ; i--)
198 solution.set(0, k, j, i) = part(i) ;
199 solution.set(0, k, j, i+1) += part(i) ;
202 solution.set(0, k, j, i) = part(i)*(2*i+3) ;
203 solution.set(0, k, j, i+1) += part(i)*(2*i+1) ;
209 for (
int i=0 ; i<nr ; i++)
210 solution.set(0, k, j, i) = 0 ;
213 for (
int j=0; j<nt; j++)
214 for(
int i=0 ; i<nr ; i++)
215 solution.set(0, np+1, j, i) = 0 ;
217 for (
int zone=1 ; zone<nz ; zone++)
218 solution.t[zone]->set_etat_zero() ;
231 const Tbl& ac,
const Tbl& bc,
bool ) {
234 int nzet = ac.get_dim(1) ;
235 assert(nzet<=source.get_mg()->get_nzone()) ;
238 assert (source.get_mg()->get_type_r(0) == RARE) ;
239 for (
int l=1 ; l<nzet ; l++)
240 assert(source.get_mg()->get_type_r(l) == FIN) ;
243 const Base_val& base = source.base ;
246 Mtbl_cf resultat(source.get_mg(), base) ;
247 resultat.annule_hard() ;
252 double alpha, beta, echelle ;
253 int l_quant, m_quant;
258 for (
int l=0 ; l<nzet ; l++) {
259 nr = mapping.get_mg()->get_nr(l) ;
261 if (nr > max_nr) max_nr = nr ;
265 systeme.set_etat_qcq() ;
266 Tbl sec_membre (size) ;
268 soluce.set_etat_qcq() ;
270 np = mapping.get_mg()->get_np(0) ;
271 nt = mapping.get_mg()->get_nt(0) ;
275 for (
int k=0 ; k<np+1 ; k++)
276 for (
int j=0 ; j<nt ; j++)
277 if (nullite_plm(j, nt, k, np, base) == 1) {
279 systeme.annule_hard() ;
280 sec_membre.annule_hard() ;
282 int column_courant = 0 ;
283 int ligne_courant = 0 ;
289 nr = mapping.get_mg()->get_nr(0) ;
290 alpha = mapping.get_alpha()[0] ;
291 base.give_quant_numbers (0, k, j, m_quant, l_quant, base_r) ;
294 for (
int i=0 ; i<size ; i++)
306 work =
new Matrice( ac(0,0) * ( d2_n + 2.*sxd_n -l_quant*(l_quant+1)*sx2_n )
307 + ac(0,2) * ( x2d2_n + 2.*xd_n -l_quant*(l_quant+1)*id_n )
308 + alpha * bc(0,1) * xd_n ) ;
319 for (
int col=0 ; col<nr ; col++)
321 systeme.set(ligne_courant, col+column_courant) = 1 ;
323 systeme.set(ligne_courant, col+column_courant) = -1 ;
327 for (
int col=0 ; col<nr ; col++)
329 systeme.set(ligne_courant, col+column_courant) = 2*col+1 ;
331 systeme.set(ligne_courant, col+column_courant) = -(2*col+1) ;
337 for (
int lig=0 ; lig<nr-1-nbr_cl ; lig++) {
338 for (
int col=0 ; col<nr ; col++)
339 systeme.set(lig+ligne_courant,col+column_courant) = (*work)(lig,col) ;
340 sec_membre.set(lig+ligne_courant) = alpha*alpha*source(0, k, j, lig) ;
344 ligne_courant += nr-1-nbr_cl ;
347 for (
int col=0 ; col<nr ; col++) {
349 systeme.set(ligne_courant, col+column_courant) = 1 ;
352 systeme.set(ligne_courant+1, col+column_courant) = 4*col*col/alpha ;
354 systeme.set(ligne_courant+1, col+column_courant) = (2*col+1)*(2*col+1)/alpha ;
356 column_courant += nr ;
362 for (
int l=1 ; l<nzet ; l++) {
364 nr = mapping.get_mg()->get_nr(l) ;
365 alpha = mapping.get_alpha()[l] ;
366 beta = mapping.get_beta()[l] ;
367 echelle = beta/alpha ;
368 double bsa = echelle ;
369 double bsa2 = bsa*bsa ;
371 base.give_quant_numbers (l, k, j, m_quant, l_quant, base_r) ;
384 work =
new Matrice ( ac(l,0) * ( x2dx2 + 2.*bsa*xdx2 + bsa2*dx2 + 2.*xdx
385 + 2.*bsa*dx - l_quant*(l_quant+1)*
id )
386 + ac(l,1) * ( x3dx2 + 2.*bsa*x2dx2 + bsa2*xdx2 + 2.*x2dx
387 + 2.*bsa*xdx - l_quant*(l_quant+1) *mx )
388 + alpha * ( bc(l,0) * ( x2dx + 2.*bsa*xdx + bsa2*dx )
389 + bc(l,1) * ( x3dx + 2.*bsa*x2dx + bsa2*xdx ) ) ) ;
392 for (
int col=0 ; col<nr ; col++) {
395 systeme.set(ligne_courant, col+column_courant) = -1 ;
397 systeme.set(ligne_courant, col+column_courant) = 1 ;
400 systeme.set(ligne_courant+1, col+column_courant) = col*col/alpha ;
402 systeme.set(ligne_courant+1, col+column_courant) = -col*col/alpha ;
408 source_aux.set_etat_qcq() ;
409 for (
int i=0 ; i<nr ; i++)
410 source_aux.set(i) = source(l,k,j,i)*alpha*alpha ;
411 Tbl xso(source_aux) ;
412 Tbl xxso(source_aux) ;
413 multx_1d(nr, &xso.t,
R_CHEB) ;
414 multx_1d(nr, &xxso.t,
R_CHEB) ;
415 multx_1d(nr, &xxso.t,
R_CHEB) ;
416 source_aux = beta*beta/alpha/alpha*source_aux+2*beta/alpha*xso+xxso ;
420 for (
int lig=0 ; lig<nr-1 ; lig++) {
421 for (
int col=0 ; col<nr ; col++)
422 systeme.set(lig+ligne_courant,col+column_courant) = (*work)(lig,col) ;
423 sec_membre.set(lig+ligne_courant) = source_aux(lig) ;
430 ligne_courant += nr-2 ;
434 for (
int col=0 ; col<nr ; col++) {
436 systeme.set(ligne_courant, col+column_courant) = 1 ;
438 systeme.set(ligne_courant+1, col+column_courant) = col*col/alpha ;
442 column_courant += nr ;
451 systeme.set_band (size, size) ;
457 soluce = systeme.inverse(sec_membre) ;
466 for (
int l=0 ; l<nzet ; l++) {
467 nr = mapping.get_mg()->get_nr(l) ;
468 for (
int i=0 ; i<nr ; i++) {
469 resultat.set(l,k,j,i) = soluce(conte) ;
Bases of the spectral expansions.
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator Identity (see the base class Diff ).
Class for the elementary differential operator multiplication by (see the base class Diff ).
Class for the elementary differential operator division by (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Class for the elementary differential operator (see the base class Diff ).
Coefficients storage for the multi-domain spectral method.
#define R_CHEB
base de Chebychev ordinaire (fin)
#define R_CHEBP
base de Cheb. paire (rare) seulement