34 #include "graphique_vtk.h" 35 #include "graphique.h" 38 #include "utilitaires.h" 42 void des_coupe_vtk_x(
const Scalar& uu,
double x0,
double y_min,
double y_max,
43 double z_min,
double z_max,
const char* title,
int ny,
int nz) {
47 const Map& mp = uu.get_mp() ;
60 double hy = (y_max - y_min) /
double(ny-1) ;
61 double hza = (z_max - z_min) /
double(nz-1) ;
64 char title2[256] = {
' '};
65 char title3[256] = {
' '};
68 c = char(tolower(title[ii]));
75 strcat(title3,title2);
76 strcat(title2,
"_x.vtk");
81 myfile <<
"# vtk DataFile Version 3.0" << endl;
82 myfile <<
"Data produced by mf_evolve" << endl;
83 myfile <<
"ASCII" << endl;
84 myfile <<
"DATASET RECTILINEAR_GRID" << endl;
85 myfile <<
"DIMENSIONS" <<
" " << nx <<
" " << ny <<
" " << nz << endl;
88 cout.setf(ios::scientific);
90 myfile <<
"X_COORDINATES " << nx <<
" FLOAT" << endl;
91 for ( i=0; i<nx; i++){
92 myfile << scientific << setprecision(12) <<
" " << x_min + hx * i <<
" " ;
96 myfile <<
"Y_COORDINATES " << ny <<
" FLOAT" << endl;
97 for ( i=0; i<ny; i++){
98 myfile <<
" " << y_min + hy * i <<
" " ;
102 myfile <<
"Z_COORDINATES " << nz <<
" FLOAT" << endl;
103 for ( i=0; i<nz; i++){
104 myfile <<
" " << z_min + hza * i <<
" " ;
108 myfile <<
"POINT_DATA " << nx*ny*nz << endl;
112 myfile <<
"SCALARS " << title3 <<
" FLOAT" << endl;
114 myfile <<
"LOOKUP_TABLE default" << endl;
116 for ( j=0; j<nz; j++) {
118 double z = z_min + hza * j ;
120 for ( i=0; i<ny; i++) {
122 double y = y_min + hy * i ;
125 double r, theta, phi ;
126 mp.convert_absolute(x0, y, z, r, theta, phi) ;
127 myfile <<
" " << float(uu.val_point(r, theta, phi)) << endl;
136 void des_coupe_vtk_x(
const Scalar& uu,
double x0,
int nzdes,
const char* title,
137 double zoom,
int ny,
int nz) {
139 const Map& mp = uu.get_mp() ;
141 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
142 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
143 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
144 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
146 ray = ( a1 > ray ) ? a1 : ray ;
147 ray = ( a2 > ray ) ? a2 : ray ;
148 ray = ( a3 > ray ) ? a3 : ray ;
152 double y_min = mp.get_ori_y() - ray ;
153 double y_max = mp.get_ori_y() + ray ;
154 double z_min = mp.get_ori_z() - ray ;
155 double z_max = mp.get_ori_z() + ray ;
157 printf(
"Printing %s to file\n",title);
165 void des_coupe_vtk_y(
const Scalar& uu,
double y0,
double x_min,
double x_max,
166 double z_min,
double z_max,
const char* title,
int nx,
int nz) {
170 const Map& mp = uu.get_mp() ;
183 double hx = (x_max - x_min) /
double(nx-1) ;
184 double hza = (z_max - z_min) /
double(nz-1) ;
187 char title2[256] = {
' '};
188 char title3[256] = {
' '};
191 c = char(tolower(title[ii]));
198 strcat(title3,title2);
199 strcat(title2,
"_y.vtk");
201 myfile.open (title2);
204 myfile <<
"# vtk DataFile Version 3.0" << endl;
205 myfile <<
"Data produced by mf_evolve" << endl;
206 myfile <<
"ASCII" << endl;
207 myfile <<
"DATASET RECTILINEAR_GRID" << endl;
208 myfile <<
"DIMENSIONS" <<
" " << nx <<
" " << ny <<
" " << nz << endl;
211 cout.setf(ios::scientific);
213 myfile <<
"X_COORDINATES " << nx <<
" FLOAT" << endl;
214 for ( i=0; i<nx; i++){
215 myfile << scientific << setprecision(12) <<
" " << x_min + hx * i <<
" " ;
219 myfile <<
"Y_COORDINATES " << ny <<
" FLOAT" << endl;
220 for ( i=0; i<ny; i++){
221 myfile <<
" " << y_min + hy * i <<
" " ;
225 myfile <<
"Z_COORDINATES " << nz <<
" FLOAT" << endl;
226 for ( i=0; i<nz; i++){
227 myfile <<
" " << z_min + hza * i <<
" " ;
231 myfile <<
"POINT_DATA " << nx*ny*nz << endl;
235 myfile <<
"SCALARS " << title3 <<
" FLOAT" << endl;
237 myfile <<
"LOOKUP_TABLE default" << endl;
240 for (j=0; j<nz; j++) {
242 double z = z_min + hza * j ;
244 for (i=0; i<nx; i++) {
246 double x = x_min + hx * i ;
249 double r, theta, phi ;
250 mp.convert_absolute(x, y0, z, r, theta, phi) ;
251 myfile <<
" " << float(uu.val_point(r, theta, phi)) << endl;
260 void des_coupe_vtk_y(
const Scalar& uu,
double y0,
int nzdes,
const char* title,
261 double zoom,
int nx,
int nz) {
263 const Map& mp = uu.get_mp() ;
265 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
266 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
267 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
268 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
270 ray = ( a1 > ray ) ? a1 : ray ;
271 ray = ( a2 > ray ) ? a2 : ray ;
272 ray = ( a3 > ray ) ? a3 : ray ;
276 double x_min = mp.get_ori_x() - ray ;
277 double x_max = mp.get_ori_x() + ray ;
278 double z_min = mp.get_ori_z() - ray ;
279 double z_max = mp.get_ori_z() + ray ;
281 printf(
"Printing %s to file\n",title);
288 void des_coupe_vtk_z(
const Scalar& uu,
double z0,
double x_min,
double x_max,
289 double y_min,
double y_max,
const char* title,
int nx,
int ny) {
293 const Map& mp = uu.get_mp() ;
307 double hy = (y_max - y_min) /
double(ny-1) ;
308 double hx = (x_max - x_min) /
double(nx-1) ;
311 char title2[256] = {
' '};
312 char title3[256] = {
' '};
315 c = char(tolower(title[ii]));
322 strcat(title3,title2);
323 strcat(title2,
"_z.vtk");
325 myfile.open (title2);
328 myfile <<
"# vtk DataFile Version 3.0" << endl;
329 myfile <<
"Data produced by mf_evolve" << endl;
330 myfile <<
"ASCII" << endl;
331 myfile <<
"DATASET RECTILINEAR_GRID" << endl;
332 myfile <<
"DIMENSIONS" <<
" " << nx <<
" " << ny <<
" " << nz << endl;
335 cout.setf(ios::scientific);
337 myfile <<
"X_COORDINATES " << nx <<
" FLOAT" << endl;
338 for ( i=0; i<nx; i++){
339 myfile << scientific << setprecision(12) <<
" " << x_min + hx * i <<
" " ;
343 myfile <<
"Y_COORDINATES " << ny <<
" FLOAT" << endl;
344 for ( i=0; i<ny; i++){
345 myfile <<
" " << y_min + hy * i <<
" " ;
349 myfile <<
"Z_COORDINATES " << nz <<
" FLOAT" << endl;
350 for ( i=0; i<nz; i++){
351 myfile <<
" " << z_min + hza * i <<
" " ;
355 myfile <<
"POINT_DATA " << nx*ny*nz << endl;
359 myfile <<
"SCALARS " << title3 <<
" FLOAT" << endl;
361 myfile <<
"LOOKUP_TABLE default" << endl;
362 for (j=0; j<ny; j++) {
364 double y = y_min + hy * j ;
366 for (i=0; i<nx; i++) {
368 double x = x_min + hx * i ;
371 double r, theta, phi ;
372 mp.convert_absolute(x, y, z0, r, theta, phi) ;
373 myfile <<
" " << float(uu.val_point(r, theta, phi)) << endl;
380 void des_coupe_vtk_z(
const Scalar& uu,
double z0,
int nzdes,
const char* title,
381 double zoom,
int nx,
int ny) {
383 const Map& mp = uu.get_mp() ;
385 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
386 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
387 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
388 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
390 ray = ( a1 > ray ) ? a1 : ray ;
391 ray = ( a2 > ray ) ? a2 : ray ;
392 ray = ( a3 > ray ) ? a3 : ray ;
396 double x_min = mp.get_ori_x() - ray ;
397 double x_max = mp.get_ori_x() + ray ;
398 double y_min = mp.get_ori_y() - ray ;
399 double y_max = mp.get_ori_y() + ray ;
401 printf(
"Printing %s to file\n",title);
409 void des_vtk_xyz(
const Scalar& uu,
double x_min,
double x_max,
double y_min,
410 double y_max,
double z_min,
double z_max,
411 const char* title,
int nx,
int ny,
int nz) {
415 const Map& mp = uu.get_mp() ;
424 double hx = (x_max - x_min) /
double(nx-1) ;
425 double hy = (y_max - y_min) /
double(ny-1) ;
426 double hz = (z_max - z_min) /
double(nz-1) ;
429 char title2[256] = {
' '};
430 char title3[256] = {
' '};
433 c = char(tolower(title[ii]));
440 strcat(title3,title2);
441 strcat(title2,
"_xyz.vtk");
443 myfile.open (title2);
446 myfile <<
"# vtk DataFile Version 3.0" << endl;
447 myfile <<
"Data produced by mf_evolve" << endl;
448 myfile <<
"ASCII" << endl;
449 myfile <<
"DATASET RECTILINEAR_GRID" << endl;
450 myfile <<
"DIMENSIONS" <<
" " << nx <<
" " << ny <<
" " << nz << endl;
453 cout.setf(ios::scientific);
455 myfile <<
"X_COORDINATES " << nx <<
" FLOAT" << endl;
456 for ( i=0; i<nx; i++){
457 myfile << scientific << setprecision(12) <<
" " << x_min + hx * i <<
" " ;
461 myfile <<
"Y_COORDINATES " << ny <<
" FLOAT" << endl;
462 for ( i=0; i<ny; i++){
463 myfile <<
" " << y_min + hy * i <<
" " ;
467 myfile <<
"Z_COORDINATES " << nz <<
" FLOAT" << endl;
468 for ( i=0; i<nz; i++){
469 myfile <<
" " << z_min + hz * i <<
" " ;
473 myfile <<
"POINT_DATA " << nx*ny*nz << endl;
477 myfile <<
"SCALARS " << title3 <<
" FLOAT" << endl;
479 myfile <<
"LOOKUP_TABLE default" << endl;
481 for ( k=0; k<nx; k++) {
483 double x = x_min + hx * k ;
485 for ( j=0; j<nz; j++) {
487 double z = z_min + hz * j ;
489 for ( i=0; i<ny; i++) {
491 double y = y_min + hy * i ;
494 double r, theta, phi ;
495 mp.convert_absolute(x, y, z, r, theta, phi) ;
497 myfile <<
" " << uu.val_point(r, theta, phi) << endl;
507 void des_vtk_xyz(
const Scalar& uu,
int nzdes,
const char* title,
508 int nx,
int ny,
int nz) {
510 const Map& mp = uu.get_mp() ;
512 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
513 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
514 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
515 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
517 ray = ( a1 > ray ) ? a1 : ray ;
518 ray = ( a2 > ray ) ? a2 : ray ;
519 ray = ( a3 > ray ) ? a3 : ray ;
521 double x_min = mp.get_ori_x() - ray ;
522 double x_max = mp.get_ori_x() + ray ;
523 double y_min = mp.get_ori_y() - ray ;
524 double y_max = mp.get_ori_y() + ray ;
525 double z_min = mp.get_ori_z() - ray ;
526 double z_max = mp.get_ori_z() + ray ;
528 printf(
"Printing %s to file\n",title);
529 des_vtk_xyz(uu, x_min, x_max, y_min, y_max, z_min, z_max, title,
void des_coupe_vtk_y(const Scalar &uu, double y0, int nzdes, const char *title=0x0, double zoom=1.2, int nx=100, int nz=100)
Saves the data for a Scalar in the plane Y=constant.
Standard units of space, time and mass.
void des_vtk_xyz(const Scalar &uu, int nzdes, const char *title=0x0, int nx=100, int ny=100, int nz=100)
Saves a three dimensional Scalar.
void des_coupe_vtk_x(const Scalar &uu, double x0, int nzdes, const char *title=0x0, double zoom=1.2, int ny=100, int nz=100)
Saves the data for a Scalar in the plane X=constant.
void des_coupe_vtk_z(const Scalar &uu, double z0, int nzdes, const char *title=0x0, double zoom=1.2, int nx=100, int ny=100)
Saves the data for a Scalar in the plane Z=constant.