LORENE
des_vect_bin.C
1/*
2 * Copyright (c) 2000-2001 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
24
25/*
26 * $Id: des_vect_bin.C,v 1.7 2016/12/05 16:18:07 j_novak Exp $
27 * $Log: des_vect_bin.C,v $
28 * Revision 1.7 2016/12/05 16:18:07 j_novak
29 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30 *
31 * Revision 1.6 2014/10/13 08:53:23 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.5 2014/10/06 15:16:05 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.4 2008/08/19 06:42:00 j_novak
38 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
39 * cast-type operations, and constant strings that must be defined as const char*
40 *
41 * Revision 1.3 2004/03/25 10:29:25 j_novak
42 * All LORENE's units are now defined in the namespace Unites (in file unites.h).
43 *
44 * Revision 1.2 2002/09/06 15:18:52 e_gourgoulhon
45 * Changement du nom de la variable "hz" en "hza"
46 * pour assurer la compatibilite avec le compilateur xlC_r
47 * sur IBM Regatta (le preprocesseur de ce compilateur remplace
48 * "hz" par "100").
49 *
50 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
51 * LORENE
52 *
53 * Revision 2.1 2000/10/09 12:27:20 eric
54 * Ajout du test sur l'identite des triades de vv1 et vv2.
55 *
56 * Revision 2.0 2000/03/02 10:34:24 eric
57 * *** empty log message ***
58 *
59 *
60 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect_bin.C,v 1.7 2016/12/05 16:18:07 j_novak Exp $
61 *
62 */
63
64
65// Header C
66#include <cmath>
67
68// Header Lorene
69#include "tenseur.h"
70#include "graphique.h"
71#include "param.h"
72#include "utilitaires.h"
73#include "unites.h"
74
75namespace Lorene {
76//******************************************************************************
77
78void des_vect_bin_x(const Tenseur& vv1, const Tenseur& vv2, double x0,
79 double scale, double sizefl, double y_min, double y_max,
80 double z_min, double z_max, const char* title,
81 const Cmp* defsurf1, const Cmp* defsurf2,
82 bool draw_bound, int ny, int nz) {
83
84 using namespace Unites ;
85
86 const Map& mp1 = *(vv1.get_mp()) ;
87 const Map& mp2 = *(vv2.get_mp()) ;
88
89 // Protections
90 // -----------
91
92 if (vv1.get_valence() != 1) {
93 cout <<
94 "des_vect_bin_x: the Tenseur vv1 must be of valence 1 (vector) !" << endl ;
95 abort() ;
96 }
97
98 if ( vv1.get_triad()->identify() != mp1.get_bvect_cart().identify() ) {
99 cout <<
100 "des_vect_bin_x: the vector vv1 must be given in Cartesian components !"
101 << endl ;
102 abort() ;
103 }
104
105 if (vv2.get_valence() != 1) {
106 cout <<
107 "des_vect_bin_x: the Tenseur vv2 must be of valence 1 (vector) !" << endl ;
108 abort() ;
109 }
110
111 if ( vv2.get_triad()->identify() != mp2.get_bvect_cart().identify() ) {
112 cout <<
113 "des_vect_bin_x: the vector vv2 must be given in Cartesian components !"
114 << endl ;
115 abort() ;
116 }
117
118 if ( *(vv1.get_triad()) != *(vv2.get_triad()) ) {
119 cout <<
120 "des_vect_bin_x: the components of the two vectors are not defined"
121 << endl << "on the same triad !" << endl ;
122 abort() ;
123 }
124
125
126 // Plot of the vector field
127 // ------------------------
128
129 float* vvy = new float[ny*nz] ;
130 float* vvz = new float[ny*nz] ;
131
132 double hy = (y_max - y_min) / double(ny-1) ;
133 double hza = (z_max - z_min) / double(nz-1) ;
134
135 for (int j=0; j<nz; j++) {
136
137 double z = z_min + hza * j ;
138
139 for (int i=0; i<ny; i++) {
140
141 double y = y_min + hy * i ;
142
143 double r, theta, phi ;
144
145 mp1.convert_absolute(x0, y, z, r, theta, phi) ;
146 double vv1y = vv1(1).val_point(r, theta, phi) ;
147 double vv1z = vv1(2).val_point(r, theta, phi) ;
148
149 mp2.convert_absolute(x0, y, z, r, theta, phi) ;
150 double vv2y = vv2(1).val_point(r, theta, phi) ;
151 double vv2z = vv2(2).val_point(r, theta, phi) ;
152
153 vvy[ny*j+i] = float(vv1y + vv2y) ;
154 vvz[ny*j+i] = float(vv1z + vv2z) ;
155
156 }
157 }
158
159 float ymin1 = float(y_min / km) ;
160 float ymax1 = float(y_max / km) ;
161 float zmin1 = float(z_min / km) ;
162 float zmax1 = float(z_max / km) ;
163
164 const char* nomy = "y [km]" ;
165 const char* nomz = "z [km]" ;
166
167 if (title == 0x0) {
168 title = "" ;
169 }
170
171 const char* device = 0x0 ;
172 int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
173 1 : 3 ;
174
175 des_vect(vvy, vvz, ny, nz, ymin1, ymax1, zmin1, zmax1,
176 scale, sizefl, nomy, nomz, title, device, newgraph) ;
177
178 delete [] vvy ;
179 delete [] vvz ;
180
181 // Plot of the surfaces
182 // --------------------
183
184 if (defsurf1 != 0x0) {
185
186 assert(defsurf1->get_mp() == vv1.get_mp()) ;
187 newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
188 des_surface_x(*defsurf1, x0, device, newgraph) ;
189 }
190
191 if (defsurf2 != 0x0) {
192
193 assert(defsurf2->get_mp() == vv2.get_mp()) ;
194 newgraph = draw_bound ? 0 : 2 ;
195 des_surface_x(*defsurf2, x0, device, newgraph) ;
196 }
197
198
199 // Plot of the domains outer boundaries
200 // ------------------------------------
201
202 if (draw_bound) {
203
204 int ndom1 = mp1.get_mg()->get_nzone() ;
205 int ndom2 = mp2.get_mg()->get_nzone() ;
206
207 for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
208 // last one)
209 newgraph = 0 ;
210 des_domaine_x(mp1, l, x0, device, newgraph) ;
211 }
212
213 for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
214 // last one)
215
216 newgraph = (l == ndom2-2) ? 2 : 0 ;
217
218 des_domaine_x(mp2, l, x0, device, newgraph) ;
219 }
220
221 }
222}
223
224
225//******************************************************************************
226
227void des_vect_bin_y(const Tenseur& vv1, const Tenseur& vv2, double y0,
228 double scale, double sizefl, double x_min, double x_max,
229 double z_min, double z_max, const char* title,
230 const Cmp* defsurf1, const Cmp* defsurf2,
231 bool draw_bound, int nx, int nz) {
232
233 using namespace Unites ;
234
235 const Map& mp1 = *(vv1.get_mp()) ;
236 const Map& mp2 = *(vv2.get_mp()) ;
237
238 // Protections
239 // -----------
240
241 if (vv1.get_valence() != 1) {
242 cout <<
243 "des_vect_bin_y: the Tenseur vv1 must be of valence 1 (vector) !" << endl ;
244 abort() ;
245 }
246
247 if ( vv1.get_triad()->identify() != mp1.get_bvect_cart().identify() ) {
248 cout <<
249 "des_vect_bin_y: the vector vv1 must be given in Cartesian components !"
250 << endl ;
251 abort() ;
252 }
253
254 if (vv2.get_valence() != 1) {
255 cout <<
256 "des_vect_bin_y: the Tenseur vv2 must be of valence 1 (vector) !" << endl ;
257 abort() ;
258 }
259
260 if ( vv2.get_triad()->identify() != mp2.get_bvect_cart().identify() ) {
261 cout <<
262 "des_vect_bin_y: the vector vv2 must be given in Cartesian components !"
263 << endl ;
264 abort() ;
265 }
266
267 if ( *(vv1.get_triad()) != *(vv2.get_triad()) ) {
268 cout <<
269 "des_vect_bin_y: the components of the two vectors are not defined"
270 << endl << "on the same triad !" << endl ;
271 abort() ;
272 }
273
274 // Plot of the vector field
275 // ------------------------
276
277 float* vvx = new float[nx*nz] ;
278 float* vvz = new float[nx*nz] ;
279
280 double hx = (x_max - x_min) / double(nx-1) ;
281 double hza = (z_max - z_min) / double(nz-1) ;
282
283 for (int j=0; j<nz; j++) {
284
285 double z = z_min + hza * j ;
286
287 for (int i=0; i<nx; i++) {
288
289 double x = x_min + hx * i ;
290
291 double r, theta, phi ;
292
293 mp1.convert_absolute(x, y0, z, r, theta, phi) ;
294 double vv1x = vv1(0).val_point(r, theta, phi) ;
295 double vv1z = vv1(2).val_point(r, theta, phi) ;
296
297 mp2.convert_absolute(x, y0, z, r, theta, phi) ;
298 double vv2x = vv2(0).val_point(r, theta, phi) ;
299 double vv2z = vv2(2).val_point(r, theta, phi) ;
300
301 vvx[nx*j+i] = float(vv1x + vv2x) ;
302 vvz[nx*j+i] = float(vv1z + vv2z) ;
303 }
304 }
305
306 float xmin1 = float(x_min / km) ;
307 float xmax1 = float(x_max / km) ;
308 float zmin1 = float(z_min / km) ;
309 float zmax1 = float(z_max / km) ;
310
311 const char* nomx = "x [km]" ;
312 const char* nomz = "z [km]" ;
313
314 if (title == 0x0) {
315 title = "" ;
316 }
317
318 const char* device = 0x0 ;
319 int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
320 1 : 3 ;
321
322 des_vect(vvx, vvz, nx, nz, xmin1, xmax1, zmin1, zmax1,
323 scale, sizefl, nomx, nomz, title, device, newgraph) ;
324
325 delete [] vvx ;
326 delete [] vvz ;
327
328 // Plot of the surfaces
329 // --------------------
330
331 if (defsurf1 != 0x0) {
332
333 assert(defsurf1->get_mp() == vv1.get_mp()) ;
334 newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
335 des_surface_y(*defsurf1, y0, device, newgraph) ;
336 }
337
338 if (defsurf2 != 0x0) {
339
340 assert(defsurf2->get_mp() == vv2.get_mp()) ;
341 newgraph = draw_bound ? 0 : 2 ;
342 des_surface_y(*defsurf2, y0, device, newgraph) ;
343 }
344
345
346 // Plot of the domains outer boundaries
347 // ------------------------------------
348
349 if (draw_bound) {
350
351 int ndom1 = mp1.get_mg()->get_nzone() ;
352 int ndom2 = mp2.get_mg()->get_nzone() ;
353
354 for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
355 // last one)
356 newgraph = 0 ;
357 des_domaine_y(mp1, l, y0, device, newgraph) ;
358 }
359
360 for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
361 // last one)
362
363 newgraph = (l == ndom2-2) ? 2 : 0 ;
364
365 des_domaine_y(mp2, l, y0, device, newgraph) ;
366 }
367
368 }
369}
370
371
372//******************************************************************************
373
374void des_vect_bin_z(const Tenseur& vv1, const Tenseur& vv2, double z0,
375 double scale, double sizefl, double x_min, double x_max,
376 double y_min, double y_max, const char* title,
377 const Cmp* defsurf1, const Cmp* defsurf2,
378 bool draw_bound, int nx, int ny) {
379
380 using namespace Unites ;
381
382 const Map& mp1 = *(vv1.get_mp()) ;
383 const Map& mp2 = *(vv2.get_mp()) ;
384
385 // Protections
386 // -----------
387
388 if (vv1.get_valence() != 1) {
389 cout <<
390 "des_vect_bin_z: the Tenseur vv1 must be of valence 1 (vector) !" << endl ;
391 abort() ;
392 }
393
394 if ( vv1.get_triad()->identify() != mp1.get_bvect_cart().identify() ) {
395 cout <<
396 "des_vect_bin_z: the vector vv1 must be given in Cartesian components !"
397 << endl ;
398 abort() ;
399 }
400
401 if (vv2.get_valence() != 1) {
402 cout <<
403 "des_vect_bin_z: the Tenseur vv2 must be of valence 1 (vector) !" << endl ;
404 abort() ;
405 }
406
407 if ( vv2.get_triad()->identify() != mp2.get_bvect_cart().identify() ) {
408 cout <<
409 "des_vect_bin_z: the vector vv2 must be given in Cartesian components !"
410 << endl ;
411 abort() ;
412 }
413
414 if ( *(vv1.get_triad()) != *(vv2.get_triad()) ) {
415 cout <<
416 "des_vect_bin_z: the components of the two vectors are not defined"
417 << endl << "on the same triad !" << endl ;
418 abort() ;
419 }
420
421 // Plot of the vector field
422 // ------------------------
423
424 float* vvx = new float[nx*ny] ;
425 float* vvy = new float[nx*ny] ;
426
427 double hx = (x_max - x_min) / double(nx-1) ;
428 double hy = (y_max - y_min) / double(ny-1) ;
429
430 for (int j=0; j<ny; j++) {
431
432 double y = y_min + hy * j ;
433
434 for (int i=0; i<nx; i++) {
435
436 double x = x_min + hx * i ;
437
438 double r, theta, phi ;
439
440 mp1.convert_absolute(x, y, z0, r, theta, phi) ;
441 double vv1x = vv1(0).val_point(r, theta, phi) ;
442 double vv1y = vv1(1).val_point(r, theta, phi) ;
443
444 mp2.convert_absolute(x, y, z0, r, theta, phi) ;
445 double vv2x = vv2(0).val_point(r, theta, phi) ;
446 double vv2y = vv2(1).val_point(r, theta, phi) ;
447
448 vvx[nx*j+i] = float(vv1x + vv2x) ;
449 vvy[nx*j+i] = float(vv1y + vv2y) ;
450 }
451 }
452
453 float xmin1 = float(x_min / km) ;
454 float xmax1 = float(x_max / km) ;
455 float ymin1 = float(y_min / km) ;
456 float ymax1 = float(y_max / km) ;
457
458 const char* nomx = "x [km]" ;
459 const char* nomy = "y [km]" ;
460
461 if (title == 0x0) {
462 title = "" ;
463 }
464
465 const char* device = 0x0 ;
466 int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
467 1 : 3 ;
468
469 des_vect(vvx, vvy, nx, ny, xmin1, xmax1, ymin1, ymax1,
470 scale, sizefl, nomx, nomy, title, device, newgraph) ;
471
472 delete [] vvx ;
473 delete [] vvy ;
474
475 // Plot of the surfaces
476 // --------------------
477
478 if (defsurf1 != 0x0) {
479
480 assert(defsurf1->get_mp() == vv1.get_mp()) ;
481 newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
482 des_surface_z(*defsurf1, z0, device, newgraph) ;
483 }
484
485 if (defsurf2 != 0x0) {
486
487 assert(defsurf2->get_mp() == vv2.get_mp()) ;
488 newgraph = draw_bound ? 0 : 2 ;
489 des_surface_z(*defsurf2, z0, device, newgraph) ;
490 }
491
492
493 // Plot of the domains outer boundaries
494 // ------------------------------------
495
496 if (draw_bound) {
497
498 int ndom1 = mp1.get_mg()->get_nzone() ;
499 int ndom2 = mp2.get_mg()->get_nzone() ;
500
501 for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
502 // last one)
503 newgraph = 0 ;
504 des_domaine_z(mp1, l, z0, device, newgraph) ;
505 }
506
507 for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
508 // last one)
509
510 newgraph = (l == ndom2-2) ? 2 : 0 ;
511
512 des_domaine_z(mp2, l, z0, device, newgraph) ;
513 }
514
515 }
516}
517}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition tenseur.h:304
Lorene prototypes.
Definition app_hor.h:67
Coord z
z coordinate centered on the grid
Definition map.h:740
Coord y
y coordinate centered on the grid
Definition map.h:739
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:142
Coord phi
coordinate centered on the grid
Definition map.h:732
Coord x
x coordinate centered on the grid
Definition map.h:738
Coord r
r coordinate centered on the grid
Definition map.h:730