| 1 |
/* |
| 2 |
* Copyright (c) 2005 Eric Gourgoulhon |
| 3 |
* |
| 4 |
* This file is part of LORENE. |
| 5 |
* |
| 6 |
* LORENE is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* LORENE is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with LORENE; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
|
| 23 |
char des_coupe_vector_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_vector.C,v 1.4 2014/10/13 08:53:22 j_novak Exp $" ; |
| 24 |
|
| 25 |
/* |
| 26 |
* $Id: des_coupe_vector.C,v 1.4 2014/10/13 08:53:22 j_novak Exp $ |
| 27 |
* $Log: des_coupe_vector.C,v $ |
| 28 |
* Revision 1.4 2014/10/13 08:53:22 j_novak |
| 29 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 30 |
* |
| 31 |
* Revision 1.3 2014/10/06 15:16:04 j_novak |
| 32 |
* Modified #include directives to use c++ syntax. |
| 33 |
* |
| 34 |
* Revision 1.2 2008/08/19 06:42:00 j_novak |
| 35 |
* Minor modifications to avoid warnings with gcc 4.3. Most of them concern |
| 36 |
* cast-type operations, and constant strings that must be defined as const char* |
| 37 |
* |
| 38 |
* Revision 1.1 2005/03/24 22:01:07 e_gourgoulhon |
| 39 |
* Plot of a vector field represented by a Vector. |
| 40 |
* |
| 41 |
* |
| 42 |
* $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_vector.C,v 1.4 2014/10/13 08:53:22 j_novak Exp $ |
| 43 |
* |
| 44 |
*/ |
| 45 |
|
| 46 |
|
| 47 |
// Header C |
| 48 |
#include <cmath> |
| 49 |
|
| 50 |
// Header Lorene |
| 51 |
#include "tensor.h" |
| 52 |
#include "graphique.h" |
| 53 |
#include "param.h" |
| 54 |
#include "utilitaires.h" |
| 55 |
#include "unites.h" |
| 56 |
|
| 57 |
namespace Lorene { |
| 58 |
//****************************************************************************** |
| 59 |
|
| 60 |
void des_coupe_vect_x(const Vector& vv, double x0, double scale, double sizefl, |
| 61 |
int nzdes, const char* title, const Scalar* defsurf, double zoom, |
| 62 |
bool draw_bound, int ny, int nz) { |
| 63 |
|
| 64 |
const Map& mp = vv.get_mp() ; |
| 65 |
|
| 66 |
double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ; |
| 67 |
double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ; |
| 68 |
double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ; |
| 69 |
double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; |
| 70 |
|
| 71 |
ray = ( a1 > ray ) ? a1 : ray ; |
| 72 |
ray = ( a2 > ray ) ? a2 : ray ; |
| 73 |
ray = ( a3 > ray ) ? a3 : ray ; |
| 74 |
|
| 75 |
ray *= zoom ; |
| 76 |
|
| 77 |
double y_min = mp.get_ori_y() - ray ; |
| 78 |
double y_max = mp.get_ori_y() + ray ; |
| 79 |
double z_min = mp.get_ori_z() - ray ; |
| 80 |
double z_max = mp.get_ori_z() + ray ; |
| 81 |
|
| 82 |
des_coupe_vect_x(vv, x0, scale, sizefl, y_min, y_max, z_min, z_max, title, |
| 83 |
defsurf, draw_bound, ny, nz) ; |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
//****************************************************************************** |
| 90 |
|
| 91 |
void des_coupe_vect_x(const Vector& vv, double x0, double scale, double |
| 92 |
sizefl, double y_min, double y_max, double z_min, |
| 93 |
double z_max, const char* title, const Scalar* defsurf, |
| 94 |
bool draw_bound, int ny, int nz) { |
| 95 |
|
| 96 |
using namespace Unites ; |
| 97 |
|
| 98 |
const Map& mp = vv.get_mp() ; |
| 99 |
|
| 100 |
if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) { |
| 101 |
cout << |
| 102 |
"des_coupe_vect_x: the vector must be given in Cartesian components !" |
| 103 |
<< endl ; |
| 104 |
abort() ; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
// Plot of the vector field |
| 109 |
// ------------------------ |
| 110 |
|
| 111 |
float* vvy = new float[ny*nz] ; |
| 112 |
float* vvz = new float[ny*nz] ; |
| 113 |
|
| 114 |
double hy = (y_max - y_min) / double(ny-1) ; |
| 115 |
double hza = (z_max - z_min) / double(nz-1) ; |
| 116 |
|
| 117 |
for (int j=0; j<nz; j++) { |
| 118 |
|
| 119 |
double z = z_min + hza * j ; |
| 120 |
|
| 121 |
for (int i=0; i<ny; i++) { |
| 122 |
|
| 123 |
double y = y_min + hy * i ; |
| 124 |
|
| 125 |
// Computation of (r,theta,phi) : |
| 126 |
double r, theta, phi ; |
| 127 |
mp.convert_absolute(x0, y, z, r, theta, phi) ; |
| 128 |
|
| 129 |
vvy[ny*j+i] = float(vv(2).val_point(r, theta, phi)) ; |
| 130 |
vvz[ny*j+i] = float(vv(3).val_point(r, theta, phi)) ; |
| 131 |
|
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
float ymin1 = float(y_min / km) ; |
| 136 |
float ymax1 = float(y_max / km) ; |
| 137 |
float zmin1 = float(z_min / km) ; |
| 138 |
float zmax1 = float(z_max / km) ; |
| 139 |
|
| 140 |
const char* nomy = "y [km]" ; |
| 141 |
const char* nomz = "z [km]" ; |
| 142 |
|
| 143 |
if (title == 0x0) { |
| 144 |
title = "" ; |
| 145 |
} |
| 146 |
|
| 147 |
const char* device = 0x0 ; |
| 148 |
int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; |
| 149 |
|
| 150 |
des_vect(vvy, vvz, ny, nz, ymin1, ymax1, zmin1, zmax1, |
| 151 |
scale, sizefl, nomy, nomz, title, device, newgraph) ; |
| 152 |
|
| 153 |
|
| 154 |
delete [] vvy ; |
| 155 |
delete [] vvz ; |
| 156 |
|
| 157 |
// Plot of the surface |
| 158 |
// ------------------- |
| 159 |
|
| 160 |
if (defsurf != 0x0) { |
| 161 |
|
| 162 |
assert( &(defsurf->get_mp()) == &mp ) ; |
| 163 |
|
| 164 |
newgraph = draw_bound ? 0 : 2 ; |
| 165 |
|
| 166 |
des_surface_x(*defsurf, x0, device, newgraph) ; |
| 167 |
|
| 168 |
} // End of the surface drawing |
| 169 |
|
| 170 |
|
| 171 |
// Plot of the domains outer boundaries |
| 172 |
// ------------------------------------ |
| 173 |
|
| 174 |
if (draw_bound) { |
| 175 |
|
| 176 |
int ndom = mp.get_mg()->get_nzone() ; // total number of domains |
| 177 |
|
| 178 |
for (int l=0; l<ndom-1; l++) { // loop on the domains (except the |
| 179 |
// last one) |
| 180 |
|
| 181 |
newgraph = (l == ndom-2) ? 2 : 0 ; |
| 182 |
|
| 183 |
des_domaine_x(mp, l, x0, device, newgraph) ; |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
//****************************************************************************** |
| 193 |
|
| 194 |
void des_coupe_vect_y(const Vector& vv, double y0, double scale, double sizefl, |
| 195 |
int nzdes, const char* title, const Scalar* defsurf, double zoom, |
| 196 |
bool draw_bound, int nx, int nz) { |
| 197 |
|
| 198 |
const Map& mp = vv.get_mp() ; |
| 199 |
|
| 200 |
double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ; |
| 201 |
double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ; |
| 202 |
double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ; |
| 203 |
double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; |
| 204 |
|
| 205 |
ray = ( a1 > ray ) ? a1 : ray ; |
| 206 |
ray = ( a2 > ray ) ? a2 : ray ; |
| 207 |
ray = ( a3 > ray ) ? a3 : ray ; |
| 208 |
|
| 209 |
ray *= zoom ; |
| 210 |
|
| 211 |
double x_min = mp.get_ori_x() - ray ; |
| 212 |
double x_max = mp.get_ori_x() + ray ; |
| 213 |
double z_min = mp.get_ori_z() - ray ; |
| 214 |
double z_max = mp.get_ori_z() + ray ; |
| 215 |
|
| 216 |
|
| 217 |
des_coupe_vect_y(vv, y0, scale, sizefl, x_min, x_max, z_min, z_max, title, |
| 218 |
defsurf, draw_bound, nx, nz) ; |
| 219 |
|
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
//****************************************************************************** |
| 225 |
|
| 226 |
void des_coupe_vect_y(const Vector& vv, double y0, double scale, double |
| 227 |
sizefl, double x_min, double x_max, double z_min, |
| 228 |
double z_max, const char* title, const Scalar* defsurf, |
| 229 |
bool draw_bound, int nx, int nz) { |
| 230 |
|
| 231 |
using namespace Unites ; |
| 232 |
|
| 233 |
const Map& mp = vv.get_mp() ; |
| 234 |
|
| 235 |
if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) { |
| 236 |
cout << |
| 237 |
"des_coupe_vect_y: the vector must be given in Cartesian components !" |
| 238 |
<< endl ; |
| 239 |
abort() ; |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
// Plot of the vector field |
| 244 |
// ------------------------ |
| 245 |
|
| 246 |
float* vvx = new float[nx*nz] ; |
| 247 |
float* vvz = new float[nx*nz] ; |
| 248 |
|
| 249 |
double hx = (x_max - x_min) / double(nx-1) ; |
| 250 |
double hza = (z_max - z_min) / double(nz-1) ; |
| 251 |
|
| 252 |
for (int j=0; j<nz; j++) { |
| 253 |
|
| 254 |
double z = z_min + hza * j ; |
| 255 |
|
| 256 |
for (int i=0; i<nx; i++) { |
| 257 |
|
| 258 |
double x = x_min + hx * i ; |
| 259 |
|
| 260 |
// Computation of (r,theta,phi) : |
| 261 |
double r, theta, phi ; |
| 262 |
mp.convert_absolute(x, y0, z, r, theta, phi) ; |
| 263 |
|
| 264 |
vvx[nx*j+i] = float(vv(1).val_point(r, theta, phi)) ; |
| 265 |
vvz[nx*j+i] = float(vv(3).val_point(r, theta, phi)) ; |
| 266 |
|
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
float xmin1 = float(x_min / km) ; |
| 271 |
float xmax1 = float(x_max / km) ; |
| 272 |
float zmin1 = float(z_min / km) ; |
| 273 |
float zmax1 = float(z_max / km) ; |
| 274 |
|
| 275 |
const char* nomx = "x [km]" ; |
| 276 |
const char* nomz = "z [km]" ; |
| 277 |
|
| 278 |
if (title == 0x0) { |
| 279 |
title = "" ; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
const char* device = 0x0 ; |
| 284 |
int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; |
| 285 |
|
| 286 |
des_vect(vvx, vvz, nx, nz, xmin1, xmax1, zmin1, zmax1, |
| 287 |
scale, sizefl, nomx, nomz, title, device, newgraph) ; |
| 288 |
|
| 289 |
|
| 290 |
delete [] vvx ; |
| 291 |
delete [] vvz ; |
| 292 |
|
| 293 |
// Plot of the surface |
| 294 |
// ------------------- |
| 295 |
|
| 296 |
if (defsurf != 0x0) { |
| 297 |
|
| 298 |
assert( &(defsurf->get_mp()) == &mp ) ; |
| 299 |
|
| 300 |
newgraph = draw_bound ? 0 : 2 ; |
| 301 |
|
| 302 |
des_surface_y(*defsurf, y0, device, newgraph) ; |
| 303 |
|
| 304 |
} // End of the surface drawing |
| 305 |
|
| 306 |
|
| 307 |
// Plot of the domains outer boundaries |
| 308 |
// ------------------------------------ |
| 309 |
|
| 310 |
if (draw_bound) { |
| 311 |
|
| 312 |
int ndom = mp.get_mg()->get_nzone() ; // total number of domains |
| 313 |
|
| 314 |
for (int l=0; l<ndom-1; l++) { // loop on the domains (except the |
| 315 |
// last one) |
| 316 |
|
| 317 |
newgraph = (l == ndom-2) ? 2 : 0 ; |
| 318 |
|
| 319 |
des_domaine_y(mp, l, y0, device, newgraph) ; |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
//****************************************************************************** |
| 328 |
|
| 329 |
void des_coupe_vect_z(const Vector& vv, double z0, double scale, double sizefl, |
| 330 |
int nzdes, const char* title, const Scalar* defsurf, double zoom, |
| 331 |
bool draw_bound, int nx, int ny) { |
| 332 |
|
| 333 |
const Map& mp = vv.get_mp() ; |
| 334 |
|
| 335 |
double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ; |
| 336 |
double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ; |
| 337 |
double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ; |
| 338 |
double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; |
| 339 |
|
| 340 |
ray = ( a1 > ray ) ? a1 : ray ; |
| 341 |
ray = ( a2 > ray ) ? a2 : ray ; |
| 342 |
ray = ( a3 > ray ) ? a3 : ray ; |
| 343 |
|
| 344 |
ray *= zoom ; |
| 345 |
|
| 346 |
double x_min = mp.get_ori_x() - ray ; |
| 347 |
double x_max = mp.get_ori_x() + ray ; |
| 348 |
double y_min = mp.get_ori_y() - ray ; |
| 349 |
double y_max = mp.get_ori_y() + ray ; |
| 350 |
|
| 351 |
des_coupe_vect_z(vv, z0, scale, sizefl, x_min, x_max, y_min, y_max, title, |
| 352 |
defsurf, draw_bound, nx, ny) ; |
| 353 |
|
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
//****************************************************************************** |
| 359 |
|
| 360 |
void des_coupe_vect_z(const Vector& vv, double z0, double scale, double |
| 361 |
sizefl, double x_min, double x_max, double y_min, |
| 362 |
double y_max, const char* title, const Scalar* defsurf, |
| 363 |
bool draw_bound, int nx, int ny) { |
| 364 |
|
| 365 |
using namespace Unites ; |
| 366 |
|
| 367 |
const Map& mp = vv.get_mp() ; |
| 368 |
|
| 369 |
if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) { |
| 370 |
cout << |
| 371 |
"des_coupe_vect_y: the vector must be given in Cartesian components !" |
| 372 |
<< endl ; |
| 373 |
abort() ; |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
// Plot of the vector field |
| 378 |
// ------------------------ |
| 379 |
|
| 380 |
float* vvx = new float[nx*ny] ; |
| 381 |
float* vvy = new float[nx*ny] ; |
| 382 |
|
| 383 |
double hy = (y_max - y_min) / double(ny-1) ; |
| 384 |
double hx = (x_max - x_min) / double(nx-1) ; |
| 385 |
|
| 386 |
for (int j=0; j<ny; j++) { |
| 387 |
|
| 388 |
double y = y_min + hy * j ; |
| 389 |
|
| 390 |
for (int i=0; i<nx; i++) { |
| 391 |
|
| 392 |
double x = x_min + hx * i ; |
| 393 |
|
| 394 |
// Computation of (r,theta,phi) : |
| 395 |
double r, theta, phi ; |
| 396 |
mp.convert_absolute(x, y, z0, r, theta, phi) ; |
| 397 |
|
| 398 |
vvx[nx*j+i] = float(vv(1).val_point(r, theta, phi)) ; |
| 399 |
vvy[nx*j+i] = float(vv(2).val_point(r, theta, phi)) ; |
| 400 |
|
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
float ymin1 = float(y_min / km) ; |
| 405 |
float ymax1 = float(y_max / km) ; |
| 406 |
float xmin1 = float(x_min / km) ; |
| 407 |
float xmax1 = float(x_max / km) ; |
| 408 |
|
| 409 |
const char* nomy = "y [km]" ; |
| 410 |
const char* nomx = "x [km]" ; |
| 411 |
|
| 412 |
if (title == 0x0) { |
| 413 |
title = "" ; |
| 414 |
} |
| 415 |
|
| 416 |
const char* device = 0x0 ; |
| 417 |
int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; |
| 418 |
|
| 419 |
des_vect(vvx, vvy, nx, ny, xmin1, xmax1, ymin1, ymax1, |
| 420 |
scale, sizefl, nomx, nomy, title, device, newgraph) ; |
| 421 |
|
| 422 |
|
| 423 |
delete [] vvx ; |
| 424 |
delete [] vvy ; |
| 425 |
|
| 426 |
// Plot of the surface |
| 427 |
// ------------------- |
| 428 |
|
| 429 |
if (defsurf != 0x0) { |
| 430 |
|
| 431 |
assert( &(defsurf->get_mp()) == &mp ) ; |
| 432 |
|
| 433 |
newgraph = draw_bound ? 0 : 2 ; |
| 434 |
|
| 435 |
des_surface_z(*defsurf, z0, device, newgraph) ; |
| 436 |
|
| 437 |
} // End of the surface drawing |
| 438 |
|
| 439 |
// Plot of the domains outer boundaries |
| 440 |
// ------------------------------------ |
| 441 |
|
| 442 |
if (draw_bound) { |
| 443 |
|
| 444 |
int ndom = mp.get_mg()->get_nzone() ; // total number of domains |
| 445 |
|
| 446 |
for (int l=0; l<ndom-1; l++) { // loop on the domains (except the |
| 447 |
// last one) |
| 448 |
|
| 449 |
newgraph = (l == ndom-2) ? 2 : 0 ; |
| 450 |
|
| 451 |
des_domaine_z(mp, l, z0, device, newgraph) ; |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
} |
| 456 |
} |