LORENE
des_coupe_z.C
1 /*
2  * Copyright (c) 1999-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_z.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
27  * $Log: des_coupe_z.C,v $
28  * Revision 1.6 2016/12/05 16:18:06 j_novak
29  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30  *
31  * Revision 1.5 2014/10/13 08:53:22 j_novak
32  * Lorene classes and functions now belong to the namespace Lorene.
33  *
34  * Revision 1.4 2014/10/06 15:16:04 j_novak
35  * Modified #include directives to use c++ syntax.
36  *
37  * Revision 1.3 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.2 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.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
45  * LORENE
46  *
47  * Revision 1.8 2000/02/12 11:19:20 eric
48  * Ajout de la version avec determination automatique des bornes de la fenetre
49  * graphique.
50  *
51  * Revision 1.7 2000/02/11 18:44:13 eric
52  * Ajout de l'argument draw_bound.
53  *
54  * Revision 1.6 2000/02/11 16:53:36 eric
55  * Utilisation des coordonnees cartesiennes abolues (X,Y,Z) et non plus
56  * des coordonnees relatives (x,y,z).
57  *
58  * Revision 1.5 1999/12/28 09:02:38 eric
59  * *** empty log message ***
60  *
61  * Revision 1.4 1999/12/27 12:18:51 eric
62  * Ajout du dessin des frontieres de domains.
63  *
64  * Revision 1.3 1999/12/24 13:01:02 eric
65  * On appelle desormais la routine des_surface_y pour le dessin de la
66  * surface.
67  *
68  * Revision 1.2 1999/12/23 16:16:16 eric
69  * Ajout du dessin de la surface (argument defsurf).
70  *
71  * Revision 1.1 1999/12/09 16:38:18 eric
72  * Initial revision
73  *
74  *
75  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_z.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
76  *
77  */
78 
79 // Header C
80 #include <cmath>
81 
82 // Header Lorene
83 #include "cmp.h"
84 #include "graphique.h"
85 #include "param.h"
86 #include "utilitaires.h"
87 #include "unites.h"
88 
89 namespace Lorene {
90 //******************************************************************************
91 
92 void des_coupe_z(const Cmp& uu, double z0, int nzdes, const char* title,
93  const Cmp* defsurf, double zoom, bool draw_bound,
94  int ncour, int nx, int ny) {
95 
96  const Map& mp = *(uu.get_mp()) ;
97 
98  double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
99  double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
100  double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
101  double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
102 
103  ray = ( a1 > ray ) ? a1 : ray ;
104  ray = ( a2 > ray ) ? a2 : ray ;
105  ray = ( a3 > ray ) ? a3 : ray ;
106 
107  ray *= zoom ;
108 
109  double x_min = mp.get_ori_x() - ray ;
110  double x_max = mp.get_ori_x() + ray ;
111  double y_min = mp.get_ori_y() - ray ;
112  double y_max = mp.get_ori_y() + ray ;
113 
114  des_coupe_z(uu, z0, x_min, x_max, y_min, y_max, title, defsurf, draw_bound,
115  ncour, nx, ny) ;
116 
117 }
118 //******************************************************************************
119 
120 
121 void des_coupe_z(const Cmp& uu, double z0, double x_min, double x_max,
122  double y_min, double y_max, const char* title, const Cmp* defsurf,
123  bool draw_bound, int ncour, int nx, int ny) {
124 
125  using namespace Unites ;
126 
127  const Map& mp = *(uu.get_mp()) ;
128 
129  // Plot of isocontours
130  // -------------------
131 
132  float* uutab = new float[ny*nx] ;
133 
134  double hy = (y_max - y_min) / double(ny-1) ;
135  double hx = (x_max - x_min) / double(nx-1) ;
136 
137  for (int j=0; j<ny; j++) {
138 
139  double y = y_min + hy * j ;
140 
141  for (int i=0; i<nx; i++) {
142 
143  double x = x_min + hx * i ;
144 
145  // Computation of (r,theta,phi) :
146  double r, theta, phi ;
147  mp.convert_absolute(x, y, z0, r, theta, phi) ;
148 
149  uutab[nx*j+i] = float(uu.val_point(r, theta, phi)) ;
150  }
151  }
152 
153  float ymin1 = float(y_min / km) ;
154  float ymax1 = float(y_max / km) ;
155  float xmin1 = float(x_min / km) ;
156  float xmax1 = float(x_max / km) ;
157 
158  const char* nomy = "y [km]" ;
159  const char* nomx = "x [km]" ;
160 
161  if (title == 0x0) {
162  title = "" ;
163  }
164 
165  const char* device = 0x0 ;
166  int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
167 
168  des_equipot(uutab, nx, ny, xmin1, xmax1, ymin1, ymax1, ncour, nomx, nomy,
169  title, device, newgraph) ;
170 
171  delete [] uutab ;
172 
173 
174  // Plot of the surface
175  // -------------------
176 
177  if (defsurf != 0x0) {
178 
179  assert(defsurf->get_mp() == uu.get_mp()) ;
180 
181  newgraph = draw_bound ? 0 : 2 ;
182 
183  des_surface_z(*defsurf, z0, device, newgraph) ;
184 
185  } // End of the surface drawing
186 
187  // Plot of the domains outer boundaries
188  // ------------------------------------
189 
190  if (draw_bound) {
191 
192  int ndom = mp.get_mg()->get_nzone() ; // total number of domains
193 
194  for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
195  // last one)
196 
197  newgraph = (l == ndom-2) ? 2 : 0 ;
198 
199  des_domaine_z(mp, l, z0, device, newgraph) ;
200  }
201  }
202 
203 
204 }
205 }
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.
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
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