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