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