| 1 |
#include "scalar.h" |
| 2 |
#include "monopole.h" |
| 3 |
#include "param_elliptic.h" |
| 4 |
#include "graphique.h" |
| 5 |
|
| 6 |
int Monopole::solve_config(double precis, int itemax, double relax) { |
| 7 |
|
| 8 |
double erreur ; |
| 9 |
int ite = 1 ; |
| 10 |
|
| 11 |
init_big_W() ; |
| 12 |
init_big_H() ; |
| 13 |
do_small_h() ; |
| 14 |
do_small_w() ; |
| 15 |
|
| 16 |
Scalar big_W_old(mp) ; |
| 17 |
Scalar big_H_old(mp) ; |
| 18 |
|
| 19 |
Scalar source_W (compute_source_W()) ; |
| 20 |
Scalar source_H (compute_source_H()) ; |
| 21 |
|
| 22 |
Param_elliptic param_W (source_W) ; |
| 23 |
|
| 24 |
Scalar F_W (mp) ; |
| 25 |
F_W = 1 ; |
| 26 |
F_W.std_spectral_base() ; |
| 27 |
F_W.annule(1, nz-1) ; |
| 28 |
param_W.set_variable_F(F_W) ; |
| 29 |
|
| 30 |
Scalar G_W (mp) ; |
| 31 |
G_W = 1 ; |
| 32 |
G_W.std_spectral_base() ; |
| 33 |
Scalar copie(G_W) ; |
| 34 |
G_W.mult_r() ; |
| 35 |
G_W.annule(1, nz-1) ; |
| 36 |
copie.annule_domain(0) ; |
| 37 |
G_W += copie ; |
| 38 |
param_W.set_variable_G(G_W) ; |
| 39 |
|
| 40 |
param_W.inc_l_quant(0) ; |
| 41 |
for (int i=1 ; i<nz ; i++) |
| 42 |
param_W.set_helmholtz_minus (i, 1., source_W) ; |
| 43 |
|
| 44 |
Param_elliptic param_H (source_H) ; |
| 45 |
|
| 46 |
Scalar F_H (mp) ; |
| 47 |
F_H = 1 ; |
| 48 |
F_H.std_spectral_base() ; |
| 49 |
F_H.annule(0, nz-2) ; |
| 50 |
param_H.set_variable_F (F_H) ; |
| 51 |
param_H.inc_l_quant(0) ; |
| 52 |
for (int i=1 ; i<nz ; i++) |
| 53 |
param_H.set_helmholtz_minus (i, beta, source_H) ; |
| 54 |
|
| 55 |
do { |
| 56 |
big_W_old = big_W ; |
| 57 |
big_H_old = big_H ; |
| 58 |
|
| 59 |
do_small_w() ; |
| 60 |
do_small_h() ; |
| 61 |
|
| 62 |
source_W = compute_source_W() ; |
| 63 |
small_w = source_W.sol_elliptic(param_W) ; |
| 64 |
do_big_W() ; |
| 65 |
big_W = relax*big_W + (1-relax)*big_W_old ; |
| 66 |
|
| 67 |
source_H = compute_source_H() ; |
| 68 |
small_h = source_H.sol_elliptic(param_H) ; |
| 69 |
do_big_H() ; |
| 70 |
big_H = relax*big_H + (1-relax)*big_H_old ; |
| 71 |
|
| 72 |
erreur = max(diffrelmax(big_W, big_W_old)) ; |
| 73 |
cout << "Iteration " << ite << " : " << erreur << endl ; |
| 74 |
ite ++ ; |
| 75 |
} |
| 76 |
while ((erreur > precis) && (ite < itemax)) ; |
| 77 |
return ite ; |
| 78 |
} |