00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 char scalar_import_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_import.C,v 1.3 2003/10/10 15:57:29 j_novak Exp $" ;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include <math.h>
00051
00052
00053 #include "tensor.h"
00054 #include "param.h"
00055 #include "nbr_spx.h"
00056
00057
00058
00059
00060
00061 void Scalar::import(const Scalar& ci) {
00062
00063 int nz = mp->get_mg()->get_nzone() ;
00064
00065 import(nz, ci) ;
00066
00067 }
00068
00069
00070
00071
00072
00073 void Scalar::import(int nzet, const Scalar& cm_d) {
00074
00075 const Map* mp_d = &(cm_d.get_mp()) ;
00076
00077
00078
00079
00080 if (mp_d == mp) {
00081 *this = cm_d ;
00082 return ;
00083 }
00084
00085
00086
00087
00088 int align_rel = (mp->get_bvect_cart()).get_align()
00089 * (mp_d->get_bvect_cart()).get_align() ;
00090
00091 switch (align_rel) {
00092
00093 case 1 : {
00094 import_align(nzet, cm_d) ;
00095 break ;
00096 }
00097
00098 case -1 : {
00099 import_anti(nzet, cm_d) ;
00100 break ;
00101 }
00102
00103 case 0 : {
00104 import_gal(nzet, cm_d) ;
00105 break ;
00106 }
00107
00108 default : {
00109 cout << "Scalar::import : unexpected value of align_rel : "
00110 << align_rel << endl ;
00111 abort() ;
00112 break ;
00113 }
00114
00115 }
00116
00117 }
00118
00119
00120
00121
00122
00123
00124 void Scalar::import_gal(int nzet, const Scalar& cm_d) {
00125
00126 const Map* mp_d = &(cm_d.get_mp()) ;
00127
00128
00129
00130
00131 if (mp_d == mp) {
00132 *this = cm_d ;
00133 return ;
00134 }
00135
00136
00137
00138
00139 if (cm_d.get_etat() == ETATZERO) {
00140 set_etat_zero() ;
00141 return ;
00142 }
00143
00144 if (cm_d.get_etat() == ETATUN) {
00145 set_etat_one() ;
00146 return ;
00147 }
00148
00149
00150
00151
00152 assert(cm_d.get_etat() != ETATNONDEF) ;
00153
00154 if (cm_d.get_dzpuis() != 0) {
00155 cout <<
00156 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00157 << endl ;
00158 abort() ;
00159 }
00160
00161
00162 const Mg3d* mg_a = mp->get_mg() ;
00163 int nz_a = mg_a->get_nzone() ;
00164 assert(nzet <= nz_a) ;
00165
00166
00167
00168
00169 assert(cm_d.get_etat() == ETATQCQ) ;
00170 const Valeur& va_d = cm_d.get_spectral_va() ;
00171 va_d.coef() ;
00172
00173
00174
00175
00176 del_t() ;
00177
00178 set_etat_qcq() ;
00179
00180 va.set_etat_c_qcq() ;
00181
00182 va.c->set_etat_qcq() ;
00183
00184
00185
00186
00187 double xo_d = mp_d->get_ori_x() ;
00188 double yo_d = mp_d->get_ori_y() ;
00189 double zo_d = mp_d->get_ori_z() ;
00190
00191
00192 double rot_phi_d = mp_d->get_rot_phi() ;
00193
00194
00195 double rot_phi_a = mp->get_rot_phi() ;
00196
00197
00198
00199
00200 if ( (mp->r).c == 0x0 ) (mp->r).fait() ;
00201 if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ;
00202 if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ;
00203 if ( (mp->xa).c == 0x0 ) (mp->xa).fait() ;
00204 if ( (mp->ya).c == 0x0 ) (mp->ya).fait() ;
00205 if ( (mp->za).c == 0x0 ) (mp->za).fait() ;
00206
00207 const Mtbl* mr_a = (mp->r).c ;
00208 const Mtbl* mtet_a = (mp->tet).c ;
00209 const Mtbl* mphi_a = (mp->phi).c ;
00210 const Mtbl* mxa_a = (mp->xa).c ;
00211 const Mtbl* mya_a = (mp->ya).c ;
00212 const Mtbl* mza_a = (mp->za).c ;
00213
00214 Param par_precis ;
00215 int nitermax = 100 ;
00216 int niter ;
00217 double precis = 1e-15 ;
00218 par_precis.add_int(nitermax) ;
00219 par_precis.add_int_mod(niter) ;
00220 par_precis.add_double(precis) ;
00221
00222
00223
00224
00225
00226 for (int l=0; l < nzet; l++) {
00227
00228 int nr = mg_a->get_nr(l) ;
00229 int nt = mg_a->get_nt(l) ;
00230 int np = mg_a->get_np(l) ;
00231
00232
00233 const double* pr_a = mr_a->t[l]->t ;
00234 const double* ptet_a = mtet_a->t[l]->t ;
00235 const double* pphi_a = mphi_a->t[l]->t ;
00236 const double* pxa_a = mxa_a->t[l]->t ;
00237 const double* pya_a = mya_a->t[l]->t ;
00238 const double* pza_a = mza_a->t[l]->t ;
00239
00240 (va.c->t[l])->set_etat_qcq() ;
00241
00242 double* ptx = (va.c->t[l])->t ;
00243
00244
00245
00246
00247 for (int k=0 ; k<np ; k++) {
00248 for (int j=0 ; j<nt ; j++) {
00249 for (int i=0 ; i<nr ; i++) {
00250
00251 double r = *pr_a ;
00252 double rd, tetd, phid ;
00253 if (r == __infinity) {
00254 rd = r ;
00255 tetd = *ptet_a ;
00256 phid = *pphi_a + rot_phi_a - rot_phi_d ;
00257 if (phid < 0) phid += 2*M_PI ;
00258 }
00259 else {
00260
00261
00262
00263 double xd = *pxa_a - xo_d ;
00264 double yd = *pya_a - yo_d ;
00265 double zd = *pza_a - zo_d ;
00266
00267
00268 double rhod2 = xd*xd + yd*yd ;
00269 double rhod = sqrt( rhod2 ) ;
00270 rd = sqrt(rhod2 + zd*zd) ;
00271 tetd = atan2(rhod, zd) ;
00272 phid = atan2(yd, xd) - rot_phi_d ;
00273 if (phid < 0) phid += 2*M_PI ;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 int ld ;
00285 double xxd ;
00286 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00287
00288
00289 *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00290
00291
00292 ptx++ ;
00293 pr_a++ ;
00294 ptet_a++ ;
00295 pphi_a++ ;
00296 pxa_a++ ;
00297 pya_a++ ;
00298 pza_a++ ;
00299
00300 }
00301 }
00302 }
00303
00304
00305 }
00306
00307
00308
00309
00310 if (nzet < nz_a) {
00311 annule(nzet, nz_a - 1) ;
00312 }
00313
00314
00315
00316
00317
00318 set_dzpuis(0) ;
00319
00320 }
00321
00322
00323
00324
00325
00326
00327
00328 void Scalar::import_anti(int nzet, const Scalar& cm_d) {
00329
00330
00331
00332
00333 if (cm_d.get_etat() == ETATZERO) {
00334 set_etat_zero() ;
00335 return ;
00336 }
00337
00338 if (cm_d.get_etat() == ETATUN) {
00339 set_etat_one() ;
00340 return ;
00341 }
00342
00343 const Map* mp_d = &(cm_d.get_mp()) ;
00344
00345
00346
00347 int align = (mp->get_bvect_cart()).get_align() ;
00348
00349 assert( align * (mp_d->get_bvect_cart()).get_align() == -1 ) ;
00350
00351 assert(cm_d.get_etat() == ETATQCQ) ;
00352
00353 if (cm_d.get_dzpuis() != 0) {
00354 cout <<
00355 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00356 << endl ;
00357 abort() ;
00358 }
00359
00360
00361 const Mg3d* mg_a = mp->get_mg() ;
00362 int nz_a = mg_a->get_nzone() ;
00363 assert(nzet <= nz_a) ;
00364
00365 const Valeur& va_d = cm_d.get_spectral_va() ;
00366 va_d.coef() ;
00367
00368
00369
00370
00371 del_t() ;
00372
00373 set_etat_qcq() ;
00374
00375 va.set_etat_c_qcq() ;
00376
00377 va.c->set_etat_qcq() ;
00378
00379
00380
00381
00382
00383 double xx_a, yy_a, zz_a ;
00384 if (align == 1) {
00385 xx_a = mp_d->get_ori_x() - mp->get_ori_x() ;
00386 yy_a = mp_d->get_ori_y() - mp->get_ori_y() ;
00387 }
00388 else {
00389 xx_a = mp->get_ori_x() - mp_d->get_ori_x() ;
00390 yy_a = mp->get_ori_y() - mp_d->get_ori_y() ;
00391 }
00392 zz_a = mp->get_ori_z() - mp_d->get_ori_z() ;
00393
00394
00395
00396
00397
00398 if ( (mp->r).c == 0x0 ) (mp->r).fait() ;
00399 if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ;
00400 if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ;
00401 if ( (mp->x).c == 0x0 ) (mp->x).fait() ;
00402 if ( (mp->y).c == 0x0 ) (mp->y).fait() ;
00403 if ( (mp->z).c == 0x0 ) (mp->z).fait() ;
00404
00405 const Mtbl* mr_a = (mp->r).c ;
00406 const Mtbl* mtet_a = (mp->tet).c ;
00407 const Mtbl* mphi_a = (mp->phi).c ;
00408 const Mtbl* mx_a = (mp->x).c ;
00409 const Mtbl* my_a = (mp->y).c ;
00410 const Mtbl* mz_a = (mp->z).c ;
00411
00412 Param par_precis ;
00413 int nitermax = 100 ;
00414 int niter ;
00415 double precis = 1e-15 ;
00416 par_precis.add_int(nitermax) ;
00417 par_precis.add_int_mod(niter) ;
00418 par_precis.add_double(precis) ;
00419
00420
00421
00422
00423
00424 for (int l=0; l < nzet; l++) {
00425
00426 int nr = mg_a->get_nr(l) ;
00427 int nt = mg_a->get_nt(l) ;
00428 int np = mg_a->get_np(l) ;
00429
00430
00431 const double* pr_a = mr_a->t[l]->t ;
00432 const double* ptet_a = mtet_a->t[l]->t ;
00433 const double* pphi_a = mphi_a->t[l]->t ;
00434 const double* px_a = mx_a->t[l]->t ;
00435 const double* py_a = my_a->t[l]->t ;
00436 const double* pz_a = mz_a->t[l]->t ;
00437
00438 (va.c->t[l])->set_etat_qcq() ;
00439
00440 double* ptx = (va.c->t[l])->t ;
00441
00442
00443
00444
00445 for (int k=0 ; k<np ; k++) {
00446 for (int j=0 ; j<nt ; j++) {
00447 for (int i=0 ; i<nr ; i++) {
00448
00449 double r = *pr_a ;
00450 double rd, tetd, phid ;
00451 if (r == __infinity) {
00452 rd = r ;
00453 tetd = *ptet_a ;
00454 phid = *pphi_a + M_PI ;
00455 if (phid < 0) phid += 2*M_PI ;
00456 }
00457 else {
00458
00459
00460 double xd = - *px_a + xx_a ;
00461 double yd = - *py_a + yy_a ;
00462 double zd = *pz_a + zz_a ;
00463
00464
00465 double rhod2 = xd*xd + yd*yd ;
00466 double rhod = sqrt( rhod2 ) ;
00467 rd = sqrt(rhod2 + zd*zd) ;
00468 tetd = atan2(rhod, zd) ;
00469 phid = atan2(yd, xd) ;
00470 if (phid < 0) phid += 2*M_PI ;
00471 }
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481 int ld ;
00482 double xxd ;
00483 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00484
00485
00486 *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00487
00488
00489 ptx++ ;
00490 pr_a++ ;
00491 ptet_a++ ;
00492 pphi_a++ ;
00493 px_a++ ;
00494 py_a++ ;
00495 pz_a++ ;
00496
00497 }
00498 }
00499 }
00500
00501
00502 }
00503
00504
00505
00506
00507 if (nzet < nz_a) {
00508 annule(nzet, nz_a - 1) ;
00509 }
00510
00511
00512
00513
00514
00515 set_dzpuis(0) ;
00516
00517 }
00518
00519
00520
00521
00522
00523
00524
00525 void Scalar::import_align(int nzet, const Scalar& cm_d) {
00526
00527
00528
00529
00530 if (cm_d.get_etat() == ETATZERO) {
00531 set_etat_zero() ;
00532 return ;
00533 }
00534 if (cm_d.get_etat() == ETATUN) {
00535 set_etat_one() ;
00536 return ;
00537 }
00538
00539 const Map* mp_d = &(cm_d.get_mp()) ;
00540
00541
00542
00543 int align = (mp->get_bvect_cart()).get_align() ;
00544
00545 assert( align * (mp_d->get_bvect_cart()).get_align() == 1 ) ;
00546
00547 assert(cm_d.get_etat() == ETATQCQ) ;
00548
00549 if (cm_d.get_dzpuis() != 0) {
00550 cout <<
00551 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
00552 << endl ;
00553 abort() ;
00554 }
00555
00556
00557 const Mg3d* mg_a = mp->get_mg() ;
00558 int nz_a = mg_a->get_nzone() ;
00559 assert(nzet <= nz_a) ;
00560
00561 const Valeur& va_d = cm_d.get_spectral_va() ;
00562 va_d.coef() ;
00563
00564
00565
00566
00567 del_t() ;
00568
00569 set_etat_qcq() ;
00570
00571 va.set_etat_c_qcq() ;
00572
00573 va.c->set_etat_qcq() ;
00574
00575
00576
00577
00578
00579 double xx_a, yy_a, zz_a ;
00580 if (align == 1) {
00581 xx_a = mp->get_ori_x() - mp_d->get_ori_x() ;
00582 yy_a = mp->get_ori_y() - mp_d->get_ori_y() ;
00583 }
00584 else {
00585 xx_a = mp_d->get_ori_x() - mp->get_ori_x() ;
00586 yy_a = mp_d->get_ori_y() - mp->get_ori_y() ;
00587 }
00588 zz_a = mp->get_ori_z() - mp_d->get_ori_z() ;
00589
00590
00591
00592
00593
00594 if ( (mp->r).c == 0x0 ) (mp->r).fait() ;
00595 if ( (mp->tet).c == 0x0 ) (mp->tet).fait() ;
00596 if ( (mp->phi).c == 0x0 ) (mp->phi).fait() ;
00597 if ( (mp->x).c == 0x0 ) (mp->x).fait() ;
00598 if ( (mp->y).c == 0x0 ) (mp->y).fait() ;
00599 if ( (mp->z).c == 0x0 ) (mp->z).fait() ;
00600
00601 const Mtbl* mr_a = (mp->r).c ;
00602 const Mtbl* mtet_a = (mp->tet).c ;
00603 const Mtbl* mphi_a = (mp->phi).c ;
00604 const Mtbl* mx_a = (mp->x).c ;
00605 const Mtbl* my_a = (mp->y).c ;
00606 const Mtbl* mz_a = (mp->z).c ;
00607
00608 Param par_precis ;
00609 int nitermax = 100 ;
00610 int niter ;
00611 double precis = 1e-15 ;
00612 par_precis.add_int(nitermax) ;
00613 par_precis.add_int_mod(niter) ;
00614 par_precis.add_double(precis) ;
00615
00616
00617
00618
00619
00620 for (int l=0; l < nzet; l++) {
00621
00622 int nr = mg_a->get_nr(l) ;
00623 int nt = mg_a->get_nt(l) ;
00624 int np = mg_a->get_np(l) ;
00625
00626
00627 const double* pr_a = mr_a->t[l]->t ;
00628 const double* ptet_a = mtet_a->t[l]->t ;
00629 const double* pphi_a = mphi_a->t[l]->t ;
00630 const double* px_a = mx_a->t[l]->t ;
00631 const double* py_a = my_a->t[l]->t ;
00632 const double* pz_a = mz_a->t[l]->t ;
00633
00634 (va.c->t[l])->set_etat_qcq() ;
00635
00636 double* ptx = (va.c->t[l])->t ;
00637
00638
00639
00640
00641 for (int k=0 ; k<np ; k++) {
00642 for (int j=0 ; j<nt ; j++) {
00643 for (int i=0 ; i<nr ; i++) {
00644
00645 double r = *pr_a ;
00646 double rd, tetd, phid ;
00647 if (r == __infinity) {
00648 rd = r ;
00649 tetd = *ptet_a ;
00650 phid = *pphi_a ;
00651 }
00652 else {
00653
00654
00655 double xd = *px_a + xx_a ;
00656 double yd = *py_a + yy_a ;
00657 double zd = *pz_a + zz_a ;
00658
00659
00660 double rhod2 = xd*xd + yd*yd ;
00661 double rhod = sqrt( rhod2 ) ;
00662 rd = sqrt(rhod2 + zd*zd) ;
00663 tetd = atan2(rhod, zd) ;
00664 phid = atan2(yd, xd) ;
00665 if (phid < 0) phid += 2*M_PI ;
00666 }
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676 int ld ;
00677 double xxd ;
00678 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
00679
00680
00681 *ptx = va_d.c_cf->val_point(ld, xxd, tetd, phid) ;
00682
00683
00684 ptx++ ;
00685 pr_a++ ;
00686 ptet_a++ ;
00687 pphi_a++ ;
00688 px_a++ ;
00689 py_a++ ;
00690 pz_a++ ;
00691
00692 }
00693 }
00694 }
00695
00696
00697 }
00698
00699
00700
00701
00702 if (nzet < nz_a) {
00703 annule(nzet, nz_a - 1) ;
00704 }
00705
00706
00707
00708
00709
00710 set_dzpuis(0) ;
00711
00712 }