LORENE
des_coupe_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_coupe_bin.C,v 1.7 2016/12/05 16:18:06 j_novak Exp $
27  * $Log: des_coupe_bin.C,v $
28  * Revision 1.7 2016/12/05 16:18:06 j_novak
29  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30  *
31  * Revision 1.6 2014/10/13 08:53:21 j_novak
32  * Lorene classes and functions now belong to the namespace Lorene.
33  *
34  * Revision 1.5 2014/10/06 15:16:04 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:24 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/02/11 18:44:28 eric
54  * Ajout de l'argument draw_bound.
55  *
56  * Revision 2.0 2000/02/11 17:47:26 eric
57  * *** empty log message ***
58  *
59  *
60  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_bin.C,v 1.7 2016/12/05 16:18:06 j_novak Exp $
61  *
62  */
63 
64 // Header C
65 #include <cmath>
66 
67 // Header Lorene
68 #include "cmp.h"
69 #include "graphique.h"
70 #include "param.h"
71 #include "utilitaires.h"
72 #include "unites.h"
73 
74 namespace Lorene {
75 //******************************************************************************
76 
77 void des_coupe_bin_x(const Cmp& uu1, const Cmp& uu2, double x0, double y_min,
78  double y_max, double z_min, double z_max, const char* title,
79  const Cmp* defsurf1, const Cmp* defsurf2,
80  bool draw_bound, int ncour, int ny, int nz) {
81 
82  using namespace Unites ;
83 
84  const Map& mp1 = *(uu1.get_mp()) ;
85  const Map& mp2 = *(uu2.get_mp()) ;
86 
87  // Plot of isocontours
88  // -------------------
89 
90  float* uutab = new float[ny*nz] ;
91 
92  double hy = (y_max - y_min) / double(ny-1) ;
93  double hza = (z_max - z_min) / double(nz-1) ;
94 
95  for (int j=0; j<nz; j++) {
96 
97  double z = z_min + hza * j ;
98 
99  for (int i=0; i<ny; i++) {
100 
101  double y = y_min + hy * i ;
102 
103  double r, theta, phi ;
104 
105  mp1.convert_absolute(x0, y, z, r, theta, phi) ;
106  double uu_1 = uu1.val_point(r, theta, phi) ;
107 
108  mp2.convert_absolute(x0, y, z, r, theta, phi) ;
109  double uu_2 = uu2.val_point(r, theta, phi) ;
110 
111  uutab[ny*j+i] = float(uu_1 + uu_2) ;
112 
113  }
114  }
115 
116  float ymin1 = float(y_min / km) ;
117  float ymax1 = float(y_max / km) ;
118  float zmin1 = float(z_min / km) ;
119  float zmax1 = float(z_max / km) ;
120 
121  const char* nomy = "y [km]" ;
122  const char* nomz = "z [km]" ;
123 
124  if (title == 0x0) {
125  title = "" ;
126  }
127 
128  const char* device = 0x0 ;
129  int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
130  1 : 3 ;
131 
132  des_equipot(uutab, ny, nz, ymin1, ymax1, zmin1, zmax1, ncour, nomy, nomz,
133  title, device, newgraph) ;
134 
135  delete [] uutab ;
136 
137  // Plot of the surfaces
138  // --------------------
139 
140  if (defsurf1 != 0x0) {
141 
142  assert(defsurf1->get_mp() == uu1.get_mp()) ;
143  newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
144  des_surface_x(*defsurf1, x0, device, newgraph) ;
145  }
146 
147  if (defsurf2 != 0x0) {
148 
149  assert(defsurf2->get_mp() == uu2.get_mp()) ;
150  newgraph = draw_bound ? 0 : 2 ;
151  des_surface_x(*defsurf2, x0, device, newgraph) ;
152  }
153 
154 
155  // Plot of the domains outer boundaries
156  // ------------------------------------
157 
158  if (draw_bound) {
159 
160  int ndom1 = mp1.get_mg()->get_nzone() ;
161  int ndom2 = mp2.get_mg()->get_nzone() ;
162 
163  for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
164  // last one)
165  newgraph = 0 ;
166  des_domaine_x(mp1, l, x0, device, newgraph) ;
167  }
168 
169  for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
170  // last one)
171 
172  newgraph = (l == ndom2-2) ? 2 : 0 ;
173 
174  des_domaine_x(mp2, l, x0, device, newgraph) ;
175  }
176 
177  }
178 }
179 
180 
181 //******************************************************************************
182 
183 void des_coupe_bin_y(const Cmp& uu1, const Cmp& uu2, double y0, double x_min,
184  double x_max, double z_min, double z_max, const char* title,
185  const Cmp* defsurf1, const Cmp* defsurf2,
186  bool draw_bound, int ncour, int nx, int nz) {
187 
188  using namespace Unites ;
189 
190  const Map& mp1 = *(uu1.get_mp()) ;
191  const Map& mp2 = *(uu2.get_mp()) ;
192 
193  // Plot of isocontours
194  // -------------------
195 
196  float* uutab = new float[nx*nz] ;
197 
198  double hx = (x_max - x_min) / double(nx-1) ;
199  double hza = (z_max - z_min) / double(nz-1) ;
200 
201 
202 
203  for (int j=0; j<nz; j++) {
204 
205  double z = z_min + hza * j ;
206 
207  for (int i=0; i<nx; i++) {
208 
209  double x = x_min + hx * i ;
210 
211  double r, theta, phi ;
212 
213  mp1.convert_absolute(x, y0, z, r, theta, phi) ;
214  double uu_1 = uu1.val_point(r, theta, phi) ;
215 
216  mp2.convert_absolute(x, y0, z, r, theta, phi) ;
217  double uu_2 = uu2.val_point(r, theta, phi) ;
218 
219  uutab[nx*j+i] = float(uu_1 + uu_2) ;
220  }
221  }
222 
223  float xmin1 = float(x_min / km) ;
224  float xmax1 = float(x_max / km) ;
225  float zmin1 = float(z_min / km) ;
226  float zmax1 = float(z_max / km) ;
227 
228  const char* nomx = "x [km]" ;
229  const char* nomz = "z [km]" ;
230 
231  if (title == 0x0) {
232  title = "" ;
233  }
234 
235 
236  const char* device = 0x0 ;
237  int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
238  1 : 3 ;
239 
240  des_equipot(uutab, nx, nz, xmin1, xmax1, zmin1, zmax1, ncour, nomx, nomz,
241  title, device, newgraph) ;
242 
243  delete [] uutab ;
244 
245  // Plot of the surfaces
246  // --------------------
247 
248  if (defsurf1 != 0x0) {
249 
250  assert(defsurf1->get_mp() == uu1.get_mp()) ;
251  newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
252  des_surface_y(*defsurf1, y0, device, newgraph) ;
253  }
254 
255  if (defsurf2 != 0x0) {
256 
257  assert(defsurf2->get_mp() == uu2.get_mp()) ;
258  newgraph = draw_bound ? 0 : 2 ;
259  des_surface_y(*defsurf2, y0, device, newgraph) ;
260  }
261 
262 
263  // Plot of the domains outer boundaries
264  // ------------------------------------
265 
266  if (draw_bound) {
267 
268  int ndom1 = mp1.get_mg()->get_nzone() ;
269  int ndom2 = mp2.get_mg()->get_nzone() ;
270 
271  for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
272  // last one)
273  newgraph = 0 ;
274  des_domaine_y(mp1, l, y0, device, newgraph) ;
275  }
276 
277  for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
278  // last one)
279 
280  newgraph = (l == ndom2-2) ? 2 : 0 ;
281 
282  des_domaine_y(mp2, l, y0, device, newgraph) ;
283  }
284 
285  }
286 }
287 
288 
289 //******************************************************************************
290 
291 void des_coupe_bin_z(const Cmp& uu1, const Cmp& uu2, double z0, double x_min,
292  double x_max, double y_min, double y_max, const char* title,
293  const Cmp* defsurf1, const Cmp* defsurf2,
294  bool draw_bound, int ncour, int nx, int ny) {
295 
296  using namespace Unites ;
297 
298  const Map& mp1 = *(uu1.get_mp()) ;
299  const Map& mp2 = *(uu2.get_mp()) ;
300 
301  // Plot of isocontours
302  // -------------------
303 
304  float* uutab = new float[ny*nx] ;
305 
306  double hy = (y_max - y_min) / double(ny-1) ;
307  double hx = (x_max - x_min) / double(nx-1) ;
308 
309  for (int j=0; j<ny; j++) {
310 
311  double y = y_min + hy * j ;
312 
313  for (int i=0; i<nx; i++) {
314 
315  double x = x_min + hx * i ;
316 
317  double r, theta, phi ;
318 
319  mp1.convert_absolute(x, y, z0, r, theta, phi) ;
320  double uu_1 = uu1.val_point(r, theta, phi) ;
321 
322  mp2.convert_absolute(x, y, z0, r, theta, phi) ;
323  double uu_2 = uu2.val_point(r, theta, phi) ;
324 
325  uutab[nx*j+i] = float(uu_1 + uu_2) ;
326  }
327  }
328 
329  float ymin1 = float(y_min / km) ;
330  float ymax1 = float(y_max / km) ;
331  float xmin1 = float(x_min / km) ;
332  float xmax1 = float(x_max / km) ;
333 
334  const char* nomy = "y [km]" ;
335  const char* nomx = "x [km]" ;
336 
337  if (title == 0x0) {
338  title = "" ;
339  }
340 
341  const char* device = 0x0 ;
342  int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
343  1 : 3 ;
344 
345  des_equipot(uutab, nx, ny, xmin1, xmax1, ymin1, ymax1, ncour, nomx, nomy,
346  title, device, newgraph) ;
347 
348  delete [] uutab ;
349 
350 
351  // Plot of the surfaces
352  // --------------------
353 
354  if (defsurf1 != 0x0) {
355 
356  assert(defsurf1->get_mp() == uu1.get_mp()) ;
357  newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
358  des_surface_z(*defsurf1, z0, device, newgraph) ;
359  }
360 
361  if (defsurf2 != 0x0) {
362 
363  assert(defsurf2->get_mp() == uu2.get_mp()) ;
364  newgraph = draw_bound ? 0 : 2 ;
365  des_surface_z(*defsurf2, z0, device, newgraph) ;
366  }
367 
368 
369  // Plot of the domains outer boundaries
370  // ------------------------------------
371 
372  if (draw_bound) {
373 
374  int ndom1 = mp1.get_mg()->get_nzone() ;
375  int ndom2 = mp2.get_mg()->get_nzone() ;
376 
377  for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
378  // last one)
379  newgraph = 0 ;
380  des_domaine_z(mp1, l, z0, device, newgraph) ;
381  }
382 
383  for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
384  // last one)
385 
386  newgraph = (l == ndom2-2) ? 2 : 0 ;
387 
388  des_domaine_z(mp2, l, z0, device, newgraph) ;
389  }
390 
391  }
392 }
393 }
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_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.
Lorene prototypes.
Definition: app_hor.h:67
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.
Standard units of space, time and mass.
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_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, int newgraph, int nxpage, int nypage)
Basic routine for drawing isocontours.
Definition: des_equipot.C:77
void des_coupe_bin_y(const Cmp &uu1, const Cmp &uu2, double y0, double x_min, double x_max, double z_min, double z_max, const char *title, const Cmp *defsurf1=0x0, const Cmp *defsurf2=0x0, bool draw_bound=true, int ncour=15, int nx=100, int nz=100)
Draws isocontour lines of a the sum of two Cmp &#39;s in a plane Y=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_coupe_bin_z(const Cmp &uu1, const Cmp &uu2, double z0, double x_min, double x_max, double y_min, double y_max, const char *title, const Cmp *defsurf1=0x0, const Cmp *defsurf2=0x0, bool draw_bound=true, int ncour=15, int nx=100, int ny=100)
Draws isocontour lines of a the sum of two Cmp &#39;s in a plane Z=constant.
void des_coupe_bin_x(const Cmp &uu1, const Cmp &uu2, double x0, double y_min, double y_max, double z_min, double z_max, const char *title, const Cmp *defsurf1=0x0, const Cmp *defsurf2=0x0, bool draw_bound=true, int ncour=15, int ny=100, int nz=100)
Draws isocontour lines of a the sum of two Cmp &#39;s 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.