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