star_global.C
/*
* Methods of class Star to compute global quantities
*/
/*
* Copyright (c) 2004 francois Limousin
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char star_global_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_global.C,v 1.6 2014/10/13 08:53:39 j_novak Exp $" ;
/*
* $Id: star_global.C,v 1.6 2014/10/13 08:53:39 j_novak Exp $
* $Log: star_global.C,v $
* Revision 1.6 2014/10/13 08:53:39 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.5 2013/04/25 15:46:06 j_novak
* Added special treatment in the case np = 1, for type_p = NONSYM.
*
* Revision 1.4 2009/10/26 10:54:33 j_novak
* Added the case of a NONSYM base in theta.
*
* Revision 1.3 2007/06/21 19:55:09 k_taniguchi
* Introduction of a method to compute ray_eq_3pis2().
*
* Revision 1.2 2004/01/20 15:20:48 f_limousin
* First version
*
*
* $Header: /cvsroot/Lorene/C++/Source/Star/star_global.C,v 1.6 2014/10/13 08:53:39 j_novak Exp $
*
*/
// Headers C
#include "math.h"
// Headers Lorene
#include "star.h"
//--------------------------//
// Stellar surface //
//--------------------------//
namespace Lorene {
const Itbl& Star::l_surf() const {
if (p_l_surf == 0x0) { // a new computation is required
assert(p_xi_surf == 0x0) ; // consistency check
int np = mp.get_mg()->get_np(0) ;
int nt = mp.get_mg()->get_nt(0) ;
p_l_surf = new Itbl(np, nt) ;
p_xi_surf = new Tbl(np, nt) ;
double ent0 = 0 ; // definition of the surface
double precis = 1.e-15 ;
int nitermax = 100 ;
int niter ;
(ent.get_spectral_va()).equipot(ent0, nzet, precis, nitermax, niter, *p_l_surf,
*p_xi_surf) ;
}
return *p_l_surf ;
}
const Tbl& Star::xi_surf() const {
if (p_xi_surf == 0x0) { // a new computation is required
assert(p_l_surf == 0x0) ; // consistency check
l_surf() ; // the computation is done by l_surf()
}
return *p_xi_surf ;
}
//--------------------------//
// Coordinate radii //
//--------------------------//
double Star::ray_eq() const {
if (p_ray_eq == 0x0) { // a new computation is required
const Mg3d& mg = *(mp.get_mg()) ;
int type_t = mg.get_type_t() ;
#ifndef NDEBUG
int type_p = mg.get_type_p() ;
#endif
int nt = mg.get_nt(0) ;
assert( (type_t == SYM) || (type_t == NONSYM) ) ;
assert( (type_p == SYM) || (type_p == NONSYM) ) ;
int k = 0 ;
int j = (type_t == SYM ? nt-1 : nt / 2);
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
double theta = M_PI / 2 ;
double phi = 0 ;
p_ray_eq = new double( mp.val_r(l, xi, theta, phi) ) ;
}
return *p_ray_eq ;
}
double Star::ray_eq_pis2() const {
if (p_ray_eq_pis2 == 0x0) { // a new computation is required
const Mg3d& mg = *(mp.get_mg()) ;
int type_t = mg.get_type_t() ;
int type_p = mg.get_type_p() ;
int nt = mg.get_nt(0) ;
int np = mg.get_np(0) ;
int j = (type_t == SYM ? nt-1 : nt / 2);
double theta = M_PI / 2 ;
double phi = M_PI / 2 ;
switch (type_p) {
case SYM : {
int k = np / 2 ;
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
break ;
}
case NONSYM : {
assert( (np == 1) || (np % 4 == 0) ) ;
int k = np / 4 ;
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
break ;
}
default : {
cout << "Star::ray_eq_pis2 : the case type_p = "
<< type_p << " is not contemplated yet !" << endl ;
abort() ;
}
}
}
return *p_ray_eq_pis2 ;
}
double Star::ray_eq_pi() const {
if (p_ray_eq_pi == 0x0) { // a new computation is required
const Mg3d& mg = *(mp.get_mg()) ;
int type_t = mg.get_type_t() ;
int type_p = mg.get_type_p() ;
int nt = mg.get_nt(0) ;
int np = mg.get_np(0) ;
assert ( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
switch (type_p) {
case SYM : {
p_ray_eq_pi = new double( ray_eq() ) ;
break ;
}
case NONSYM : {
int k = np / 2 ;
int j = (type_t == SYM ? nt-1 : nt/2 ) ;
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
double theta = M_PI / 2 ;
double phi = M_PI ;
p_ray_eq_pi = new double( mp.val_r(l, xi, theta, phi) ) ;
break ;
}
default : {
cout << "Star::ray_eq_pi : the case type_p = " << type_p << endl ;
cout << " is not contemplated yet !" << endl ;
abort() ;
break ;
}
}
}
return *p_ray_eq_pi ;
}
double Star::ray_eq_3pis2() const {
if (p_ray_eq_3pis2 == 0x0) { // a new computation is required
const Mg3d& mg = *(mp.get_mg()) ;
int type_t = mg.get_type_t() ;
int type_p = mg.get_type_p() ;
int nt = mg.get_nt(0) ;
int np = mg.get_np(0) ;
assert( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
int j = (type_t == SYM ? nt-1 : nt/2 );
double theta = M_PI / 2 ;
double phi = 3. * M_PI / 2 ;
switch (type_p) {
case SYM : {
p_ray_eq_3pis2 = new double( ray_eq_pis2() ) ;
break ;
}
case NONSYM : {
assert( np % 4 == 0 ) ;
int k = 3 * np / 4 ;
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
p_ray_eq_3pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
break ;
}
default : {
cout << "Star::ray_eq_3pis2 : the case type_p = "
<< type_p << " is not implemented yet !" << endl ;
abort() ;
}
}
}
return *p_ray_eq_3pis2 ;
}
double Star::ray_pole() const {
if (p_ray_pole == 0x0) { // a new computation is required
#ifndef NDEBUG
const Mg3d& mg = *(mp.get_mg()) ;
int type_t = mg.get_type_t() ;
#endif
assert( (type_t == SYM) || (type_t == NONSYM) ) ;
int k = 0 ;
int j = 0 ;
int l = l_surf()(k, j) ;
double xi = xi_surf()(k, j) ;
double theta = 0 ;
double phi = 0 ;
p_ray_pole = new double( mp.val_r(l, xi, theta, phi) ) ;
}
return *p_ray_pole ;
}
//--------------------------//
// Baryon mass //
//--------------------------//
double Star::mass_b() const {
if (p_mass_b == 0x0) { // a new computation is required
cout <<
"Star::mass_b : in the relativistic case, the baryon mass"
<< endl <<
"computation cannot be performed by the base class Star !"
<< endl ;
abort() ;
}
return *p_mass_b ;
}
//----------------------------//
// Gravitational mass //
//----------------------------//
double Star::mass_g() const {
if (p_mass_g == 0x0) { // a new computation is required
cout <<
"Star::mass_g : in the relativistic case, the gravitational mass"
<< endl <<
"computation cannot be performed by the base class Star !"
<< endl ;
abort() ;
}
return *p_mass_g ;
}
}
Lorene::Itbl
Basic integer array class.
Definition itbl.h:122
Lorene::Mg3d
Multi-domain grid.
Definition grilles.h:273
Lorene::Mg3d::get_type_t
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
Definition grilles.h:485
Lorene::Mg3d::get_np
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition grilles.h:462
Lorene::Mg3d::get_type_p
int get_type_p() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the transformatio...
Definition grilles.h:495
Lorene::Mg3d::get_nt
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:457
Lorene::Star::mass_g
virtual double mass_g() const =0
Gravitational mass.
Definition star_global.C:327
Lorene::Star::l_surf
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...
Definition star_global.C:63
Lorene::Star::p_mass_b
double * p_mass_b
Baryon mass.
Definition star.h:268
Lorene::Star::ray_eq_3pis2
double ray_eq_3pis2() const
Coordinate radius at , [r_unit].
Definition star_global.C:233
Lorene::Star::p_ray_eq
double * p_ray_eq
Coordinate radius at , .
Definition star.h:242
Lorene::Star::xi_surf
const Tbl & xi_surf() const
Description of the stellar surface: returns a 2-D Tbl containing the values of the radial coordinate ...
Definition star_global.C:89
Lorene::Star::p_ray_eq_pi
double * p_ray_eq_pi
Coordinate radius at , .
Definition star.h:248
Lorene::Star::p_l_surf
Itbl * p_l_surf
Description of the stellar surface: 2-D Itbl containing the values of the domain index l on the surfa...
Definition star.h:260
Lorene::Star::p_ray_eq_pis2
double * p_ray_eq_pis2
Coordinate radius at , .
Definition star.h:245
Lorene::Star::p_ray_eq_3pis2
double * p_ray_eq_3pis2
Coordinate radius at , .
Definition star.h:251
Lorene::Star::ray_eq
double ray_eq() const
Coordinate radius at , [r_unit].
Definition star_global.C:108
Lorene::Star::p_mass_g
double * p_mass_g
Gravitational mass.
Definition star.h:269
Lorene::Star::p_xi_surf
Tbl * p_xi_surf
Description of the stellar surface: 2-D Tbl containing the values of the radial coordinate on the su...
Definition star.h:266
Lorene::Star::ray_eq_pis2
double ray_eq_pis2() const
Coordinate radius at , [r_unit].
Definition star_global.C:138
Lorene::Star::ray_eq_pi
double ray_eq_pi() const
Coordinate radius at , [r_unit].
Definition star_global.C:186
Lorene::Star::ent
Scalar ent
Log-enthalpy.
Definition star.h:190
Lorene::Star::mp
Map & mp
Mapping associated with the star.
Definition star.h:180
Lorene::Star::nzet
int nzet
Number of domains of *mp occupied by the star.
Definition star.h:183
Lorene::Star::p_ray_pole
double * p_ray_pole
Coordinate radius at .
Definition star.h:254
Lorene::Star::ray_pole
double ray_pole() const
Coordinate radius at [r_unit].
Definition star_global.C:278
Lorene::Star::mass_b
virtual double mass_b() const =0
Baryon mass.
Definition star_global.C:307
Lorene::Tbl
Basic array class.
Definition tbl.h:161
Lorene
Lorene prototypes.
Definition app_hor.h:64
Lorene::phi
Coord phi
coordinate centered on the grid
Definition map.h:720