LORENE
des_bi_coupe.C
1 /*
2  * Copyright (c) 2001 Jerome Novak
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_bi_coupe_c[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_bi_coupe.C,v 1.6 2014/10/13 08:53:21 j_novak Exp $" ;
24 
25 /*
26  * $Id: des_bi_coupe.C,v 1.6 2014/10/13 08:53:21 j_novak Exp $
27  * $Log: des_bi_coupe.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 1.1 2001/06/21 07:39:20 novak
51  * Initial revision
52  *
53  *
54  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_bi_coupe.C,v 1.6 2014/10/13 08:53:21 j_novak Exp $
55  *
56  */
57 
58 // Header C
59 #include <cmath>
60 
61 // Header Lorene
62 #include "cmp.h"
63 #include "graphique.h"
64 #include "param.h"
65 #include "utilitaires.h"
66 #include "unites.h"
67 
68 namespace Lorene {
69 //******************************************************************************
70 
71 void des_bi_coupe_y(const Cmp& uu, double y0, int nzdes, const char* title,
72  const Cmp* defsurf, const Cmp* defsurf2, double zoom,
73  bool draw_bound, int ncour, int nx, int nz) {
74 
75  const Map& mp = *(uu.get_mp()) ;
76 
77  double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;
78  double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;
79  double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;
80  double ray = mp.val_r(nzdes-1, 1., 0., 0.) ;
81 
82  ray = ( a1 > ray ) ? a1 : ray ;
83  ray = ( a2 > ray ) ? a2 : ray ;
84  ray = ( a3 > ray ) ? a3 : ray ;
85 
86  ray *= zoom ;
87 
88  double x_min = mp.get_ori_x() - ray ;
89  double x_max = mp.get_ori_x() + ray ;
90  double z_min = mp.get_ori_z() - ray ;
91  double z_max = mp.get_ori_z() + ray ;
92 
93  des_bi_coupe_y(uu, y0, x_min, x_max, z_min, z_max, title, defsurf,
94  defsurf2, draw_bound, ncour, nx, nz) ;
95 
96 }
97 
98 //******************************************************************************
99 
100 void des_bi_coupe_y(const Cmp& uu, double y0, double x_min, double x_max,
101  double z_min, double z_max, const char* title, const Cmp* defsurf,
102  const Cmp* defsurf2, bool draw_bound, int ncour, int nx,
103  int nz) {
104 
105  using namespace Unites ;
106 
107  const Map& mp = *(uu.get_mp()) ;
108 
109  // Plot of isocontours
110  // -------------------
111 
112  float* uutab = new float[nx*nz] ;
113 
114  double hx = (x_max - x_min) / double(nx-1) ;
115  double hza = (z_max - z_min) / double(nz-1) ;
116 
117 
118 
119  for (int j=0; j<nz; j++) {
120 
121  double z = z_min + hza * j ;
122 
123  for (int i=0; i<nx; i++) {
124 
125  double x = x_min + hx * i ;
126 
127  // Computation of (r,theta,phi) :
128  double r, theta, phi ;
129  mp.convert_absolute(x, y0, z, r, theta, phi) ;
130 
131  uutab[nx*j+i] = float(uu.val_point(r, theta, phi)) ;
132  }
133  }
134 
135  float xmin1 = float(x_min / km) ;
136  float xmax1 = float(x_max / km) ;
137  float zmin1 = float(z_min / km) ;
138  float zmax1 = float(z_max / km) ;
139 
140  const char* nomx = "x [km]" ;
141  const char* nomz = "z [km]" ;
142 
143  if (title == 0x0) {
144  title = "" ;
145  }
146 
147 
148  const char* device = 0x0 ;
149  int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ;
150 
151  des_equipot(uutab, nx, nz, xmin1, xmax1, zmin1, zmax1, ncour, nomx, nomz,
152  title, device, newgraph) ;
153 
154  // Plot of the surface
155  // -------------------
156 
157  if (defsurf != 0x0) {
158 
159  assert(defsurf->get_mp() == uu.get_mp()) ;
160 
161  newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;
162 
163  des_surface_y(*defsurf, y0, device, newgraph) ;
164 
165  } // End of the surface drawing
166 
167  if (defsurf2 != 0x0) {
168 
169  assert(defsurf2->get_mp() == uu.get_mp()) ;
170 
171  newgraph = draw_bound ? 0 : 2 ;
172 
173  des_surface_y(*defsurf2, y0, device, newgraph) ;
174 
175  } // End of the surface drawing
176 
177  delete [] uutab ;
178 
179  // Plot of the domains outer boundaries
180  // ------------------------------------
181 
182  if (draw_bound) {
183 
184  int ndom = mp.get_mg()->get_nzone() ; // total number of domains
185 
186  for (int l=0; l<ndom-1; l++) { // loop on the domains (except the
187  // last one)
188 
189  newgraph = (l == ndom-2) ? 2 : 0 ;
190 
191  des_domaine_y(mp, l, y0, device, newgraph) ;
192  }
193  }
194 
195 
196 }
197 }
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.
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.
void des_bi_coupe_y(const Cmp &uu, double y0, int nzdes, const char *title=0x0, const Cmp *defsurf=0x0, const Cmp *defsurf2=0x0, double zoom=1.2, bool draw_bound=true, int ncour=15, int nx=100, int nz=100)
Draws isocontour lines of a Cmp in a plane Y=constant.