LORENE
des_coupe_y.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_y.C,v 1.7 2016/12/05 16:18:06 j_novak Exp $
27  * $Log: des_coupe_y.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:22 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 1.8 2000/02/12 11:18:59 eric
54  * Ajout de la version avec determination automatique des bornes de la fenetre
55  * graphique.
56  *
57  * Revision 1.7 2000/02/11 18:44:06 eric
58  * Ajout de l'argument draw_bound.
59  *
60  * Revision 1.6 2000/02/11 16:53:25 eric
61  * Utilisation des coordonnees cartesiennes abolues (X,Y,Z) et non plus
62  * des coordonnees relatives (x,y,z).
63  *
64  * Revision 1.5 1999/12/28 09:02:30 eric
65  * *** empty log message ***
66  *
67  * Revision 1.4 1999/12/27 12:18:43 eric
68  * Ajout du dessin des frontieres de domains.
69  *
70  * Revision 1.3 1999/12/24 13:00:46 eric
71  * On appelle desormais la routine des_surface_y pour le dessin de la
72  * surface.
73  *
74  * Revision 1.2 1999/12/23 16:16:26 eric
75  * Ajout du dessin de la surface (argument defsurf).
76  *
77  * Revision 1.1 1999/12/09 16:38:10 eric
78  * Initial revision
79  *
80  *
81  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_y.C,v 1.7 2016/12/05 16:18:06 j_novak Exp $
82  *
83  */
84 
85 // Header C
86 #include <cmath>
87 
88 // Header Lorene
89 #include "cmp.h"
90 #include "graphique.h"
91 #include "param.h"
92 #include "utilitaires.h"
93 #include "unites.h"
94 
95 namespace Lorene {
96 //******************************************************************************
97 
98 void des_coupe_y(const Cmp& uu, double y0, int nzdes, const char* title,
99  const Cmp* defsurf, double zoom, bool draw_bound,
100  int ncour, int nx, int nz) {
101 
102  const Map& mp = *(uu.get_mp()) ;
103 
104  double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
105  double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
106  double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
107  double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
108 
109  ray = ( a1 > ray ) ? a1 : ray ;
110  ray = ( a2 > ray ) ? a2 : ray ;
111  ray = ( a3 > ray ) ? a3 : ray ;
112 
113  ray *= zoom ;
114 
115  double x_min = mp.get_ori_x() - ray ;
116  double x_max = mp.get_ori_x() + ray ;
117  double z_min = mp.get_ori_z() - ray ;
118  double z_max = mp.get_ori_z() + ray ;
119 
120  des_coupe_y(uu, y0, x_min, x_max, z_min, z_max, title, defsurf, draw_bound,
121  ncour, nx, nz) ;
122 
123 }
124 
125 //******************************************************************************
126 
127 void des_coupe_y(const Cmp& uu, double y0, double x_min, double x_max,
128  double z_min, double z_max, const char* title, const Cmp* defsurf,
129  bool draw_bound, int ncour, int nx, int nz) {
130 
131  using namespace Unites ;
132 
133  const Map& mp = *(uu.get_mp()) ;
134 
135  // Plot of isocontours
136  // -------------------
137 
138  float* uutab = new float[nx*nz] ;
139 
140  double hx = (x_max - x_min) / double(nx-1) ;
141  double hza = (z_max - z_min) / double(nz-1) ;
142 
143 
144 
145  for (int j=0; j<nz; j++) {
146 
147  double z = z_min + hza * j ;
148 
149  for (int i=0; i<nx; i++) {
150 
151  double x = x_min + hx * i ;
152 
153  // Computation of (r,theta,phi) :
154  double r, theta, phi ;
155  mp.convert_absolute(x, y0, z, r, theta, phi) ;
156 
157  uutab[nx*j+i] = float(uu.val_point(r, theta, phi)) ;
158  }
159  }
160 
161  float xmin1 = float(x_min / km) ;
162  float xmax1 = float(x_max / km) ;
163  float zmin1 = float(z_min / km) ;
164  float zmax1 = float(z_max / km) ;
165 
166  const char* nomx = "x [km]" ;
167  const char* nomz = "z [km]" ;
168 
169  if (title == 0x0) {
170  title = "" ;
171  }
172 
173 
174  const char* device = 0x0 ;
175  int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
176 
177  des_equipot(uutab, nx, nz, xmin1, xmax1, zmin1, zmax1, ncour, nomx, nomz,
178  title, device, newgraph) ;
179 
180  // Plot of the surface
181  // -------------------
182 
183  if (defsurf != 0x0) {
184 
185  assert(defsurf->get_mp() == uu.get_mp()) ;
186 
187  newgraph = draw_bound ? 0 : 2 ;
188 
189  des_surface_y(*defsurf, y0, device, newgraph) ;
190 
191  } // End of the surface drawing
192 
193  delete [] uutab ;
194 
195  // Plot of the domains outer boundaries
196  // ------------------------------------
197 
198  if (draw_bound) {
199 
200  int ndom = mp.get_mg()->get_nzone() ; // total number of domains
201 
202  for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
203  // last one)
204 
205  newgraph = (l == ndom-2) ? 2 : 0 ;
206 
207  des_domaine_y(mp, l, y0, device, newgraph) ;
208  }
209  }
210 
211 
212 }
213 }
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_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.
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
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_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.