| 1 |
//standard |
| 2 |
#include <cstdlib> |
| 3 |
#include <cmath> |
| 4 |
|
| 5 |
|
| 6 |
// Headers Lorene : |
| 7 |
#include "nbr_spx.h" |
| 8 |
#include "tensor.h" |
| 9 |
#include "cmp.h" |
| 10 |
#include "utilitaires.h" |
| 11 |
|
| 12 |
using namespace Lorene ; |
| 13 |
|
| 14 |
int main() { |
| 15 |
|
| 16 |
int nz = 2 ; |
| 17 |
double R = 2. ; |
| 18 |
|
| 19 |
int nr0 = 9 ; int nt0 = 5; int np0 = 4 ; |
| 20 |
|
| 21 |
// echantillonnage en phi : |
| 22 |
int* np = new int [nz] ; |
| 23 |
for (int l=0 ; l<nz ; l++) |
| 24 |
np[l] = np0 ; |
| 25 |
int type_p = SYM ; |
| 26 |
|
| 27 |
// echantillonnage en theta : |
| 28 |
int* nt = new int [nz] ; |
| 29 |
for (int l=0 ; l<nz ; l++) |
| 30 |
nt[l] = nt0 ; |
| 31 |
int type_t = SYM ; |
| 32 |
|
| 33 |
int* type_r = new int[nz] ; |
| 34 |
type_r[0] = RARE ; |
| 35 |
for (int l=1 ; l<nz ; l++) |
| 36 |
type_r[l] = FIN ; |
| 37 |
|
| 38 |
type_r[nz-1] = UNSURR ; |
| 39 |
|
| 40 |
// Construction de la grille |
| 41 |
|
| 42 |
// echantillonage en r : |
| 43 |
int* nr = new int [nz] ; |
| 44 |
for (int l=0 ; l<nz ; l++) |
| 45 |
nr[l] = nr0 ; |
| 46 |
nr[0] = nr0/2 + 1 ; |
| 47 |
|
| 48 |
Mg3d grille (nz, nr, type_r, nt, type_t, np, type_p) ; |
| 49 |
|
| 50 |
//Construction du mapping : |
| 51 |
double* bornes = new double[nz+1] ; |
| 52 |
for (int i=0 ; i<nz ; i++) |
| 53 |
bornes[i] = R*double(i)/double(nz - 1) ; |
| 54 |
bornes[nz] = __infinity ; |
| 55 |
Map_af mapping(grille, bornes) ; |
| 56 |
|
| 57 |
Scalar essai(mapping) ; |
| 58 |
|
| 59 |
essai = 1 ; |
| 60 |
|
| 61 |
Scalar deux = essai + 5 ; |
| 62 |
|
| 63 |
essai = deux ; |
| 64 |
|
| 65 |
FILE* fich = fopen("res.d", "w") ; |
| 66 |
|
| 67 |
grille.sauve(fich) ; |
| 68 |
mapping.sauve(fich) ; |
| 69 |
essai.sauve(fich) ; |
| 70 |
|
| 71 |
fclose(fich) ; |
| 72 |
|
| 73 |
fich = fopen("res.d", "r") ; |
| 74 |
|
| 75 |
Mg3d mg1(fich) ; |
| 76 |
Map_af mp1(mg1, fich) ; |
| 77 |
|
| 78 |
Scalar scalfich(mapping, grille, fich) ; |
| 79 |
|
| 80 |
fclose(fich) ; |
| 81 |
|
| 82 |
Tensor num(mapping, 1, COV, mapping.get_bvect_spher()) ; |
| 83 |
|
| 84 |
Itbl ind(1) ; |
| 85 |
|
| 86 |
ind.set_etat_qcq() ; |
| 87 |
ind.set(0) = 1 ; |
| 88 |
|
| 89 |
num.set(ind) = essai ; |
| 90 |
|
| 91 |
cout << num ; |
| 92 |
|
| 93 |
Cmp cuu(mapping) ; |
| 94 |
Cmp theo(mapping) ; |
| 95 |
Coord& rr = mapping.r ; |
| 96 |
Coord& zz = mapping.z ; |
| 97 |
|
| 98 |
cuu = exp(-rr*rr) ; |
| 99 |
cuu.std_base_scal() ; |
| 100 |
essai = cuu ; |
| 101 |
|
| 102 |
theo = -2*zz*exp(-rr*rr) ; |
| 103 |
theo.va.set_base_r(0,R_CHEBI) ; |
| 104 |
theo.va.set_base_r(1,R_CHEBU) ; |
| 105 |
theo.va.set_base_t(T_COS_I) ; |
| 106 |
theo.va.set_base_p(P_COSSIN_P) ; |
| 107 |
theo.inc2_dzpuis() ; |
| 108 |
scalfich = theo ; |
| 109 |
|
| 110 |
Scalar resu = scalfich - essai.dsdz() ; |
| 111 |
resu.spectral_display("resu", 1.e-10) ; |
| 112 |
|
| 113 |
arrete() ; |
| 114 |
|
| 115 |
Vector vv(mapping, COV, mapping.get_bvect_spher() ) ; |
| 116 |
vv = num ; |
| 117 |
|
| 118 |
cout << vv ; |
| 119 |
|
| 120 |
Sym_tensor tt(mapping, CON, mapping.get_bvect_cart() ) ; |
| 121 |
|
| 122 |
cout << tt ; |
| 123 |
|
| 124 |
fich = fopen("res2.d", "w") ; |
| 125 |
|
| 126 |
grille.sauve(fich) ; |
| 127 |
mapping.sauve(fich) ; |
| 128 |
num.sauve(fich) ; |
| 129 |
|
| 130 |
fclose(fich) ; |
| 131 |
|
| 132 |
fich = fopen("res2.d", "r") ; |
| 133 |
|
| 134 |
Mg3d mg2(fich) ; |
| 135 |
Map_af mp2(mg2, fich) ; |
| 136 |
|
| 137 |
Vector toto(mapping, mapping.get_bvect_spher(), fich) ; |
| 138 |
|
| 139 |
fclose(fich) ; |
| 140 |
|
| 141 |
|
| 142 |
delete [] bornes ; |
| 143 |
delete [] nr ; |
| 144 |
delete [] nt ; |
| 145 |
delete [] np ; |
| 146 |
delete [] type_r ; |
| 147 |
|
| 148 |
return EXIT_SUCCESS ; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|