LORENE
star_rot_lambda_grv2.C
1 /*
2  * Method Star_rot::lambda_grv2.
3  *
4  * (see file star_rot.h for documentation)
5  *
6  */
7 
8 /*
9  * Copyright (c) 2010 Eric Gourgoulhon
10  * (c) 2017 Jerome Novak
11  *
12  * This file is part of LORENE.
13  *
14  * LORENE is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * LORENE is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with LORENE; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29 
30 
31 
32 
33 /*
34  * $Id: star_rot_lambda_grv2.C,v 1.6 2017/10/20 13:54:20 j_novak Exp $
35  * $Log: star_rot_lambda_grv2.C,v $
36  * Revision 1.6 2017/10/20 13:54:20 j_novak
37  * Now calling C++ function integrale2d instead of old FORTRAN routines.
38  *
39  * Revision 1.5 2016/12/05 16:18:15 j_novak
40  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
41  *
42  * Revision 1.4 2014/10/13 08:53:39 j_novak
43  * Lorene classes and functions now belong to the namespace Lorene.
44  *
45  * Revision 1.3 2014/10/06 15:13:17 j_novak
46  * Modified #include directives to use c++ syntax.
47  *
48  * Revision 1.2 2013/06/05 15:10:43 j_novak
49  * Suppression of FINJAC sampling in r. This Jacobi(0,2) base is now
50  * available by setting colloc_r to BASE_JAC02 in the Mg3d constructor.
51  *
52  * Revision 1.1 2010/01/25 18:15:52 e_gourgoulhon
53  * First version.
54  *
55  *
56  *
57  * $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_lambda_grv2.C,v 1.6 2017/10/20 13:54:20 j_novak Exp $
58  *
59  */
60 
61 // Headers C
62 #include <cmath>
63 
64 // Headers Lorene
65 #include "star_rot.h"
66 #include "proto.h"
67 
68 namespace Lorene {
69  double Star_rot::lambda_grv2(const Scalar& sou_m, const Scalar& sou_q) {
70 
71  const Map_radial* mprad = dynamic_cast<const Map_radial*>( &sou_m.get_mp() ) ;
72 
73  if (mprad == 0x0) {
74  cout << "Star_rot::lambda_grv2: the mapping of sou_m does not"
75  << endl << " belong to the class Map_radial !" << endl ;
76  abort() ;
77  }
78 
79  assert( &sou_q.get_mp() == mprad ) ;
80 
81  sou_q.check_dzpuis(4) ;
82 
83  const Mg3d* mg = mprad->get_mg() ;
84  int nz = mg->get_nzone() ;
85 
86  // Construction of a Map_af which coincides with *mp on the equator
87  // ----------------------------------------------------------------
88 
89  double theta0 = M_PI / 2 ; // Equator
90  double phi0 = 0 ;
91 
92  Map_af mpaff(*mprad) ;
93 
94  for (int l=0 ; l<nz ; l++) {
95  double rmax = mprad->val_r(l, double(1), theta0, phi0) ;
96  switch ( mg->get_type_r(l) ) {
97  case RARE: {
98  double rmin = mprad->val_r(l, double(0), theta0, phi0) ;
99  mpaff.set_alpha(rmax - rmin, l) ;
100  mpaff.set_beta(rmin, l) ;
101  break ;
102  }
103 
104  case FIN: {
105  double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
106  mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
107  mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
108  break ;
109  }
110 
111 
112  case UNSURR: {
113  double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
114  double umax = double(1) / rmin ;
115  double umin = double(1) / rmax ;
116  mpaff.set_alpha( double(.5) * (umin - umax), l) ;
117  mpaff.set_beta( double(.5) * (umin + umax), l) ;
118  break ;
119  }
120 
121  default: {
122  cout << "Star_rot::lambda_grv2: unknown type_r ! " << endl ;
123  abort () ;
124  break ;
125  }
126 
127  }
128  }
129 
130 
131  // Reduced Jacobian of
132  // the transformation (r,theta,phi) <-> (dzeta,theta',phi')
133  // ------------------------------------------------------------
134 
135  Mtbl jac = 1 / ( (mprad->xsr) * (mprad->dxdr) ) ;
136  // R/x dR/dx in the nucleus
137  // R dR/dx in the shells
138  // - U/(x-1) dU/dx in the ZEC
139  for (int l=0; l<nz; l++) {
140  switch ( mg->get_type_r(l) ) {
141  case RARE: {
142  double a1 = mpaff.get_alpha()[l] ;
143  *(jac.t[l]) = *(jac.t[l]) / (a1*a1) ;
144  break ;
145  }
146 
147  case FIN: {
148  double a1 = mpaff.get_alpha()[l] ;
149  double b1 = mpaff.get_beta()[l] ;
150  assert( jac.t[l]->get_etat() == ETATQCQ ) ;
151  double* tjac = jac.t[l]->t ;
152  double* const xi = mg->get_grille3d(l)->x ;
153  for (int k=0; k<mg->get_np(l); k++) {
154  for (int j=0; j<mg->get_nt(l); j++) {
155  for (int i=0; i<mg->get_nr(l); i++) {
156  *tjac = *tjac /
157  (a1 * (a1 * xi[i] + b1) ) ;
158  tjac++ ;
159  }
160  }
161  }
162 
163  break ;
164  }
165 
166 
167  case UNSURR: {
168  double a1 = mpaff.get_alpha()[l] ;
169  *(jac.t[l]) = - *(jac.t[l]) / (a1*a1) ;
170  break ;
171  }
172 
173  default: {
174  cout << "Star_rot::lambda_grv2: unknown type_r ! " << endl ;
175  abort () ;
176  break ;
177  }
178 
179  }
180 
181  }
182 
183 
184  // Multiplication of the sources by the reduced Jacobian:
185  // -----------------------------------------------------
186 
187  Mtbl s_m(mg) ;
188  if ( sou_m.get_etat() == ETATZERO ) {
189  s_m = 0 ;
190  }
191  else{
192  assert(sou_m.get_spectral_va().get_etat() == ETATQCQ) ;
193  sou_m.get_spectral_va().coef_i() ;
194  s_m = *(sou_m.get_spectral_va().c) ;
195  }
196 
197  Mtbl s_q(mg) ;
198  if ( sou_q.get_etat() == ETATZERO ) {
199  s_q = 0 ;
200  }
201  else{
202  assert(sou_q.get_spectral_va().get_etat() == ETATQCQ) ;
203  sou_q.get_spectral_va().coef_i() ;
204  s_q = *(sou_q.get_spectral_va().c) ;
205  }
206 
207  s_m *= jac ;
208  s_q *= jac ;
209 
210  // Computation of the integrals
211  // ----------------------------
212  Scalar af_soum(mpaff) ;
213  af_soum = s_m ;
214  af_soum.std_spectral_base() ;
215  af_soum.set_dzpuis(sou_m.get_dzpuis()) ;
216 
217  Scalar af_souq(mpaff) ;
218  af_souq = s_q ;
219  af_souq.std_spectral_base() ;
220  af_souq.set_dzpuis(sou_q.get_dzpuis()) ;
221 
222  double int_m = integrale2d(af_soum) ;
223  double int_q = integrale2d(af_souq) ;
224 
225  // Computation of lambda
226  // ---------------------
227 
228  double lambda ;
229  if ( int_q != double(0) ) {
230  lambda = - int_m / int_q ;
231  }
232  else{
233  lambda = 0 ;
234  }
235 
236  return lambda ;
237 
238  }
239 }
const Grille3d * get_grille3d(int l) const
Returns a pointer on the 3D mono-grid for domain no. l.
Definition: grilles.h:517
const double * get_alpha() const
Returns the pointer on the array alpha.
Definition: map_af.C:604
static double lambda_grv2(const Scalar &sou_m, const Scalar &sou_q)
Computes the coefficient which ensures that the GRV2 virial identity is satisfied.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
Multi-domain array.
Definition: mtbl.h:118
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:777
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
void coef_i() const
Computes the physical value of *this.
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Definition: scalar.C:790
int get_etat() const
Gives the logical state.
Definition: tbl.h:414
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition: scalar.h:560
double * x
Array of values of at the nr collocation points.
Definition: grilles.h:215
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition: scalar.C:814
void set_beta(double beta0, int l)
Modifies the value of in domain no. l.
Definition: map_af.C:768
int get_etat() const
Returns the logical state.
Definition: valeur.h:760
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.
Coord dxdr
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition: map.h:1575
int get_dzpuis() const
Returns dzpuis.
Definition: scalar.h:563
double * t
The array of double.
Definition: tbl.h:176
const double * get_beta() const
Returns the pointer on the array beta.
Definition: map_af.C:608
Mtbl * c
Values of the function at the points of the multi-grid.
Definition: valeur.h:309
Base class for pure radial mappings.
Definition: map.h:1551
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
void set_alpha(double alpha0, int l)
Modifies the value of in domain no. l.
Definition: map_af.C:757
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain...
Definition: map.h:1564
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Multi-domain grid.
Definition: grilles.h:279
Affine radial mapping.
Definition: map.h:2042
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491
bool check_dzpuis(int dzi) const
Returns false if the last domain is compactified and *this is not zero in this domain and dzpuis is n...
Definition: scalar.C:879
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s.
Definition: mtbl.h:132
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:874
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:607