LORENE
des_prof_cmp.C
1 /*
2  * Draws the profile of a {\tt Cmp} along some radial axis determined by
3  * a fixed value of $(\theta, \phi)$.
4  */
5 
6 /*
7  * Copyright (c) 1999-2004 Eric Gourgoulhon
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * LORENE is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with LORENE; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  */
26 
27 
28 
29 
30 
31 /*
32  * $Id: des_prof_cmp.C,v 1.9 2016/12/05 16:18:06 j_novak Exp $
33  * $Log: des_prof_cmp.C,v $
34  * Revision 1.9 2016/12/05 16:18:06 j_novak
35  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36  *
37  * Revision 1.8 2014/10/13 08:53:22 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.7 2014/10/06 15:16:05 j_novak
41  * Modified #include directives to use c++ syntax.
42  *
43  * Revision 1.6 2008/08/19 06:42:00 j_novak
44  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
45  * cast-type operations, and constant strings that must be defined as const char*
46  *
47  * Revision 1.5 2004/03/25 10:29:25 j_novak
48  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
49  *
50  * Revision 1.4 2004/02/12 16:20:36 e_gourgoulhon
51  * Functions des_profile for Scalar's are now in the new file
52  * des_prof_scalar.C
53  *
54  * Revision 1.3 2004/02/04 14:28:14 p_grandclement
55  * Ajout de la version Scalar de des_profile
56  *
57  * Revision 1.2 2003/06/03 09:59:35 e_gourgoulhon
58  * Added a new des_profile with scale and nomx in arguments
59  *
60  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
61  * LORENE
62  *
63  * Revision 1.1 1999/12/09 16:38:31 eric
64  * Initial revision
65  *
66  *
67  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_prof_cmp.C,v 1.9 2016/12/05 16:18:06 j_novak Exp $
68  *
69  */
70 
71 // Header C
72 #include <cmath>
73 
74 
75 // Header Lorene
76 #include "cmp.h"
77 #include "graphique.h"
78 #include "unites.h"
79 
80 namespace Lorene {
81 //******************************************************************************
82 
83 void des_profile(const Cmp& uu, double r_min, double r_max,
84  double theta, double phi, const char* nomy, const char* title) {
85 
86 using namespace Unites ;
87 
88  const int npt = 400 ; // Number of points along the axis
89 
90  float uutab[npt] ; // Value of uu at the npt points
91 
92  double hr = (r_max - r_min) / double(npt-1) ;
93 
94  for (int i=0; i<npt; i++) {
95 
96  double r = hr * i + r_min ;
97 
98  uutab[i] = float(uu.val_point(r, theta, phi)) ;
99 
100  }
101 
102  float xmin = float(r_min / km) ;
103  float xmax = float(r_max / km) ;
104 
105  const char* nomx = "r [km]" ;
106 
107  if (title == 0x0) {
108  title = "" ;
109  }
110 
111  if (nomy == 0x0) {
112  nomy = "" ;
113  }
114 
115 
116  des_profile(uutab, npt, xmin, xmax, nomx, nomy, title) ;
117 
118 }
119 
120 //******************************************************************************
121 
122 void des_profile(const Cmp& uu, double r_min, double r_max, double scale,
123  double theta, double phi, const char* nomx, const char* nomy, const char* title) {
124 
125 
126  const int npt = 400 ; // Number of points along the axis
127 
128  float uutab[npt] ; // Value of uu at the npt points
129 
130  double hr = (r_max - r_min) / double(npt-1) ;
131 
132  for (int i=0; i<npt; i++) {
133 
134  double r = hr * i + r_min ;
135 
136  uutab[i] = float(uu.val_point(r, theta, phi)) ;
137 
138  }
139 
140  float xmin = float(r_min * scale) ;
141  float xmax = float(r_max * scale) ;
142 
143 
144  if (title == 0x0) {
145  title = "" ;
146  }
147 
148  if (nomx == 0x0) {
149  nomx = "" ;
150  }
151 
152  if (nomy == 0x0) {
153  nomy = "" ;
154  }
155 
156 
157  des_profile(uutab, npt, xmin, xmax, nomx, nomy, title) ;
158 
159 }
160 
161 
162 }
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
void des_profile(const float *uutab, int nx, float xmin, float xmax, const char *nomx, const char *nomy, const char *title, const char *device=0x0, int nbound=0, float *xbound=0x0, bool logscale=false)
Basic routine for drawing a single profile with uniform x sampling.
Definition: des_profile.C:97