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