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 vector_visu_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_visu.C,v 1.3 2005/02/16 15:31:56 m_forot Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <stdlib.h>
00049 #include <string.h>
00050
00051
00052 #include "tensor.h"
00053
00054
00055 void Vector::visu_arrows(double xmin, double xmax, double ymin, double ymax,
00056 double zmin, double zmax, const char* title0, const char* filename0,
00057 bool start_dx, int nx, int ny, int nz) const {
00058
00059 const Vector* vect ;
00060 Vector* vect_tmp = 0x0 ;
00061
00062
00063 if (*triad == mp->get_bvect_cart()) {
00064 vect = this ;
00065 }
00066 else {
00067 if (*triad == mp->get_bvect_spher()) {
00068 vect_tmp = new Vector(*this) ;
00069 vect_tmp->change_triad( mp->get_bvect_cart() ) ;
00070 vect = vect_tmp ;
00071 }
00072 else {
00073 cerr << "Vector::visu_arrows : unknown triad !" << endl ;
00074 abort() ;
00075 }
00076 }
00077
00078
00079 bool dzpnonzero = false ;
00080 for (int i=1; i<=3; i++) {
00081 dzpnonzero = dzpnonzero || !(operator()(i).check_dzpuis(0)) ;
00082 }
00083 if (dzpnonzero) {
00084 if (vect_tmp == 0x0) {
00085 vect_tmp = new Vector(*this) ;
00086 }
00087 for (int i=1; i<=3; i++) {
00088 Scalar& cvect = vect_tmp->set(i) ;
00089 int dzpuis = cvect.get_dzpuis() ;
00090 if (dzpuis != 0) {
00091 cvect.dec_dzpuis(dzpuis) ;
00092 }
00093 }
00094 vect = vect_tmp ;
00095 }
00096
00097 char* title ;
00098 char* title_quotes ;
00099 if (title0 == 0x0) {
00100 title = new char[2] ;
00101 strcpy(title, " ") ;
00102
00103 title_quotes = new char[4] ;
00104 strcpy(title_quotes, "\" \"") ;
00105 }
00106 else {
00107 title = new char[ strlen(title0)+1 ] ;
00108 strcpy(title, title0) ;
00109
00110 title_quotes = new char[ strlen(title0)+3 ] ;
00111 strcpy(title_quotes, "\"") ;
00112 strcat(title_quotes, title0) ;
00113 strcat(title_quotes, "\"") ;
00114 }
00115
00116
00117
00118
00119
00120 char* filename ;
00121 if (filename0 == 0x0) {
00122 filename = new char[30] ;
00123 strcpy(filename, "vector3d_arrows.dxdata") ;
00124 }
00125 else {
00126 filename = new char[ strlen(filename0)+8 ] ;
00127 strcpy(filename, filename0) ;
00128 strcat(filename, ".dxdata") ;
00129 }
00130
00131 ofstream fdata(filename) ;
00132
00133 fdata << title << "\n" ;
00134 fdata << "size : " << nx << " x " << ny << " x " << nz << "\n" ;
00135 fdata << "x_min = " << xmin << " x_max = " << xmax << "\n" ;
00136 fdata << "y_min = " << ymin << " y_max = " << ymax << "\n" ;
00137 fdata << "z_min = " << zmin << " z_max = " << zmax << "\n" ;
00138
00139
00140 const Valeur& vax = (vect->operator()(1)).get_spectral_va() ;
00141 const Valeur& vay = (vect->operator()(2)).get_spectral_va() ;
00142 const Valeur& vaz = (vect->operator()(3)).get_spectral_va() ;
00143 vax.coef() ;
00144 vay.coef() ;
00145 vaz.coef() ;
00146 const Mtbl_cf& cvax = *(vax.c_cf) ;
00147 const Mtbl_cf& cvay = *(vay.c_cf) ;
00148 const Mtbl_cf& cvaz = *(vaz.c_cf) ;
00149
00150
00151 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
00152
00153 fdata.precision(5) ;
00154 fdata.setf(ios::scientific) ;
00155
00156
00157
00158 double dx = (xmax - xmin) / double(nx-1) ;
00159 double dy = (ymax - ymin) / double(ny-1) ;
00160 double dz = (zmax - zmin) / double(nz-1) ;
00161
00162 int npoint = 0 ;
00163
00164 for (int k=0; k<nz; k++) {
00165
00166 double zz = zmin + dz * k ;
00167
00168 for (int j=0; j<ny; j++) {
00169
00170 double yy = ymin + dy * j ;
00171
00172 for (int i=0; i<nx; i++) {
00173
00174 double xx = xmin + dx * i ;
00175
00176
00177 double rr, th, ph ;
00178
00179
00180 mp->convert_absolute(xx, yy, zz, rr, th, ph) ;
00181
00182
00183 double xi ; int l ;
00184
00185 mp->val_lx(rr, th, ph, l, xi) ;
00186
00187
00188
00189 double vx = cvax.val_point(l, xi, th, ph) ;
00190 double vy = cvay.val_point(l, xi, th, ph) ;
00191 double vz = cvaz.val_point(l, xi, th, ph) ;
00192
00193 fdata.width(14) ; fdata << vx ;
00194 fdata.width(14) ; fdata << vy ;
00195 fdata.width(14) ; fdata << vz ;
00196 npoint++ ;
00197
00198 if (npoint == 3) {
00199 fdata << "\n" ;
00200 npoint = 0 ;
00201 }
00202
00203 }
00204 }
00205
00206 }
00207
00208 if (npoint != 0) fdata << "\n" ;
00209
00210 fdata.close() ;
00211
00212
00213
00214
00215
00216 char* headername ;
00217 if (filename0 == 0x0) {
00218 headername = new char[30] ;
00219 strcpy(headername, "vector3d_arrows.dxhead") ;
00220 }
00221 else {
00222 headername = new char[ strlen(filename0)+9 ] ;
00223 strcpy(headername, filename0) ;
00224 strcat(headername, ".dxhead") ;
00225 }
00226
00227 ofstream fheader(headername) ;
00228
00229 fheader << "file = " << filename << endl ;
00230 fheader << "grid = " << nx << " x " << ny << " x " << nz << endl ;
00231 fheader << "format = ascii" << endl ;
00232 fheader << "interleaving = record-vector" << endl ;
00233 fheader << "majority = column" << endl ;
00234 fheader << "header = lines 5" << endl ;
00235 fheader << "field = " << title_quotes << endl ;
00236 fheader << "structure = 3-vector" << endl ;
00237 fheader << "type = float" << endl ;
00238 fheader << "dependency = positions" << endl ;
00239 fheader << "positions = regular, regular, regular, "
00240 << xmin << ", " << dx << ", "
00241 << ymin << ", " << dy << ", "
00242 << zmin << ", " << dz << endl ;
00243 fheader << endl ;
00244 fheader << "end" << endl ;
00245
00246 fheader.close() ;
00247
00248
00249 if ( start_dx ) {
00250
00251 char* commande = new char[ strlen(headername) + 60 ] ;
00252 strcpy(commande, "ln -s ") ;
00253 strcat(commande, headername) ;
00254 strcat(commande, " visu_vector3d.dxhead") ;
00255
00256 system("rm -f visu_vector3d.dxhead") ;
00257 system(commande) ;
00258 system("dx -image visu_vector3d.net &") ;
00259
00260 delete [] commande ;
00261 }
00262
00263
00264
00265
00266
00267 if (vect_tmp != 0x0) delete vect_tmp ;
00268 delete [] title ;
00269 delete [] title_quotes ;
00270 delete [] filename ;
00271 delete [] headername ;
00272
00273
00274 }
00275
00276 void Vector::visu_streamline(double xmin, double xmax, double ymin, double ymax,
00277 double zmin, double zmax, const char* title0, const char* filename0,
00278 bool start_dx, int nx, int ny, int nz) const {
00279
00280 const Vector* vect ;
00281 Vector* vect_tmp = 0x0 ;
00282
00283
00284 if (*triad == mp->get_bvect_cart()) {
00285 vect = this ;
00286 }
00287 else {
00288 if (*triad == mp->get_bvect_spher()) {
00289 vect_tmp = new Vector(*this) ;
00290 vect_tmp->change_triad( mp->get_bvect_cart() ) ;
00291 vect = vect_tmp ;
00292 }
00293 else {
00294 cerr << "Vector::visu_streamline : unknown triad !" << endl ;
00295 abort() ;
00296 }
00297 }
00298
00299
00300 bool dzpnonzero = false ;
00301 for (int i=1; i<=3; i++) {
00302 dzpnonzero = dzpnonzero || !(operator()(i).check_dzpuis(0)) ;
00303 }
00304 if (dzpnonzero) {
00305 if (vect_tmp == 0x0) {
00306 vect_tmp = new Vector(*this) ;
00307 }
00308 for (int i=1; i<=3; i++) {
00309 Scalar& cvect = vect_tmp->set(i) ;
00310 int dzpuis = cvect.get_dzpuis() ;
00311 if (dzpuis != 0) {
00312 cvect.dec_dzpuis(dzpuis) ;
00313 }
00314 }
00315 vect = vect_tmp ;
00316 }
00317
00318 char* title ;
00319 char* title_quotes ;
00320 if (title0 == 0x0) {
00321 title = new char[2] ;
00322 strcpy(title, " ") ;
00323
00324 title_quotes = new char[4] ;
00325 strcpy(title_quotes, "\" \"") ;
00326 }
00327 else {
00328 title = new char[ strlen(title0)+1 ] ;
00329 strcpy(title, title0) ;
00330
00331 title_quotes = new char[ strlen(title0)+3 ] ;
00332 strcpy(title_quotes, "\"") ;
00333 strcat(title_quotes, title0) ;
00334 strcat(title_quotes, "\"") ;
00335 }
00336
00337
00338
00339
00340
00341 char* filename ;
00342 if (filename0 == 0x0) {
00343 filename = new char[30] ;
00344 strcpy(filename, "vector3d_streamline.dxdata") ;
00345 }
00346 else {
00347 filename = new char[ strlen(filename0)+8 ] ;
00348 strcpy(filename, filename0) ;
00349 strcat(filename, ".dxdata") ;
00350 }
00351
00352 ofstream fdata(filename) ;
00353
00354 fdata << title << "\n" ;
00355 fdata << "size : " << nx << " x " << ny << " x " << nz << "\n" ;
00356 fdata << "x_min = " << xmin << " x_max = " << xmax << "\n" ;
00357 fdata << "y_min = " << ymin << " y_max = " << ymax << "\n" ;
00358 fdata << "z_min = " << zmin << " z_max = " << zmax << "\n" ;
00359
00360
00361 const Valeur& vax = (vect->operator()(1)).get_spectral_va() ;
00362 const Valeur& vay = (vect->operator()(2)).get_spectral_va() ;
00363 const Valeur& vaz = (vect->operator()(3)).get_spectral_va() ;
00364 vax.coef() ;
00365 vay.coef() ;
00366 vaz.coef() ;
00367 const Mtbl_cf& cvax = *(vax.c_cf) ;
00368 const Mtbl_cf& cvay = *(vay.c_cf) ;
00369 const Mtbl_cf& cvaz = *(vaz.c_cf) ;
00370
00371
00372 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
00373
00374 fdata.precision(5) ;
00375 fdata.setf(ios::scientific) ;
00376
00377
00378
00379 double dx = (xmax - xmin) / double(nx-1) ;
00380 double dy = (ymax - ymin) / double(ny-1) ;
00381 double dz = (zmax - zmin) / double(nz-1) ;
00382
00383 int npoint = 0 ;
00384
00385 for (int k=0; k<nz; k++) {
00386
00387 double zz = zmin + dz * k ;
00388
00389 for (int j=0; j<ny; j++) {
00390
00391 double yy = ymin + dy * j ;
00392
00393 for (int i=0; i<nx; i++) {
00394
00395 double xx = xmin + dx * i ;
00396
00397
00398 double rr, th, ph ;
00399
00400
00401 mp->convert_absolute(xx, yy, zz, rr, th, ph) ;
00402
00403
00404 double xi ; int l ;
00405
00406 mp->val_lx(rr, th, ph, l, xi) ;
00407
00408
00409
00410 double vx = cvax.val_point(l, xi, th, ph) ;
00411 double vy = cvay.val_point(l, xi, th, ph) ;
00412 double vz = cvaz.val_point(l, xi, th, ph) ;
00413
00414 fdata.width(14) ; fdata << vx ;
00415 fdata.width(14) ; fdata << vy ;
00416 fdata.width(14) ; fdata << vz ;
00417 npoint++ ;
00418
00419 if (npoint == 3) {
00420 fdata << "\n" ;
00421 npoint = 0 ;
00422 }
00423
00424 }
00425 }
00426
00427 }
00428
00429 if (npoint != 0) fdata << "\n" ;
00430
00431 fdata.close() ;
00432
00433
00434
00435
00436
00437 char* headername ;
00438 if (filename0 == 0x0) {
00439 headername = new char[30] ;
00440 strcpy(headername, "vector3d_streamline.dxhead") ;
00441 }
00442 else {
00443 headername = new char[ strlen(filename0)+9 ] ;
00444 strcpy(headername, filename0) ;
00445 strcat(headername, ".dxhead") ;
00446 }
00447
00448 ofstream fheader(headername) ;
00449
00450 fheader << "file = " << filename << endl ;
00451 fheader << "grid = " << nx << " x " << ny << " x " << nz << endl ;
00452 fheader << "format = ascii" << endl ;
00453 fheader << "interleaving = record-vector" << endl ;
00454 fheader << "majority = column" << endl ;
00455 fheader << "header = lines 5" << endl ;
00456 fheader << "field = " << title_quotes << endl ;
00457 fheader << "structure = 3-vector" << endl ;
00458 fheader << "type = float" << endl ;
00459 fheader << "dependency = positions" << endl ;
00460 fheader << "positions = regular, regular, regular, "
00461 << xmin << ", " << dx << ", "
00462 << ymin << ", " << dy << ", "
00463 << zmin << ", " << dz << endl ;
00464 fheader << endl ;
00465 fheader << "end" << endl ;
00466
00467 fheader.close() ;
00468
00469
00470 if ( start_dx ) {
00471
00472 char* commande = new char[ strlen(headername) + 60 ] ;
00473 strcpy(commande, "ln -s ") ;
00474 strcat(commande, headername) ;
00475 strcat(commande, " visu_vector3d_SL.general") ;
00476
00477 system("rm -f visu_vector3d_SL.general") ;
00478 system(commande) ;
00479 system("dx -image visu_vector3d_SL.net &") ;
00480
00481 delete [] commande ;
00482 }
00483
00484
00485
00486
00487
00488 if (vect_tmp != 0x0) delete vect_tmp ;
00489 delete [] title ;
00490 delete [] title_quotes ;
00491 delete [] filename ;
00492 delete [] headername ;
00493
00494
00495 }
00496