LORENE
et_rot_lambda_grv2.C
1/*
2 * Method Etoile_rot::lambda_grv2.
3 *
4 * (see file etoile.h for documentation)
5 *
6 */
7
8/*
9 * Copyright (c) 2000-2001 Eric Gourgoulhon
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29
30char et_rot_lambda_grv2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_lambda_grv2.C,v 1.7 2014/10/13 08:52:58 j_novak Exp $" ;
31
32/*
33 * $Id: et_rot_lambda_grv2.C,v 1.7 2014/10/13 08:52:58 j_novak Exp $
34 * $Log: et_rot_lambda_grv2.C,v $
35 * Revision 1.7 2014/10/13 08:52:58 j_novak
36 * Lorene classes and functions now belong to the namespace Lorene.
37 *
38 * Revision 1.6 2014/10/06 15:13:09 j_novak
39 * Modified #include directives to use c++ syntax.
40 *
41 * Revision 1.5 2013/06/05 15:10:42 j_novak
42 * Suppression of FINJAC sampling in r. This Jacobi(0,2) base is now
43 * available by setting colloc_r to BASE_JAC02 in the Mg3d constructor.
44 *
45 * Revision 1.4 2008/08/27 08:47:17 jl_cornou
46 * Added R_JACO02 case
47 *
48 * Revision 1.3 2003/10/27 10:53:16 e_gourgoulhon
49 * Changed variable name mp --> mprad in order not to shadow member mp.
50 *
51 * Revision 1.2 2002/09/09 13:00:39 e_gourgoulhon
52 * Modification of declaration of Fortran 77 prototypes for
53 * a better portability (in particular on IBM AIX systems):
54 * All Fortran subroutine names are now written F77_* and are
55 * defined in the new file C++/Include/proto_f77.h.
56 *
57 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
58 * LORENE
59 *
60 * Revision 2.1 2001/10/10 13:52:21 eric
61 * Modif Joachim: suppression caractere invisible en fin de fichier.
62 *
63 * Revision 2.0 2000/11/19 18:52:30 eric
64 * *** empty log message ***
65 *
66 *
67 * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_lambda_grv2.C,v 1.7 2014/10/13 08:52:58 j_novak Exp $
68 *
69 */
70
71// Headers C
72#include <cmath>
73
74// Headers Lorene
75#include "etoile.h"
76#include "proto_f77.h"
77
78namespace Lorene {
79double Etoile_rot::lambda_grv2(const Cmp& sou_m, const Cmp& sou_q) {
80
81 const Map_radial* mprad = dynamic_cast<const Map_radial*>( sou_m.get_mp() ) ;
82
83 if (mprad == 0x0) {
84 cout << "Etoile_rot::lambda_grv2: the mapping of sou_m does not"
85 << endl << " belong to the class Map_radial !" << endl ;
86 abort() ;
87 }
88
89 assert( sou_q.get_mp() == mprad ) ;
90
91 sou_q.check_dzpuis(4) ;
92
93 const Mg3d* mg = mprad->get_mg() ;
94 int nz = mg->get_nzone() ;
95
96 // Construction of a Map_af which coincides with *mp on the equator
97 // ----------------------------------------------------------------
98
99 double theta0 = M_PI / 2 ; // Equator
100 double phi0 = 0 ;
101
102 Map_af mpaff(*mprad) ;
103
104 for (int l=0 ; l<nz ; l++) {
105 double rmax = mprad->val_r(l, double(1), theta0, phi0) ;
106 switch ( mg->get_type_r(l) ) {
107 case RARE: {
108 double rmin = mprad->val_r(l, double(0), theta0, phi0) ;
109 mpaff.set_alpha(rmax - rmin, l) ;
110 mpaff.set_beta(rmin, l) ;
111 break ;
112 }
113
114 case FIN: {
115 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
116 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
117 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
118 break ;
119 }
120
121 case UNSURR: {
122 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
123 double umax = double(1) / rmin ;
124 double umin = double(1) / rmax ;
125 mpaff.set_alpha( double(.5) * (umin - umax), l) ;
126 mpaff.set_beta( double(.5) * (umin + umax), l) ;
127 break ;
128 }
129
130 default: {
131 cout << "Etoile_rot::lambda_grv2: unknown type_r ! " << endl ;
132 abort () ;
133 break ;
134 }
135
136 }
137 }
138
139
140 // Reduced Jacobian of
141 // the transformation (r,theta,phi) <-> (dzeta,theta',phi')
142 // ------------------------------------------------------------
143
144 Mtbl jac = 1 / ( (mprad->xsr) * (mprad->dxdr) ) ;
145 // R/x dR/dx in the nucleus
146 // R dR/dx in the shells
147 // - U/(x-1) dU/dx in the ZEC
148 for (int l=0; l<nz; l++) {
149 switch ( mg->get_type_r(l) ) {
150 case RARE: {
151 double a1 = mpaff.get_alpha()[l] ;
152 *(jac.t[l]) = *(jac.t[l]) / (a1*a1) ;
153 break ;
154 }
155
156 case FIN: {
157 double a1 = mpaff.get_alpha()[l] ;
158 double b1 = mpaff.get_beta()[l] ;
159 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
160 double* tjac = jac.t[l]->t ;
161 double* const xi = mg->get_grille3d(l)->x ;
162 for (int k=0; k<mg->get_np(l); k++) {
163 for (int j=0; j<mg->get_nt(l); j++) {
164 for (int i=0; i<mg->get_nr(l); i++) {
165 *tjac = *tjac /
166 (a1 * (a1 * xi[i] + b1) ) ;
167 tjac++ ;
168 }
169 }
170 }
171
172 break ;
173 }
174
175
176 case UNSURR: {
177 double a1 = mpaff.get_alpha()[l] ;
178 *(jac.t[l]) = - *(jac.t[l]) / (a1*a1) ;
179 break ;
180 }
181
182 default: {
183 cout << "Etoile_rot::lambda_grv2: unknown type_r ! " << endl ;
184 abort () ;
185 break ;
186 }
187
188 }
189
190 }
191
192
193 // Multiplication of the sources by the reduced Jacobian:
194 // -----------------------------------------------------
195
196 Mtbl s_m(mg) ;
197 if ( sou_m.get_etat() == ETATZERO ) {
198 s_m = 0 ;
199 }
200 else{
201 assert(sou_m.va.get_etat() == ETATQCQ) ;
202 sou_m.va.coef_i() ;
203 s_m = *(sou_m.va.c) ;
204 }
205
206 Mtbl s_q(mg) ;
207 if ( sou_q.get_etat() == ETATZERO ) {
208 s_q = 0 ;
209 }
210 else{
211 assert(sou_q.va.get_etat() == ETATQCQ) ;
212 sou_q.va.coef_i() ;
213 s_q = *(sou_q.va.c) ;
214 }
215
216 s_m *= jac ;
217 s_q *= jac ;
218
219
220 // Preparations for the call to the Fortran subroutine
221 // ---------------------------------------------------
222
223 int np1 = 1 ; // Axisymmetry enforced
224 int nt = mg->get_nt(0) ;
225 int nt2 = 2*nt - 1 ; // Number of points for the theta sampling
226 // in [0,Pi], instead of [0,Pi/2]
227
228 // Array NDL
229 // ---------
230 int* ndl = new int[nz+4] ;
231 ndl[0] = nz ;
232 for (int l=0; l<nz; l++) {
233 ndl[1+l] = mg->get_nr(l) ;
234 }
235 ndl[1+nz] = nt2 ;
236 ndl[2+nz] = np1 ;
237 ndl[3+nz] = nz ;
238
239 // Parameters NDR, NDT, NDP
240 // ------------------------
241 int nrmax = 0 ;
242 for (int l=0; l<nz ; l++) {
243 nrmax = ( ndl[1+l] > nrmax ) ? ndl[1+l] : nrmax ;
244 }
245 int ndr = nrmax + 5 ;
246 int ndt = nt2 + 2 ;
247 int ndp = np1 + 2 ;
248
249 // Array ERRE
250 // ----------
251
252 double* erre = new double [nz*ndr] ;
253
254 for (int l=0; l<nz; l++) {
255 double a1 = mpaff.get_alpha()[l] ;
256 double b1 = mpaff.get_beta()[l] ;
257 for (int i=0; i<ndl[1+l]; i++) {
258 double xi = mg->get_grille3d(l)->x[i] ;
259 erre[ ndr*l + i ] = a1 * xi + b1 ;
260 }
261 }
262
263 // Arrays containing the data
264 // --------------------------
265
266 int ndrt = ndr*ndt ;
267 int ndrtp = ndr*ndt*ndp ;
268 int taille = ndrtp*nz ;
269
270 double* tsou_m = new double[ taille ] ;
271 double* tsou_q = new double[ taille ] ;
272
273 // Initialisation to zero :
274 for (int i=0; i<taille; i++) {
275 tsou_m[i] = 0 ;
276 tsou_q[i] = 0 ;
277 }
278
279 // Copy of s_m into tsou_m
280 // -----------------------
281
282 for (int l=0; l<nz; l++) {
283 for (int k=0; k<np1; k++) {
284 for (int j=0; j<nt; j++) {
285 for (int i=0; i<mg->get_nr(l); i++) {
286 double xx = s_m(l, k, j, i) ;
287 tsou_m[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
288 // point symetrique par rapport au plan theta = pi/2 :
289 tsou_m[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;
290 }
291 }
292 }
293 }
294
295 // Copy of s_q into tsou_q
296 // -----------------------
297
298 for (int l=0; l<nz; l++) {
299 for (int k=0; k<np1; k++) {
300 for (int j=0; j<nt; j++) {
301 for (int i=0; i<mg->get_nr(l); i++) {
302 double xx = s_q(l, k, j, i) ;
303 tsou_q[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
304 // point symetrique par rapport au plan theta = pi/2 :
305 tsou_q[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;
306 }
307 }
308 }
309 }
310
311
312 // Computation of the integrals
313 // ----------------------------
314
315 double int_m, int_q ;
316 F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_m, &int_m) ;
317 F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_q, &int_q) ;
318
319 // Cleaning
320 // --------
321
322 delete [] ndl ;
323 delete [] erre ;
324 delete [] tsou_m ;
325 delete [] tsou_q ;
326
327 // Computation of lambda
328 // ---------------------
329
330 double lambda ;
331 if ( int_q != double(0) ) {
332 lambda = - int_m / int_q ;
333 }
334 else{
335 lambda = 0 ;
336 }
337
338 return lambda ;
339
340}
341}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
int get_etat() const
Returns the logical state.
Definition cmp.h:899
Valeur va
The numerical value of the Cmp
Definition cmp.h:464
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 cmp.C:715
const Map * get_mp() const
Returns the mapping.
Definition cmp.h:901
static double lambda_grv2(const Cmp &sou_m, const Cmp &sou_q)
Computes the coefficient which ensures that the GRV2 virial identity is satisfied.
double * x
Array of values of at the nr collocation points.
Definition grilles.h:209
Affine radial mapping.
Definition map.h:2027
const double * get_beta() const
Returns the pointer on the array beta.
Definition map_af.C:481
const double * get_alpha() const
Returns the pointer on the array alpha.
Definition map_af.C:477
void set_beta(double beta0, int l)
Modifies the value of in domain no. l.
Definition map_af.C:641
void set_alpha(double alpha0, int l)
Modifies the value of in domain no. l.
Definition map_af.C:630
Base class for pure radial mappings.
Definition map.h:1536
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1549
Coord dxdr
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1560
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.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition map.h:765
Multi-domain grid.
Definition grilles.h:273
const Grille3d * get_grille3d(int l) const
Returns a pointer on the 3D mono-grid for domain no. l.
Definition grilles.h:500
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition grilles.h:462
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:457
int get_nzone() const
Returns the number of domains.
Definition grilles.h:448
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition grilles.h:452
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition grilles.h:474
Multi-domain array.
Definition mtbl.h:118
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
Definition mtbl.h:132
int get_etat() const
Gives the logical state.
Definition tbl.h:394
double * t
The array of double.
Definition tbl.h:173
int get_etat() const
Returns the logical state.
Definition valeur.h:726
Mtbl * c
Values of the function at the points of the multi-grid
Definition valeur.h:299
void coef_i() const
Computes the physical value of *this.
Lorene prototypes.
Definition app_hor.h:64