LORENE
scalar_asymptot.C
1 /*
2  * Function Scalar::asymptot
3  *
4  */
5 
6 /*
7  * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
8  *
9  * Copyright (c) 1999-2002 Eric Gourgoulhon (for previous class Cmp)
10  * Copyright (c) 1999-2001 Philippe Grandclement (for previous class Cmp)
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: scalar_asymptot.C,v 1.6 2016/12/05 16:18:18 j_novak Exp $
35  * $Log: scalar_asymptot.C,v $
36  * Revision 1.6 2016/12/05 16:18:18 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.5 2014/10/13 08:53:46 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.4 2014/10/06 15:16:15 j_novak
43  * Modified #include directives to use c++ syntax.
44  *
45  * Revision 1.3 2004/02/21 17:05:14 e_gourgoulhon
46  * Method Scalar::point renamed Scalar::val_grid_point.
47  * Method Scalar::set_point renamed Scalar::set_grid_point.
48  *
49  * Revision 1.2 2003/10/08 14:24:09 j_novak
50  * replaced mult_r_zec with mult_r_ced
51  *
52  * Revision 1.1 2003/09/25 07:18:00 j_novak
53  * Method asymptot implemented.
54  *
55  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_asymptot.C,v 1.6 2016/12/05 16:18:18 j_novak Exp $
56  *
57  */
58 
59 // Headers C
60 #include <cmath>
61 
62 // Headers Lorene
63 #include "tensor.h"
64 
65 namespace Lorene {
66 Valeur** Scalar::asymptot(int n0, const int flag) const {
67 
68  assert(n0 >= 0) ;
69  const Mg3d& mg = *(mp->get_mg()) ;
70  int nz = mg.get_nzone() ;
71  int nzm1 = nz-1 ;
72  assert(mg.get_type_r(nzm1) == UNSURR) ;
73  int np = mg.get_np(nzm1) ;
74  int nt = mg.get_nt(nzm1) ;
75  int nr = mg.get_nr(nzm1) ;
76  int nrm1 = nr-1 ;
77 
78  Valeur** vu = new Valeur*[n0+1] ;
79  for (int h=0; h<=n0; h++) {
80  vu[h] = new Valeur(mg.get_angu()) ;
81  }
82 
83  Scalar uu = *this ;
84 
85  int precis = 2 ;
86 
87  // The terms 1/r^h with h < dzpuis are null :
88  // -----------------------------------------
89  for (int h=0; h<dzpuis; h++) {
90 
91  vu[h]->set_etat_zero() ;
92 
93  }
94 
95  // Terms 1/r^h with h >= dzpuis :
96  // -----------------------------
97  for (int h=dzpuis; h<=n0; h++) {
98 
99  // Value on the sphere S^2 at infinity
100  // -----------------------------------
101  vu[h]->set_etat_c_qcq() ;
102  vu[h]->c->set_etat_qcq() ;
103  for (int l=0; l<nzm1; l++) {
104  vu[h]->c->t[l]->set_etat_zero() ;
105  }
106  vu[h]->c->t[nzm1]->set_etat_qcq() ;
107 
108  for (int k=0; k<np; k++) {
109  for (int j=0; j<nt; j++) {
110  vu[h]->set(nzm1, k, j, 0) = uu.val_grid_point(nzm1, k, j, nrm1) ;
111  }
112  }
113 
114  vu[h]->set_base( uu.va.base ) ;
115 
116  // Printing
117  // --------
118  if (flag != 0) {
119  cout << "Term in 1/r^" << h << endl ;
120  cout << "-------------" << endl ;
121 
122  double ndec = 0 ;
123  double vmin = (*vu[h])(nzm1, 0, 0, 0) ;
124  double vmax = vmin ;
125 
126  cout << " Values at the point (phi_k, theta_j) : " << endl ;
127  cout.precision(precis) ;
128  cout.setf(ios::showpoint) ;
129  for (int k=0; k<np; k++) {
130  cout << " k=" << k << " : " ;
131  for (int j=0; j<nt; j++) {
132  double xx = (*vu[h])(nzm1, k, j, 0) ;
133  cout << " " << setw(precis) << xx ;
134  ndec += fabs(xx) ;
135  vmin = ( xx < vmin ) ? xx : vmin ;
136  vmax = ( xx > vmax ) ? xx : vmax ;
137  }
138  cout << endl;
139  }
140  ndec /= np*nt ;
141  cout << "Minimum value on S^2 : " << vmin << endl ;
142  cout << "Maximum value on S^2 : " << vmax << endl ;
143  cout << "L^1 norm on S^2 : " << ndec << endl ;
144  }
145  // The value at infinity is substracted
146  // ------------------------------------
147  for (int k=0; k<np; k++) {
148  for (int j=0; j<nt; j++) {
149  double v_inf = (*vu[h])(nzm1, k, j, 0) ;
150  for (int i=0; i<nr; i++) {
151  uu.set_grid_point(nzm1, k, j, i) -= v_inf ;
152  }
153  }
154  }
155 
156  // Mutliplication by r
157  // -------------------
158 
159  uu.mult_r_ced() ;
160 
161  } // End of loop on h (development order)
162 
163  return vu ;
164 
165 }
166 }
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: valeur.C:692
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
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
int dzpuis
Power of r by which the quantity represented by this must be divided in the compactified external do...
Definition: scalar.h:409
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base )
Definition: valeur.C:813
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Definition: scalar.h:643
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
const Mg3d * get_angu() const
Returns the pointer on the associated angular grid.
Definition: mg3d.C:604
Base_val base
Bases on which the spectral expansion is performed.
Definition: valeur.h:315
void mult_r_ced()
Multiplication by r in the compactified external domain (CED), the dzpuis flag is not changed...
Mtbl * c
Values of the function at the points of the multi-grid.
Definition: valeur.h:309
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
Valeur va
The numerical value of the Scalar.
Definition: scalar.h:411
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: mtbl.C:302
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: tbl.C:350
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
double & set_grid_point(int l, int k, int j, int i)
Setting the value of the field at a given grid point.
Definition: scalar.h:690
Valeur ** asymptot(int n, const int flag=0) const
Asymptotic expansion at r = infinity.
void set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c )...
Definition: valeur.C:704
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
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:301
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s.
Definition: mtbl.h:132
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).
Definition: valeur.h:373