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 char des_profile_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_profile.C,v 1.9 2012/01/17 10:35:46 j_penner Exp $" ;
00028
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 #include"headcpp.h"
00073
00074
00075 #include <stdlib.h>
00076 #include <math.h>
00077 #include <cpgplot.h>
00078
00079
00080
00081
00082
00083
00084 void des_profile(const float* uutab, int nx, float xmin, float xmax,
00085 const char* nomx, const char* nomy,
00086 const char* title, const char* device,
00087 int nbound, float* xbound) {
00088
00089
00090
00091
00092 float uumin = uutab[0] ;
00093 float uumax = uutab[0] ;
00094 for (int i=1; i<nx; i++) {
00095 uumin = (uutab[i] < uumin) ? uutab[i] : uumin ;
00096 uumax = (uutab[i] > uumax) ? uutab[i] : uumax ;
00097 }
00098
00099 cout << " " << nomy << " : min, max : " << uumin << " " << uumax
00100 << endl ;
00101
00102
00103
00104
00105 float* xx = new float[nx] ;
00106 float hx = (xmax-xmin)/float(nx-1) ;
00107 for(int i=0; i<nx; i++) {
00108 xx[i] = xmin + float(i) * hx ;
00109 }
00110
00111
00112
00113
00114 if (device == 0x0) {
00115 device = "?" ;
00116 }
00117
00118 int ier = cpgbeg(0, device, 1, 1) ;
00119 if (ier != 1) {
00120 cout << "des_profile: problem in opening PGPLOT display !" << endl ;
00121 }
00122
00123
00124 float size = float(1.3) ;
00125 cpgsch(size) ;
00126
00127
00128 int lepais = 1 ;
00129 cpgslw(lepais) ;
00130
00131
00132 cpgscf(2) ;
00133
00134
00135 float uuamp = uumax - uumin ;
00136 float uumin1 = uumin - float(0.05) * uuamp ;
00137 float uumax1 = uumax + float(0.05) * uuamp ;
00138 cpgenv(xmin, xmax, uumin1, uumax1, 0, 0 ) ;
00139 cpglab(nomx,nomy,title) ;
00140
00141
00142 cpgline(nx, xx, uutab) ;
00143
00144
00145
00146
00147
00148 if (nbound > 0) {
00149 float xb[2] ;
00150 float yb[2] ;
00151 yb[0] = uumin1 ;
00152 yb[1] = uumax1 ;
00153 cpgsls(3) ;
00154 cpgsci(3) ;
00155 for (int i=0; i<nbound; i++) {
00156 xb[0] = xbound[i] ;
00157 xb[1] = xbound[i] ;
00158 cpgline(2, xb, yb) ;
00159 }
00160 cpgsls(1) ;
00161 cpgsci(1) ;
00162 }
00163
00164 cpgend() ;
00165
00166 delete [] xx ;
00167
00168 }
00169
00170
00171
00172
00173
00174
00175
00176 void des_profile_mult(const float* uutab, int nprof, int nx,
00177 float xmin, float xmax, const char* nomx, const char* nomy,
00178 const char* title, const int* line_style,
00179 int ngraph, bool closeit, const char* device,
00180 int nbound, float* xbound) {
00181
00182 const int ngraph_max = 100 ;
00183 static int graph_list[ngraph_max] ;
00184 static bool first_call = true ;
00185
00186
00187
00188
00189 if (first_call) {
00190 for (int i=0; i<ngraph_max; i++) {
00191 graph_list[i] = 0 ;
00192 }
00193 first_call = false ;
00194 }
00195
00196
00197
00198
00199
00200 int ntot = nprof * nx ;
00201 float uumin = uutab[0] ;
00202 float uumax = uutab[0] ;
00203 for (int i=1; i<ntot; i++) {
00204 if (uutab[i] < uumin) uumin = uutab[i] ;
00205 if (uutab[i] > uumax) uumax = uutab[i] ;
00206 }
00207
00208 cout << " " << nomy << " : min, max : " << uumin << " " << uumax
00209 << endl ;
00210
00211
00212
00213
00214 float* xx = new float[nx] ;
00215 float hx = (xmax-xmin)/float(nx-1) ;
00216 for(int i=0; i<nx; i++) {
00217 xx[i] = xmin + float(i) * hx ;
00218 }
00219
00220
00221
00222
00223
00224
00225 if ( (ngraph < 0) || (ngraph >= ngraph_max) ) {
00226 cerr << "des_profile_mult : graph index out of range ! \n" ;
00227 cerr << " ngraph = " << ngraph << " while range = 0, "
00228 << ngraph_max-1 << endl ;
00229 abort() ;
00230 }
00231
00232 if (graph_list[ngraph] == 0) {
00233
00234
00235 if (device == 0x0) device = "?" ;
00236
00237 graph_list[ngraph] = cpgopen(device) ;
00238
00239 if ( graph_list[ngraph] <= 0 ) {
00240 cerr << "des_profile_mult: problem in opening PGPLOT display !\n" ;
00241 abort() ;
00242 }
00243
00244 cpgask(0) ;
00245
00246 }
00247 else {
00248
00249 cpgslct( graph_list[ngraph] ) ;
00250 }
00251
00252
00253
00254
00255
00256 float size = float(1.3) ;
00257 cpgsch(size) ;
00258
00259
00260 int lepais = 1 ;
00261 cpgslw(lepais) ;
00262
00263
00264 cpgscf(2) ;
00265
00266
00267 float uuamp = uumax - uumin ;
00268 float uumin1 = uumin - float(0.05) * uuamp ;
00269 float uumax1 = uumax + float(0.05) * uuamp ;
00270 cpgsls(1) ;
00271 cpgenv(xmin, xmax, uumin1, uumax1, 0, 0 ) ;
00272 cpglab(nomx,nomy,title) ;
00273
00274
00275 for (int i=0; i<nprof; i++) {
00276 const float* uudes = uutab + i*nx ;
00277
00278 if (line_style == 0x0) cpgsls(i%5 + 1) ;
00279 else cpgsls(line_style[i]) ;
00280
00281 cpgline(nx, xx, uudes) ;
00282 }
00283
00284
00285
00286
00287 if (nbound > 0) {
00288 float xb[2] ;
00289 float yb[2] ;
00290 yb[0] = uumin1 ;
00291 yb[1] = uumax1 ;
00292 cpgsls(3) ;
00293 cpgsci(3) ;
00294 for (int i=0; i<nbound; i++) {
00295 xb[0] = xbound[i] ;
00296 xb[1] = xbound[i] ;
00297 cpgline(2, xb, yb) ;
00298 }
00299 cpgsls(1) ;
00300 cpgsci(1) ;
00301 }
00302
00303
00304 if (closeit) {
00305 cpgclos() ;
00306 graph_list[ngraph] = 0 ;
00307 }
00308
00309 delete [] xx ;
00310
00311 }
00312
00313
00314
00315
00316
00317
00318 void des_profile(const float* uutab, int nx, const float *xtab,
00319 const char* nomx, const char* nomy,
00320 const char* title, const char* device,
00321 int nbound, float* xbound) {
00322
00323
00324
00325
00326 float uumin = uutab[0] ;
00327 float uumax = uutab[0] ;
00328 float xmin = xtab[0] ;
00329 float xmax = xtab[0] ;
00330 for (int i=1; i<nx; i++) {
00331 uumin = (uutab[i] < uumin) ? uutab[i] : uumin ;
00332 uumax = (uutab[i] > uumax) ? uutab[i] : uumax ;
00333 xmin = (xtab[i] < xmin) ? xtab[i] : xmin ;
00334 xmax = (xtab[i] > xmax) ? xtab[i] : xmax ;
00335 }
00336
00337 cout << " " << nomy << " : min, max : " << uumin << " " << uumax << endl;
00338 cout << " " << "domain: " << "min, max : " << xmin << " " << xmax << endl ;
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 if (device == 0x0) {
00353 device = "?" ;
00354 }
00355
00356 int ier = cpgbeg(0, device, 1, 1) ;
00357 if (ier != 1) {
00358 cout << "des_profile: problem in opening PGPLOT display !" << endl ;
00359 }
00360
00361
00362 float size = float(1.3) ;
00363 cpgsch(size) ;
00364
00365
00366 int lepais = 1 ;
00367 cpgslw(lepais) ;
00368
00369
00370 cpgscf(2) ;
00371
00372
00373 float uuamp = uumax - uumin ;
00374 float uumin1 = uumin - float(0.05) * uuamp ;
00375 float uumax1 = uumax + float(0.05) * uuamp ;
00376 cpgenv(xmin, xmax, uumin1, uumax1, 0, 0 ) ;
00377 cpglab(nomx,nomy,title) ;
00378
00379
00380 cpgline(nx, xtab, uutab) ;
00381
00382
00383
00384
00385
00386 if (nbound > 0) {
00387 float xb[2] ;
00388 float yb[2] ;
00389 yb[0] = uumin1 ;
00390 yb[1] = uumax1 ;
00391 cpgsls(3) ;
00392 cpgsci(3) ;
00393 for (int i=0; i<nbound; i++) {
00394 xb[0] = xbound[i] ;
00395 xb[1] = xbound[i] ;
00396 cpgline(2, xb, yb) ;
00397 }
00398 cpgsls(1) ;
00399 cpgsci(1) ;
00400 }
00401
00402 cpgend() ;
00403
00404 }
00405
00406
00407
00408
00409
00410
00411
00412 void des_profile_mult(const float* uutab, int nprof, int nx, const float* xtab,
00413 const char* nomx, const char* nomy, const char* title,
00414 const int* line_style, int ngraph, bool closeit,
00415 const char* device, int nbound, float* xbound) {
00416
00417 const int ngraph_max = 100 ;
00418 static int graph_list[ngraph_max] ;
00419 static bool first_call = true ;
00420
00421
00422
00423
00424 if (first_call) {
00425 for (int i=0; i<ngraph_max; i++) {
00426 graph_list[i] = 0 ;
00427 }
00428 first_call = false ;
00429 }
00430
00431
00432
00433
00434
00435 int ntot = nprof * nx ;
00436 float uumin = uutab[0] ;
00437 float uumax = uutab[0] ;
00438 for (int i=1; i<ntot; i++) {
00439 if (uutab[i] < uumin) uumin = uutab[i] ;
00440 if (uutab[i] > uumax) uumax = uutab[i] ;
00441 }
00442
00443 float xmin = xtab[0] ;
00444 float xmax = xtab[0] ;
00445 for (int i=1; i<ntot; i++) {
00446 if (xtab[i] < xmin) xmin = xtab[i] ;
00447 if (xtab[i] > xmax) xmax = xtab[i] ;
00448 }
00449
00450 cout << " " << nomy << " : min, max : " << uumin << " " << uumax
00451 << endl ;
00452
00453
00454
00455
00456
00457
00458
00459 if ( (ngraph < 0) || (ngraph >= ngraph_max) ) {
00460 cerr << "des_profile_mult : graph index out of range ! \n" ;
00461 cerr << " ngraph = " << ngraph << " while range = 0, "
00462 << ngraph_max-1 << endl ;
00463 abort() ;
00464 }
00465
00466 if (graph_list[ngraph] == 0) {
00467
00468
00469 if (device == 0x0) device = "?" ;
00470
00471 graph_list[ngraph] = cpgopen(device) ;
00472
00473 if ( graph_list[ngraph] <= 0 ) {
00474 cerr << "des_profile_mult: problem in opening PGPLOT display !\n" ;
00475 abort() ;
00476 }
00477
00478 cpgask(0) ;
00479
00480 }
00481 else {
00482
00483 cpgslct( graph_list[ngraph] ) ;
00484 }
00485
00486
00487
00488
00489
00490 float size = float(1.3) ;
00491 cpgsch(size) ;
00492
00493
00494 int lepais = 1 ;
00495 cpgslw(lepais) ;
00496
00497
00498 cpgscf(2) ;
00499
00500
00501 float uuamp = uumax - uumin ;
00502 float uumin1 = uumin - float(0.05) * uuamp ;
00503 float uumax1 = uumax + float(0.05) * uuamp ;
00504 cpgsls(1) ;
00505 cpgenv(xmin, xmax, uumin1, uumax1, 0, 0 ) ;
00506 cpglab(nomx,nomy,title) ;
00507
00508
00509 for (int i=0; i<nprof; i++) {
00510 const float* uudes = uutab + i*nx ;
00511 const float* xdes = xtab + i*nx ;
00512
00513 if (line_style == 0x0) cpgsls(i%5 + 1) ;
00514 else cpgsls(line_style[i]) ;
00515
00516 cpgline(nx, xdes, uudes) ;
00517 }
00518
00519
00520
00521
00522 if (nbound > 0) {
00523 float xb[2] ;
00524 float yb[2] ;
00525 yb[0] = uumin1 ;
00526 yb[1] = uumax1 ;
00527 cpgsls(3) ;
00528 cpgsci(3) ;
00529 for (int i=0; i<nbound; i++) {
00530 xb[0] = xbound[i] ;
00531 xb[1] = xbound[i] ;
00532 cpgline(2, xb, yb) ;
00533 }
00534 cpgsls(1) ;
00535 cpgsci(1) ;
00536 }
00537
00538 if (closeit) {
00539 cpgclos() ;
00540 graph_list[ngraph] = 0 ;
00541 }
00542
00543 }
00544