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