LORENE
hot_star_global.C
1 /*
2  * Methods of class Hot_star to compute global quantities
3  */
4 
5 /*
6  * Copyright (c) 2004 francois Limousin
7  *
8  * This file is part of LORENE.
9  *
10  * LORENE is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 
27 
28 
29 /*
30  * $Id: hot_star_global.C,v 1.1 2026/03/23 17:33:04 s_jaraba Exp $
31  * $Log: hot_star_global.C,v $
32  * Revision 1.1 2026/03/23 17:33:04 s_jaraba
33  * Initial commit for classes Hot_star, Hot_star_rot_CFC and Hot_star_rot_diff_CFC
34  *
35  * Revision 1.7 2016/12/05 16:18:15 j_novak
36  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37  *
38  * Revision 1.6 2014/10/13 08:53:39 j_novak
39  * Lorene classes and functions now belong to the namespace Lorene.
40  *
41  * Revision 1.5 2013/04/25 15:46:06 j_novak
42  * Added special treatment in the case np = 1, for type_p = NONSYM.
43  *
44  * Revision 1.4 2009/10/26 10:54:33 j_novak
45  * Added the case of a NONSYM base in theta.
46  *
47  * Revision 1.3 2007/06/21 19:55:09 k_taniguchi
48  * Introduction of a method to compute ray_eq_3pis2().
49  *
50  * Revision 1.2 2004/01/20 15:20:48 f_limousin
51  * First version
52  *
53  *
54  * $Header: /cvsroot/Lorene/C++/Source/Star/hot_star_global.C,v 1.1 2026/03/23 17:33:04 s_jaraba Exp $
55  *
56  */
57 
58 // Headers C
59 #include "math.h"
60 
61 // Headers Lorene
62 #include "hot_star.h"
63 
64  //--------------------------//
65  // Stellar surface //
66  //--------------------------//
67 
68 namespace Lorene {
69 const Itbl& Hot_star::l_surf() const {
70 
71  if (p_l_surf == 0x0) { // a new computation is required
72 
73  assert(p_xi_surf == 0x0) ; // consistency check
74 
75  int np = mp.get_mg()->get_np(0) ;
76  int nt = mp.get_mg()->get_nt(0) ;
77 
78  p_l_surf = new Itbl(np, nt) ;
79  p_xi_surf = new Tbl(np, nt) ;
80 
81  double ent0 = 0 ; // definition of the surface
82  double precis = 1.e-15 ;
83  int nitermax = 100 ;
84  int niter ;
85 
86  (ent.get_spectral_va()).equipot(ent0, nzet, precis, nitermax, niter, *p_l_surf,
87  *p_xi_surf) ;
88 
89  }
90 
91  return *p_l_surf ;
92 
93 }
94 
95 const Tbl& Hot_star::xi_surf() const {
96 
97  if (p_xi_surf == 0x0) { // a new computation is required
98 
99  assert(p_l_surf == 0x0) ; // consistency check
100 
101  l_surf() ; // the computation is done by l_surf()
102 
103  }
104 
105  return *p_xi_surf ;
106 
107 }
108 
109 
110  //--------------------------//
111  // Coordinate radii //
112  //--------------------------//
113 
114 double Hot_star::ray_eq() const {
115 
116  if (p_ray_eq == 0x0) { // a new computation is required
117 
118  const Mg3d& mg = *(mp.get_mg()) ;
119 
120  int type_t = mg.get_type_t() ;
121 #ifndef NDEBUG
122  int type_p = mg.get_type_p() ;
123 #endif
124  int nt = mg.get_nt(0) ;
125 
126  assert( (type_t == SYM) || (type_t == NONSYM) ) ;
127  assert( (type_p == SYM) || (type_p == NONSYM) ) ;
128  int k = 0 ;
129  int j = (type_t == SYM ? nt-1 : nt / 2);
130  int l = l_surf()(k, j) ;
131  double xi = xi_surf()(k, j) ;
132  double theta = M_PI / 2 ;
133  double phi = 0 ;
134 
135  p_ray_eq = new double( mp.val_r(l, xi, theta, phi) ) ;
136 
137  }
138 
139  return *p_ray_eq ;
140 
141 }
142 
143 
144 double Hot_star::ray_eq_pis2() const {
145 
146  if (p_ray_eq_pis2 == 0x0) { // a new computation is required
147 
148  const Mg3d& mg = *(mp.get_mg()) ;
149 
150  int type_t = mg.get_type_t() ;
151  int type_p = mg.get_type_p() ;
152  int nt = mg.get_nt(0) ;
153  int np = mg.get_np(0) ;
154 
155  int j = (type_t == SYM ? nt-1 : nt / 2);
156  double theta = M_PI / 2 ;
157  double phi = M_PI / 2 ;
158 
159  switch (type_p) {
160 
161  case SYM : {
162  int k = np / 2 ;
163  int l = l_surf()(k, j) ;
164  double xi = xi_surf()(k, j) ;
165  p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
166  break ;
167  }
168 
169  case NONSYM : {
170  assert( (np == 1) || (np % 4 == 0) ) ;
171  int k = np / 4 ;
172  int l = l_surf()(k, j) ;
173  double xi = xi_surf()(k, j) ;
174  p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
175  break ;
176  }
177 
178  default : {
179  cout << "Hot_star::ray_eq_pis2 : the case type_p = "
180  << type_p << " is not contemplated yet !" << endl ;
181  abort() ;
182  }
183  }
184 
185  }
186 
187  return *p_ray_eq_pis2 ;
188 
189 }
190 
191 
192 double Hot_star::ray_eq_pi() const {
193 
194  if (p_ray_eq_pi == 0x0) { // a new computation is required
195 
196  const Mg3d& mg = *(mp.get_mg()) ;
197 
198  int type_t = mg.get_type_t() ;
199  int type_p = mg.get_type_p() ;
200  int nt = mg.get_nt(0) ;
201  int np = mg.get_np(0) ;
202 
203  assert ( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
204 
205  switch (type_p) {
206 
207  case SYM : {
208  p_ray_eq_pi = new double( ray_eq() ) ;
209  break ;
210  }
211 
212  case NONSYM : {
213  int k = np / 2 ;
214  int j = (type_t == SYM ? nt-1 : nt/2 ) ;
215  int l = l_surf()(k, j) ;
216  double xi = xi_surf()(k, j) ;
217  double theta = M_PI / 2 ;
218  double phi = M_PI ;
219 
220  p_ray_eq_pi = new double( mp.val_r(l, xi, theta, phi) ) ;
221  break ;
222  }
223 
224  default : {
225 
226  cout << "Hot_star::ray_eq_pi : the case type_p = " << type_p << endl ;
227  cout << " is not contemplated yet !" << endl ;
228  abort() ;
229  break ;
230  }
231  }
232 
233  }
234 
235  return *p_ray_eq_pi ;
236 
237 }
238 
239 double Hot_star::ray_eq_3pis2() const {
240 
241  if (p_ray_eq_3pis2 == 0x0) { // a new computation is required
242 
243  const Mg3d& mg = *(mp.get_mg()) ;
244 
245  int type_t = mg.get_type_t() ;
246  int type_p = mg.get_type_p() ;
247  int nt = mg.get_nt(0) ;
248  int np = mg.get_np(0) ;
249 
250  assert( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
251 
252  int j = (type_t == SYM ? nt-1 : nt/2 );
253  double theta = M_PI / 2 ;
254  double phi = 3. * M_PI / 2 ;
255 
256  switch (type_p) {
257 
258  case SYM : {
259  p_ray_eq_3pis2 = new double( ray_eq_pis2() ) ;
260  break ;
261  }
262 
263  case NONSYM : {
264  assert( np % 4 == 0 ) ;
265  int k = 3 * np / 4 ;
266  int l = l_surf()(k, j) ;
267  double xi = xi_surf()(k, j) ;
268  p_ray_eq_3pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
269  break ;
270  }
271 
272  default : {
273  cout << "Hot_star::ray_eq_3pis2 : the case type_p = "
274  << type_p << " is not implemented yet !" << endl ;
275  abort() ;
276  }
277  }
278  }
279 
280  return *p_ray_eq_3pis2 ;
281 
282 }
283 
284 double Hot_star::ray_pole() const {
285 
286  if (p_ray_pole == 0x0) { // a new computation is required
287 
288 #ifndef NDEBUG
289  const Mg3d& mg = *(mp.get_mg()) ;
290  int type_t = mg.get_type_t() ;
291 #endif
292  assert( (type_t == SYM) || (type_t == NONSYM) ) ;
293 
294  int k = 0 ;
295  int j = 0 ;
296  int l = l_surf()(k, j) ;
297  double xi = xi_surf()(k, j) ;
298  double theta = 0 ;
299  double phi = 0 ;
300 
301  p_ray_pole = new double( mp.val_r(l, xi, theta, phi) ) ;
302 
303  }
304 
305  return *p_ray_pole ;
306 
307 }
308 
309  //--------------------------//
310  // Baryon mass //
311  //--------------------------//
312 
313 double Hot_star::mass_b() const {
314 
315  if (p_mass_b == 0x0) { // a new computation is required
316 
317  cout <<
318  "Hot_star::mass_b : in the relativistic case, the baryon mass"
319  << endl <<
320  "computation cannot be performed by the base class Hot_star !"
321  << endl ;
322  abort() ;
323  }
324 
325  return *p_mass_b ;
326 
327 }
328 
329  //----------------------------//
330  // Gravitational mass //
331  //----------------------------//
332 
333 double Hot_star::mass_g() const {
334 
335  if (p_mass_g == 0x0) { // a new computation is required
336 
337  cout <<
338  "Hot_star::mass_g : in the relativistic case, the gravitational mass"
339  << endl <<
340  "computation cannot be performed by the base class Hot_star !"
341  << endl ;
342  abort() ;
343  }
344 
345  return *p_mass_g ;
346 
347 }
348 
349 }
int get_type_p() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the transformatio...
Definition: grilles.h:514
virtual double mass_b() const =0
Baryon mass.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:481
double * p_ray_pole
Coordinate radius at .
Definition: hot_star.h:159
double * p_mass_g
Gravitational mass.
Definition: hot_star.h:174
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:791
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
Definition: grilles.h:504
Basic integer array class.
Definition: itbl.h:122
double ray_eq_pi() const
Coordinate radius at , [r_unit].
virtual const Itbl & l_surf() const
Description of the stellar surface: returns a 2-D Itbl containing the values of the domain index l on...
double ray_eq_pis2() const
Coordinate radius at , [r_unit].
double ray_eq() const
Coordinate radius at , [r_unit].
int nzet
Number of domains of *mp occupied by the star.
Definition: hot_star.h:84
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
Itbl * p_l_surf
Description of the stellar surface: 2-D Itbl containing the values of the domain index l on the surfa...
Definition: hot_star.h:165
double * p_ray_eq_pis2
Coordinate radius at , .
Definition: hot_star.h:150
Tbl * p_xi_surf
Description of the stellar surface: 2-D Tbl containing the values of the radial coordinate on the su...
Definition: hot_star.h:171
double * p_mass_b
Baryon mass.
Definition: hot_star.h:173
Scalar ent
Log-enthalpy.
Definition: hot_star.h:91
Map & mp
Mapping associated with the star.
Definition: hot_star.h:81
double * p_ray_eq_pi
Coordinate radius at , .
Definition: hot_star.h:153
Multi-domain grid.
Definition: grilles.h:276
double * p_ray_eq_3pis2
Coordinate radius at , .
Definition: hot_star.h:156
virtual double mass_g() const =0
Gravitational mass.
double ray_eq_3pis2() const
Coordinate radius at , [r_unit].
Basic array class.
Definition: tbl.h:164
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:476
double ray_pole() const
Coordinate radius at [r_unit].
double * p_ray_eq
Coordinate radius at , .
Definition: hot_star.h:147
const Tbl & xi_surf() const
Description of the stellar surface: returns a 2-D Tbl containing the values of the radial coordinate ...
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:616