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