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 char connection_fspher_C[] = "$Header: /cvsroot/Lorene/C++/Source/Connection/connection_fspher.C,v 1.22 2005/05/25 16:11:03 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #include "headcpp.h"
00122
00123
00124 #include <stdlib.h>
00125
00126
00127 #include "connection.h"
00128
00129
00130
00131
00132
00133
00134
00135 Connection_fspher::Connection_fspher(const Map& mpi, const Base_vect_spher& bi)
00136 : Connection_flat(mpi, bi) {
00137
00138 }
00139
00140
00141 Connection_fspher::Connection_fspher(const Connection_fspher& ci)
00142 : Connection_flat(ci) {
00143
00144 }
00145
00146
00147
00148
00149
00150
00151 Connection_fspher::~Connection_fspher(){
00152
00153 }
00154
00155
00156
00157
00158
00159
00160
00161 void Connection_fspher::operator=(const Connection_fspher& ) {
00162
00163 cout << "Connection_fspher::operator= : not implemented yet !" << endl ;
00164 abort() ;
00165
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 Tensor* Connection_fspher::p_derive_cov(const Tensor& uu) const {
00177
00178
00179
00180
00181 int valence0 = uu.get_valence() ;
00182 int valence1 = valence0 + 1 ;
00183 int valence1m1 = valence1 - 1 ;
00184
00185 int ncomp0 = uu.get_n_comp() ;
00186
00187
00188
00189 if (valence0 >= 1) {
00190 assert(uu.get_triad() == triad) ;
00191 }
00192
00193
00194
00195 Tensor* resu ;
00196
00197
00198 if (valence0 == 0)
00199 resu = new Vector(*mp, COV, triad) ;
00200 else {
00201
00202
00203 Itbl tipe(valence1) ;
00204 const Itbl& tipeuu = uu.get_index_type() ;
00205 for (int id = 0; id<valence0; id++) {
00206 tipe.set(id) = tipeuu(id) ;
00207 }
00208 tipe.set(valence1m1) = COV ;
00209
00210
00211 const Tensor* puu = &uu ;
00212 const Tensor_sym* puus = dynamic_cast<const Tensor_sym*>(puu) ;
00213 if ( puus != 0x0 ) {
00214 resu = new Tensor_sym(*mp, valence1, tipe, *triad,
00215 puus->sym_index1(), puus->sym_index2()) ;
00216 }
00217 else {
00218 resu = new Tensor(*mp, valence1, tipe, *triad) ;
00219 }
00220
00221 }
00222
00223 int ncomp1 = resu->get_n_comp() ;
00224
00225 Itbl ind1(valence1) ;
00226 Itbl ind0(valence0) ;
00227 Itbl ind(valence0) ;
00228
00229 Scalar tmp(*mp) ;
00230
00231
00232
00233 int dz_in = 0 ;
00234 for (int ic=0; ic<ncomp0; ic++) {
00235 int dzp = uu(uu.indices(ic)).get_dzpuis() ;
00236 assert(dzp >= 0) ;
00237 if (dzp > dz_in) dz_in = dzp ;
00238 }
00239
00240 #ifndef NDEBUG
00241
00242 for (int ic=0; ic<ncomp0; ic++) {
00243 if ( !(uu(uu.indices(ic)).check_dzpuis(dz_in)) ) {
00244 cout << "######## WARNING #######\n" ;
00245 cout << " Connection_fspher::p_derive_cov : the tensor components \n"
00246 << " do not have all the same dzpuis ! : \n"
00247 << " ic, dzpuis(ic), dz_in : " << ic << " "
00248 << uu(uu.indices(ic)).get_dzpuis() << " " << dz_in << endl ;
00249 }
00250 }
00251 #endif
00252
00253 int dz_resu = (dz_in == 0) ? 2 : dz_in + 1 ;
00254 int nzm1 = mp->get_mg()->get_nzone() - 1 ;
00255 if (mp->get_mg()->get_type_r(nzm1) != UNSURR) dz_resu = 0 ;
00256
00257
00258
00259 for (int ic=0; ic<ncomp1; ic++) {
00260
00261
00262 ind1 = resu->indices(ic) ;
00263
00264
00265 Scalar& cresu = resu->set(ind1) ;
00266
00267
00268 for (int id = 0; id < valence0; id++) {
00269 ind0.set(id) = ind1(id) ;
00270 }
00271
00272
00273 int k = ind1(valence1m1) ;
00274
00275 switch (k) {
00276
00277 case 1 : {
00278
00279
00280 cresu = (uu(ind0)).dsdr() ;
00281
00282
00283 break ;
00284 }
00285
00286 case 2 : {
00287
00288
00289 cresu = (uu(ind0)).srdsdt() ;
00290
00291
00292 for (int id=0; id<valence0; id++) {
00293
00294 switch ( ind0(id) ) {
00295
00296 case 1 : {
00297
00298 ind = ind0 ;
00299 ind.set(id) = 2 ;
00300
00301
00302 tmp = uu(ind) ;
00303 tmp.div_r_dzpuis(dz_resu) ;
00304
00305 cresu -= tmp ;
00306 break ;
00307 }
00308
00309 case 2 : {
00310
00311 ind = ind0 ;
00312 ind.set(id) = 1 ;
00313 tmp = uu(ind) ;
00314 tmp.div_r_dzpuis(dz_resu) ;
00315
00316 cresu += tmp ;
00317 break ;
00318 }
00319
00320 case 3 : {
00321
00322 break ;
00323 }
00324
00325 default : {
00326 cerr << "Connection_fspher::p_derive_cov : index problem ! "
00327 << endl ;
00328 abort() ;
00329 }
00330 }
00331
00332 }
00333 break ;
00334 }
00335
00336
00337 case 3 : {
00338
00339
00340 cresu = (uu(ind0)).srstdsdp() ;
00341
00342
00343 for (int id=0; id<valence0; id++) {
00344
00345 switch ( ind0(id) ) {
00346
00347 case 1 : {
00348
00349 ind = ind0 ;
00350 ind.set(id) = 3 ;
00351 tmp = uu(ind) ;
00352 tmp.div_r_dzpuis(dz_resu) ;
00353
00354 cresu -= tmp ;
00355 break ;
00356 }
00357
00358 case 2 : {
00359
00360 ind = ind0 ;
00361 ind.set(id) = 3 ;
00362 tmp = uu(ind) ;
00363 tmp.div_r_dzpuis(dz_resu) ;
00364
00365 tmp.div_tant() ;
00366
00367 cresu -= tmp ;
00368 break ;
00369 }
00370
00371 case 3 : {
00372
00373
00374 ind = ind0 ;
00375 ind.set(id) = 1 ;
00376 tmp = uu(ind) ;
00377 tmp.div_r_dzpuis(dz_resu) ;
00378
00379 cresu += tmp ;
00380
00381 ind.set(id) = 2 ;
00382 tmp = uu(ind) ;
00383 tmp.div_r_dzpuis(dz_resu) ;
00384
00385 tmp.div_tant() ;
00386
00387 cresu += tmp ;
00388 break ;
00389 }
00390
00391 default : {
00392 cerr << "Connection_fspher::p_derive_cov : index problem ! "
00393 << endl ;
00394 abort() ;
00395 }
00396 }
00397
00398 }
00399
00400 break ;
00401 }
00402
00403 default : {
00404 cerr << "Connection_fspher::p_derive_cov : index problem ! \n" ;
00405 abort() ;
00406 }
00407
00408 }
00409
00410
00411 }
00412
00413
00414
00415 return resu ;
00416
00417 }
00418
00419
00420
00421
00422
00423
00424 Tensor* Connection_fspher::p_divergence(const Tensor& uu) const {
00425
00426
00427
00428
00429 int valence0 = uu.get_valence() ;
00430 int valence1 = valence0 - 1 ;
00431 int valence0m1 = valence0 - 1 ;
00432
00433 int ncomp0 = uu.get_n_comp() ;
00434
00435
00436
00437 assert (valence0 >= 1) ;
00438 assert (uu.get_triad() == triad) ;
00439
00440
00441 assert (uu.get_index_type(valence0-1) == CON) ;
00442
00443
00444
00445
00446 Tensor* resu ;
00447
00448 if (valence0 == 1)
00449 resu = new Scalar(*mp) ;
00450 else {
00451
00452
00453 Itbl tipe(valence1) ;
00454 const Itbl& tipeuu = uu.get_index_type() ;
00455 for (int id = 0; id<valence1; id++) {
00456 tipe.set(id) = tipeuu(id) ;
00457 }
00458
00459 if (valence0 == 2) {
00460 resu = new Vector(*mp, tipe(0), *triad) ;
00461 }
00462 else {
00463
00464 const Tensor* puu = &uu ;
00465 const Tensor_sym* puus = dynamic_cast<const Tensor_sym*>(puu) ;
00466 if ( puus != 0x0 ) {
00467
00468 if (puus->sym_index2() != valence0 - 1) {
00469
00470
00471
00472 if (valence1 == 2) {
00473 resu = new Sym_tensor(*mp, tipe, *triad) ;
00474 }
00475 else {
00476 resu = new Tensor_sym(*mp, valence1, tipe, *triad,
00477 puus->sym_index1(), puus->sym_index2()) ;
00478 }
00479 }
00480 else {
00481
00482 resu = new Tensor(*mp, valence1, tipe, *triad) ;
00483 }
00484 }
00485 else {
00486 resu = new Tensor(*mp, valence1, tipe, *triad) ;
00487 }
00488 }
00489
00490 }
00491
00492 int ncomp1 = resu->get_n_comp() ;
00493
00494 Itbl ind0(valence0) ;
00495 Itbl ind1(valence1) ;
00496 Itbl ind(valence0) ;
00497
00498 Scalar tmp1(*mp) ;
00499 Scalar tmp2(*mp) ;
00500
00501
00502
00503 int dz_in = 0 ;
00504 for (int ic=0; ic<ncomp0; ic++) {
00505 int dzp = uu(uu.indices(ic)).get_dzpuis() ;
00506 assert(dzp >= 0) ;
00507 if (dzp > dz_in) dz_in = dzp ;
00508 }
00509
00510 #ifndef NDEBUG
00511
00512 for (int ic=0; ic<ncomp0; ic++) {
00513 if ( !(uu(uu.indices(ic)).check_dzpuis(dz_in)) ) {
00514 cout << "######## WARNING #######\n" ;
00515 cout << " Connection_fspher::p_divergence : the tensor components \n"
00516 << " do not have all the same dzpuis ! : \n"
00517 << " ic, dzpuis(ic), dz_in : " << ic << " "
00518 << uu(uu.indices(ic)).get_dzpuis() << " " << dz_in << endl ;
00519 }
00520 }
00521 #endif
00522
00523 int dz_resu = (dz_in == 0) ? 2 : dz_in + 1 ;
00524
00525
00526 for (int ic=0; ic<ncomp1; ic++) {
00527
00528 ind1 = resu->indices(ic) ;
00529 Scalar& cresu = resu->set(ind1) ;
00530
00531
00532
00533 int k = 1 ;
00534
00535
00536 for (int id = 0; id < valence1; id++) {
00537 ind0.set(id) = ind1(id) ;
00538 }
00539 ind0.set(valence0m1) = k ;
00540
00541 cresu = uu(ind0).dsdr() ;
00542
00543
00544
00545 k = 2 ;
00546
00547
00548 for (int id = 0; id < valence1; id++) {
00549 ind0.set(id) = ind1(id) ;
00550 }
00551 ind0.set(valence0m1) = k ;
00552
00553 tmp1 = uu(ind0).dsdt() ;
00554
00555 ind = ind0 ;
00556 ind.set(valence0m1) = 1 ;
00557 tmp1 += uu(ind) ;
00558
00559
00560
00561 for (int id=0; id<valence0m1; id++) {
00562
00563 switch ( ind0(id) ) {
00564 case 1 : {
00565
00566 ind = ind0 ;
00567 ind.set(id) = 2 ;
00568 tmp1 -= uu(ind) ;
00569 break ;
00570 }
00571
00572 case 2 : {
00573
00574 ind = ind0 ;
00575 ind.set(id) = 1 ;
00576 tmp1 += uu(ind) ;
00577 break ;
00578 }
00579
00580 case 3 : {
00581
00582 break ;
00583 }
00584
00585 default : {
00586 cout << "Connection_fspher::p_divergence : index problem ! "
00587 << endl ;
00588 abort() ;
00589 }
00590 }
00591
00592 }
00593
00594
00595
00596 k = 3 ;
00597
00598
00599 for (int id = 0; id < valence1; id++) {
00600 ind0.set(id) = ind1(id) ;
00601 }
00602 ind0.set(valence0m1) = k ;
00603
00604 tmp1 += uu(ind0).stdsdp() ;
00605
00606 ind = ind0 ;
00607 ind.set(valence0m1) = 1 ;
00608 tmp1 += uu(ind) ;
00609 ind.set(valence0m1) = 2 ;
00610 tmp2 = uu(ind) ;
00611
00612
00613 for (int id=0; id<valence0-1; id++) {
00614
00615 switch ( ind0(id) ) {
00616 case 1 : {
00617
00618 ind = ind0 ;
00619 ind.set(id) = 3 ;
00620 tmp1 -= uu(ind) ;
00621 break ;
00622 }
00623
00624 case 2 : {
00625
00626 ind = ind0 ;
00627 ind.set(id) = 3 ;
00628 tmp2 -= uu(ind) ;
00629 break ;
00630 }
00631
00632 case 3 : {
00633
00634 ind = ind0 ;
00635
00636 ind.set(id) = 1 ;
00637 tmp1 += uu(ind) ;
00638
00639 ind.set(id) = 2 ;
00640 tmp2 += uu(ind) ;
00641 break ;
00642 }
00643
00644 default : {
00645 cout << "Connection_fspher::p_divergence : index problem ! "
00646 << endl ;
00647 abort() ;
00648 }
00649 }
00650 }
00651
00652
00653 tmp2.div_tant() ;
00654 tmp1 += tmp2 ;
00655 tmp1.div_r_dzpuis(dz_resu) ;
00656
00657 cresu += tmp1 ;
00658
00659 }
00660
00661
00662
00663 return resu ;
00664
00665 }
00666
00667
00668
00669
00670
00671
00672