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 scalar_visu_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_visu.C,v 1.7 2005/02/18 13:14:19 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 #include <stdlib.h>
00062 #include <string.h>
00063
00064
00065 #include "tensor.h"
00066
00067
00068
00069
00070
00071 void Scalar::visu_section(const char section_type, double aa, double umin,
00072 double umax, double vmin, double vmax, const char* title0,
00073 const char* filename0, bool start_dx, int nu, int nv) const {
00074
00075 Tbl plane(3,3) ;
00076 plane.set_etat_qcq() ;
00077
00078 switch (section_type) {
00079
00080 case 'x' : {
00081 plane.set(0,0) = aa ;
00082 plane.set(0,1) = 0. ;
00083 plane.set(0,2) = 0. ;
00084
00085 plane.set(1,0) = 0. ;
00086 plane.set(1,1) = 1. ;
00087 plane.set(1,2) = 0. ;
00088
00089 plane.set(2,0) = 0. ;
00090 plane.set(2,1) = 0. ;
00091 plane.set(2,2) = 1. ;
00092
00093 visu_section(plane, umin, umax, vmin, vmax, title0, filename0,
00094 start_dx, nu, nv) ;
00095 break ;
00096 }
00097
00098 case 'y' : {
00099 plane.set(0,0) = 0. ;
00100 plane.set(0,1) = aa ;
00101 plane.set(0,2) = 0. ;
00102
00103 plane.set(1,0) = 1. ;
00104 plane.set(1,1) = 0. ;
00105 plane.set(1,2) = 0. ;
00106
00107 plane.set(2,0) = 0. ;
00108 plane.set(2,1) = 0. ;
00109 plane.set(2,2) = 1. ;
00110
00111 visu_section(plane, umin, umax, vmin, vmax, title0, filename0,
00112 start_dx, nu, nv) ;
00113 break ;
00114 }
00115
00116 case 'z' : {
00117 plane.set(0,0) = 0. ;
00118 plane.set(0,1) = 0. ;
00119 plane.set(0,2) = aa ;
00120
00121 plane.set(1,0) = 1. ;
00122 plane.set(1,1) = 0. ;
00123 plane.set(1,2) = 0. ;
00124
00125 plane.set(2,0) = 0. ;
00126 plane.set(2,1) = 1. ;
00127 plane.set(2,2) = 0. ;
00128
00129 visu_section(plane, umin, umax, vmin, vmax, title0, filename0,
00130 start_dx, nu, nv) ;
00131 break ;
00132 }
00133
00134 default : {
00135 cerr << "Scalar::visu_section : unknown type of section ! \n" ;
00136 cerr << " section_type = " << section_type << endl ;
00137 break ;
00138 }
00139 }
00140
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 void Scalar::visu_section(const Tbl& plane, double umin, double umax,
00150 double vmin, double vmax, const char* title0, const char* filename0,
00151 bool start_dx, int nu, int nv) const {
00152
00153 char* title ;
00154 char* title_quotes ;
00155 if (title0 == 0x0) {
00156 title = new char[2] ;
00157 strcpy(title, " ") ;
00158
00159 title_quotes = new char[4] ;
00160 strcpy(title_quotes, "\" \"") ;
00161 }
00162 else {
00163 title = new char[ strlen(title0)+1 ] ;
00164 strcpy(title, title0) ;
00165
00166 title_quotes = new char[ strlen(title0)+3 ] ;
00167 strcpy(title_quotes, "\"") ;
00168 strcat(title_quotes, title0) ;
00169 strcat(title_quotes, "\"") ;
00170 }
00171
00172
00173
00174
00175
00176 char* filename ;
00177 if (filename0 == 0x0) {
00178 filename = new char[30] ;
00179 strcpy(filename, "scalar_section.dxdata") ;
00180 }
00181 else {
00182 filename = new char[ strlen(filename0)+8 ] ;
00183 strcpy(filename, filename0) ;
00184 strcat(filename, ".dxdata") ;
00185 }
00186
00187 ofstream fdata(filename) ;
00188
00189 fdata << title << "\n" ;
00190 fdata << "size : " << nu << " x " << nv << "\n" ;
00191 fdata << "u_min = " << umin << " u_max = " << umax << "\n" ;
00192 fdata << "v_min = " << vmin << " v_max = " << vmax << "\n" ;
00193
00194
00195
00196
00197 double xa0 = plane(0,0) ;
00198 double ya0 = plane(0,1) ;
00199 double za0 = plane(0,2) ;
00200
00201 double eux = plane(1,0) ;
00202 double euy = plane(1,1) ;
00203 double euz = plane(1,2) ;
00204
00205 double evx = plane(2,0) ;
00206 double evy = plane(2,1) ;
00207 double evz = plane(2,2) ;
00208
00209
00210
00211 va.coef() ;
00212 const Mtbl_cf& cva = *(va.c_cf) ;
00213
00214
00215 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
00216
00217 fdata.precision(5) ;
00218 fdata.setf(ios::scientific) ;
00219
00220
00221
00222 double du = (umax - umin) / double(nu-1) ;
00223 double dv = (vmax - vmin) / double(nv-1) ;
00224
00225 int npoint = 0 ;
00226
00227 for (int j=0; j<nv; j++) {
00228
00229 double v = vmin + dv * j ;
00230
00231 for (int i=0; i<nu; i++) {
00232
00233 double u = umin + du * i ;
00234
00235 double xa = xa0 + u * eux + v * evx ;
00236 double ya = ya0 + u * euy + v * evy ;
00237 double za = za0 + u * euz + v * evz ;
00238
00239
00240
00241 double rr, th, ph ;
00242
00243
00244 mp->convert_absolute(xa, ya, za, rr, th, ph) ;
00245
00246
00247 double xi ;
00248 int l ;
00249
00250 mp->val_lx(rr, th, ph, l, xi) ;
00251
00252
00253
00254 double ff = cva.val_point(l, xi, th, ph) ;
00255
00256 fdata.width(14) ;
00257 fdata << ff ;
00258 npoint++ ;
00259
00260 if (npoint == 6) {
00261 fdata << "\n" ;
00262 npoint = 0 ;
00263 }
00264
00265 }
00266 }
00267
00268 if (npoint != 0) fdata << "\n" ;
00269
00270 fdata.close() ;
00271
00272
00273
00274
00275
00276 char* headername ;
00277 if (filename0 == 0x0) {
00278 headername = new char[30] ;
00279 strcpy(headername, "scalar_section.dxhead") ;
00280 }
00281 else {
00282 headername = new char[ strlen(filename0)+9 ] ;
00283 strcpy(headername, filename0) ;
00284 strcat(headername, ".dxhead") ;
00285 }
00286
00287 ofstream fheader(headername) ;
00288
00289 fheader << "file = " << filename << endl ;
00290 fheader << "grid = " << nu << " x " << nv << endl ;
00291 fheader << "format = ascii" << endl ;
00292 fheader << "interleaving = record" << endl ;
00293 fheader << "majority = column" << endl ;
00294 fheader << "header = lines 4" << endl ;
00295 fheader << "field = " << title_quotes << endl ;
00296 fheader << "structure = scalar" << endl ;
00297 fheader << "type = float" << endl ;
00298 fheader << "dependency = positions" << endl ;
00299 fheader << "positions = regular, regular, " << umin << ", " << du
00300 << ", " << vmin << ", " << dv << endl ;
00301 fheader << endl ;
00302 fheader << "end" << endl ;
00303
00304 fheader.close() ;
00305
00306
00307 if ( start_dx ) {
00308
00309 char* commande = new char[ strlen(headername) + 60 ] ;
00310 strcpy(commande, "ln -s ") ;
00311 strcat(commande, headername) ;
00312 strcat(commande, " visu_section.dxhead") ;
00313
00314 system("rm -f visu_section.dxhead") ;
00315 system(commande) ;
00316 system("dx -image visu_section.net &") ;
00317
00318 delete [] commande ;
00319 }
00320
00321
00322
00323 delete [] title ;
00324 delete [] title_quotes ;
00325 delete [] filename ;
00326 delete [] headername ;
00327
00328 }
00329
00330
00331
00332
00333
00334
00335 void Scalar::visu_box(double xmin, double xmax, double ymin, double ymax,
00336 double zmin, double zmax, const char* title0, const char* filename0,
00337 bool start_dx, int nx, int ny, int nz) const {
00338
00339 const Scalar* scal ;
00340 Scalar* scal_tmp = 0x0 ;
00341
00342
00343 if ( !check_dzpuis(0) ) {
00344 scal_tmp = new Scalar(*this) ;
00345 scal_tmp->dec_dzpuis(dzpuis) ;
00346 scal = scal_tmp ;
00347 }
00348 else{
00349 scal = this ;
00350 }
00351
00352 char* title ;
00353 char* title_quotes ;
00354 if (title0 == 0x0) {
00355 title = new char[2] ;
00356 strcpy(title, " ") ;
00357
00358 title_quotes = new char[4] ;
00359 strcpy(title_quotes, "\" \"") ;
00360 }
00361 else {
00362 title = new char[ strlen(title0)+1 ] ;
00363 strcpy(title, title0) ;
00364
00365 title_quotes = new char[ strlen(title0)+3 ] ;
00366 strcpy(title_quotes, "\"") ;
00367 strcat(title_quotes, title0) ;
00368 strcat(title_quotes, "\"") ;
00369 }
00370
00371
00372
00373
00374
00375 char* filename ;
00376 if (filename0 == 0x0) {
00377 filename = new char[30] ;
00378 strcpy(filename, "scalar_box.dxdata") ;
00379 }
00380 else {
00381 filename = new char[ strlen(filename0)+8 ] ;
00382 strcpy(filename, filename0) ;
00383 strcat(filename, ".dxdata") ;
00384 }
00385
00386 ofstream fdata(filename) ;
00387
00388 fdata << title << "\n" ;
00389 fdata << "size : " << nx << " x " << ny << " x " << nz << "\n" ;
00390 fdata << "x_min = " << xmin << " x_max = " << xmax << "\n" ;
00391 fdata << "y_min = " << ymin << " y_max = " << ymax << "\n" ;
00392 fdata << "z_min = " << zmin << " z_max = " << zmax << "\n" ;
00393
00394
00395 const Valeur& val = scal->va ;
00396 val.coef() ;
00397 const Mtbl_cf& cva = *(val.c_cf) ;
00398
00399
00400 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
00401
00402 fdata.precision(5) ;
00403 fdata.setf(ios::scientific) ;
00404
00405
00406
00407 double dx = (xmax - xmin) / double(nx-1) ;
00408 double dy = (ymax - ymin) / double(ny-1) ;
00409 double dz = (zmax - zmin) / double(nz-1) ;
00410
00411 int npoint = 0 ;
00412
00413 for (int k=0; k<nz; k++) {
00414
00415 double zz = zmin + dz * k ;
00416
00417 for (int j=0; j<ny; j++) {
00418
00419 double yy = ymin + dy * j ;
00420
00421 for (int i=0; i<nx; i++) {
00422
00423 double xx = xmin + dx * i ;
00424
00425
00426 double rr, th, ph ;
00427
00428
00429 mp->convert_absolute(xx, yy, zz, rr, th, ph) ;
00430
00431
00432 double xi ; int l ;
00433
00434 mp->val_lx(rr, th, ph, l, xi) ;
00435
00436
00437
00438 double ff = cva.val_point(l, xi, th, ph) ;
00439
00440 fdata.width(14) ;
00441 fdata << ff ;
00442 npoint++ ;
00443
00444 if (npoint == 9) {
00445 fdata << "\n" ;
00446 npoint = 0 ;
00447 }
00448
00449 }
00450 }
00451
00452 }
00453
00454 if (npoint != 0) fdata << "\n" ;
00455
00456 fdata.close() ;
00457
00458
00459
00460
00461
00462 char* headername ;
00463 if (filename0 == 0x0) {
00464 headername = new char[30] ;
00465 strcpy(headername, "scalar_box.dxhead") ;
00466 }
00467 else {
00468 headername = new char[ strlen(filename0)+9 ] ;
00469 strcpy(headername, filename0) ;
00470 strcat(headername, ".dxhead") ;
00471 }
00472
00473 ofstream fheader(headername) ;
00474
00475 fheader << "file = " << filename << endl ;
00476 fheader << "grid = " << nx << " x " << ny << " x " << nz << endl ;
00477 fheader << "format = ascii" << endl ;
00478 fheader << "interleaving = record" << endl ;
00479 fheader << "majority = column" << endl ;
00480 fheader << "header = lines 5" << endl ;
00481 fheader << "field = " << title_quotes << endl ;
00482 fheader << "structure = scalar" << endl ;
00483 fheader << "type = float" << endl ;
00484 fheader << "dependency = positions" << endl ;
00485 fheader << "positions = regular, regular, regular, "
00486 << xmin << ", " << dx << ", "
00487 << ymin << ", " << dy << ", "
00488 << zmin << ", " << dz << endl ;
00489 fheader << endl ;
00490 fheader << "end" << endl ;
00491
00492 fheader.close() ;
00493
00494
00495 if ( start_dx ) {
00496
00497 char* commande = new char[ strlen(headername) + 60 ] ;
00498 strcpy(commande, "ln -s ") ;
00499 strcat(commande, headername) ;
00500 strcat(commande, " visu_scalar_box.dxhead") ;
00501
00502 system("rm -f visu_scalar_box.dxhead") ;
00503 system(commande) ;
00504 system("dx -image visu_scalar_box.net &") ;
00505
00506 delete [] commande ;
00507 }
00508
00509
00510
00511
00512
00513 if (scal_tmp != 0x0) delete scal_tmp ;
00514 delete [] title ;
00515 delete [] title_quotes ;
00516 delete [] filename ;
00517 delete [] headername ;
00518
00519
00520 }
00521
00522
00523
00524
00525
00526
00527
00528 void Scalar::visu_section_anim(const char section_type, double aa, double umin,
00529 double umax, double vmin, double vmax, int jtime, double ,
00530 int jgraph, const char* title, const char* filename_root, bool start_dx,
00531 int nu, int nv) const {
00532
00533 if ( jtime % jgraph != 0 ) return ;
00534
00535
00536
00537 int k = jtime / jgraph ;
00538
00539 char* filename ;
00540 if (filename_root == 0x0) {
00541 filename = new char[40] ;
00542 strcpy(filename, "anim") ;
00543 }
00544 else {
00545 filename = new char[ strlen(filename_root)+10 ] ;
00546 strcpy(filename, filename_root) ;
00547 }
00548
00549 char nomk[5] ;
00550 sprintf(nomk, "%04d", k) ;
00551 strcat(filename, nomk) ;
00552
00553
00554
00555
00556 visu_section(section_type, aa, umin, umax, vmin, vmax, title, filename,
00557 false, nu, nv) ;
00558
00559
00560
00561
00562 if ( start_dx ) {
00563
00564 system("dx -edit anime.net &") ;
00565
00566 }
00567
00568
00569
00570
00571 delete [] filename ;
00572
00573 }