LORENE
des_coupe_scalar.C
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
24
25/*
26 * $Id: des_coupe_scalar.C,v 1.5 2016/12/05 16:18:06 j_novak Exp $
27 * $Log: des_coupe_scalar.C,v $
28 * Revision 1.5 2016/12/05 16:18:06 j_novak
29 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30 *
31 * Revision 1.4 2014/10/13 08:53:21 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.3 2014/10/06 15:16:04 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.2 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.1 2005/03/24 22:00:34 e_gourgoulhon
42 * Isocontour plot of a Scalar.
43 *
44 *
45 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_scalar.C,v 1.5 2016/12/05 16:18:06 j_novak Exp $
46 *
47 */
48
49// Header C
50#include <cmath>
51
52// Header Lorene
53#include "scalar.h"
54#include "graphique.h"
55#include "param.h"
56#include "utilitaires.h"
57#include "unites.h"
58
59
60namespace Lorene {
61void des_coupe_x(const Scalar& uu, double x0, int nzdes, const char* title,
62 const Scalar* defsurf, double zoom, bool draw_bound,
63 int ncour, int ny, int nz) {
64
65 const Map& mp = uu.get_mp() ;
66
67 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
68 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
69 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
70 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
71
72 ray = ( a1 > ray ) ? a1 : ray ;
73 ray = ( a2 > ray ) ? a2 : ray ;
74 ray = ( a3 > ray ) ? a3 : ray ;
75
76 ray *= zoom ;
77
78 double y_min = mp.get_ori_y() - ray ;
79 double y_max = mp.get_ori_y() + ray ;
80 double z_min = mp.get_ori_z() - ray ;
81 double z_max = mp.get_ori_z() + ray ;
82
83 des_coupe_x(uu, x0, y_min, y_max, z_min, z_max, title, defsurf, draw_bound,
84 ncour, ny, nz) ;
85
86}
87
88//******************************************************************************
89
90void des_coupe_x(const Scalar& uu, double x0, double y_min, double y_max,
91 double z_min, double z_max, const char* title, const Scalar* defsurf,
92 bool draw_bound, int ncour, int ny, int nz) {
93
94using namespace Unites ;
95
96 const Map& mp = uu.get_mp() ;
97
98 // Plot of isocontours
99 // -------------------
100
101 float* uutab = new float[ny*nz] ;
102
103 double hy = (y_max - y_min) / double(ny-1) ;
104 double hza = (z_max - z_min) / double(nz-1) ;
105
106 for (int j=0; j<nz; j++) {
107
108 double z = z_min + hza * j ;
109
110 for (int i=0; i<ny; i++) {
111
112 double y = y_min + hy * i ;
113
114 // Computation of (r,theta,phi) :
115 double r, theta, phi ;
116 mp.convert_absolute(x0, y, z, r, theta, phi) ;
117
118 uutab[ny*j+i] = float(uu.val_point(r, theta, phi)) ;
119 }
120 }
121
122 float ymin1 = float(y_min / km) ;
123 float ymax1 = float(y_max / km) ;
124 float zmin1 = float(z_min / km) ;
125 float zmax1 = float(z_max / km) ;
126
127 const char* nomy = "y [km]" ;
128 const char* nomz = "z [km]" ;
129
130 if (title == 0x0) {
131 title = "" ;
132 }
133
134 const char* device = 0x0 ;
135 int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
136
137 des_equipot(uutab, ny, nz, ymin1, ymax1, zmin1, zmax1, ncour, nomy, nomz,
138 title, device, newgraph) ;
139
140 delete [] uutab ;
141
142 // Plot of the surface
143 // -------------------
144
145 if (defsurf != 0x0) {
146
147 assert( &(defsurf->get_mp()) == &mp ) ;
148
149 newgraph = draw_bound ? 0 : 2 ;
150
151 des_surface_x(*defsurf, x0, device, newgraph) ;
152
153 } // End of the surface drawing
154
155
156 // Plot of the domains outer boundaries
157 // ------------------------------------
158
159 if (draw_bound) {
160
161 int ndom = mp.get_mg()->get_nzone() ; // total number of domains
162
163 for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
164 // last one)
165
166 newgraph = (l == ndom-2) ? 2 : 0 ;
167
168 des_domaine_x(mp, l, x0, device, newgraph) ;
169 }
170 }
171
172
173}
174
175
176//******************************************************************************
177
178void des_coupe_y(const Scalar& uu, double y0, int nzdes, const char* title,
179 const Scalar* defsurf, double zoom, bool draw_bound,
180 int ncour, int nx, int nz) {
181
182 const Map& mp = uu.get_mp() ;
183
184 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
185 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
186 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
187 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
188
189 ray = ( a1 > ray ) ? a1 : ray ;
190 ray = ( a2 > ray ) ? a2 : ray ;
191 ray = ( a3 > ray ) ? a3 : ray ;
192
193 ray *= zoom ;
194
195 double x_min = mp.get_ori_x() - ray ;
196 double x_max = mp.get_ori_x() + ray ;
197 double z_min = mp.get_ori_z() - ray ;
198 double z_max = mp.get_ori_z() + ray ;
199
200 des_coupe_y(uu, y0, x_min, x_max, z_min, z_max, title, defsurf, draw_bound,
201 ncour, nx, nz) ;
202
203}
204
205//******************************************************************************
206
207void des_coupe_y(const Scalar& uu, double y0, double x_min, double x_max,
208 double z_min, double z_max, const char* title, const Scalar* defsurf,
209 bool draw_bound, int ncour, int nx, int nz) {
210
211 using namespace Unites ;
212
213 const Map& mp = uu.get_mp() ;
214
215 // Plot of isocontours
216 // -------------------
217
218 float* uutab = new float[nx*nz] ;
219
220 double hx = (x_max - x_min) / double(nx-1) ;
221 double hza = (z_max - z_min) / double(nz-1) ;
222
223
224
225 for (int j=0; j<nz; j++) {
226
227 double z = z_min + hza * j ;
228
229 for (int i=0; i<nx; i++) {
230
231 double x = x_min + hx * i ;
232
233 // Computation of (r,theta,phi) :
234 double r, theta, phi ;
235 mp.convert_absolute(x, y0, z, r, theta, phi) ;
236
237 uutab[nx*j+i] = float(uu.val_point(r, theta, phi)) ;
238 }
239 }
240
241 float xmin1 = float(x_min / km) ;
242 float xmax1 = float(x_max / km) ;
243 float zmin1 = float(z_min / km) ;
244 float zmax1 = float(z_max / km) ;
245
246 const char* nomx = "x [km]" ;
247 const char* nomz = "z [km]" ;
248
249 if (title == 0x0) {
250 title = "" ;
251 }
252
253
254 const char* device = 0x0 ;
255 int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
256
257 des_equipot(uutab, nx, nz, xmin1, xmax1, zmin1, zmax1, ncour, nomx, nomz,
258 title, device, newgraph) ;
259
260 // Plot of the surface
261 // -------------------
262
263 if (defsurf != 0x0) {
264
265 assert( &(defsurf->get_mp()) == &mp ) ;
266
267 newgraph = draw_bound ? 0 : 2 ;
268
269 des_surface_y(*defsurf, y0, device, newgraph) ;
270
271 } // End of the surface drawing
272
273 delete [] uutab ;
274
275 // Plot of the domains outer boundaries
276 // ------------------------------------
277
278 if (draw_bound) {
279
280 int ndom = mp.get_mg()->get_nzone() ; // total number of domains
281
282 for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
283 // last one)
284
285 newgraph = (l == ndom-2) ? 2 : 0 ;
286
287 des_domaine_y(mp, l, y0, device, newgraph) ;
288 }
289 }
290
291
292}
293
294
295//******************************************************************************
296
297void des_coupe_z(const Scalar& uu, double z0, int nzdes, const char* title,
298 const Scalar* defsurf, double zoom, bool draw_bound,
299 int ncour, int nx, int ny) {
300
301 const Map& mp = uu.get_mp() ;
302
303 double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
304 double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
305 double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
306 double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
307
308 ray = ( a1 > ray ) ? a1 : ray ;
309 ray = ( a2 > ray ) ? a2 : ray ;
310 ray = ( a3 > ray ) ? a3 : ray ;
311
312 ray *= zoom ;
313
314 double x_min = mp.get_ori_x() - ray ;
315 double x_max = mp.get_ori_x() + ray ;
316 double y_min = mp.get_ori_y() - ray ;
317 double y_max = mp.get_ori_y() + ray ;
318
319 des_coupe_z(uu, z0, x_min, x_max, y_min, y_max, title, defsurf, draw_bound,
320 ncour, nx, ny) ;
321
322}
323
324//******************************************************************************
325
326
327void des_coupe_z(const Scalar& uu, double z0, double x_min, double x_max,
328 double y_min, double y_max, const char* title, const Scalar* defsurf,
329 bool draw_bound, int ncour, int nx, int ny) {
330
331 using namespace Unites ;
332
333 const Map& mp = uu.get_mp() ;
334
335 // Plot of isocontours
336 // -------------------
337
338 float* uutab = new float[ny*nx] ;
339
340 double hy = (y_max - y_min) / double(ny-1) ;
341 double hx = (x_max - x_min) / double(nx-1) ;
342
343 for (int j=0; j<ny; j++) {
344
345 double y = y_min + hy * j ;
346
347 for (int i=0; i<nx; i++) {
348
349 double x = x_min + hx * i ;
350
351 // Computation of (r,theta,phi) :
352 double r, theta, phi ;
353 mp.convert_absolute(x, y, z0, r, theta, phi) ;
354
355 uutab[nx*j+i] = float(uu.val_point(r, theta, phi)) ;
356 }
357 }
358
359 float ymin1 = float(y_min / km) ;
360 float ymax1 = float(y_max / km) ;
361 float xmin1 = float(x_min / km) ;
362 float xmax1 = float(x_max / km) ;
363
364 const char* nomy = "y [km]" ;
365 const char* nomx = "x [km]" ;
366
367 if (title == 0x0) {
368 title = "" ;
369 }
370
371 const char* device = 0x0 ;
372 int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
373
374 des_equipot(uutab, nx, ny, xmin1, xmax1, ymin1, ymax1, ncour, nomx, nomy,
375 title, device, newgraph) ;
376
377 delete [] uutab ;
378
379
380 // Plot of the surface
381 // -------------------
382
383 if (defsurf != 0x0) {
384
385 assert( &(defsurf->get_mp()) == &mp ) ;
386
387 newgraph = draw_bound ? 0 : 2 ;
388
389 des_surface_z(*defsurf, z0, device, newgraph) ;
390
391 } // End of the surface drawing
392
393 // Plot of the domains outer boundaries
394 // ------------------------------------
395
396 if (draw_bound) {
397
398 int ndom = mp.get_mg()->get_nzone() ; // total number of domains
399
400 for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
401 // last one)
402
403 newgraph = (l == ndom-2) ? 2 : 0 ;
404
405 des_domaine_z(mp, l, z0, device, newgraph) ;
406 }
407 }
408
409
410}
411
412}
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:393
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