LORENE
map_af_radius.C
1 /*
2  * Methods of the class Map_af relative to the function
3  * r = R_l(xi, theta', phi')
4  */
5 
6 /*
7  * Copyright (c) 1999-2001 Eric Gourgoulhon
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * LORENE is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with LORENE; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  */
26 
27 
28 
29 
30 /*
31  * $Id: map_af_radius.C,v 1.10 2016/12/05 16:17:57 j_novak Exp $
32  * $Log: map_af_radius.C,v $
33  * Revision 1.10 2016/12/05 16:17:57 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.9 2014/10/13 08:53:03 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.8 2014/10/06 15:13:12 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.7 2013/06/05 15:10:42 j_novak
43  * Suppression of FINJAC sampling in r. This Jacobi(0,2) base is now
44  * available by setting colloc_r to BASE_JAC02 in the Mg3d constructor.
45  *
46  * Revision 1.6 2008/09/01 08:12:03 j_novak
47  * Improved test on the [rmin, rmax] interval.
48  *
49  * Revision 1.5 2007/12/11 15:28:14 jl_cornou
50  * Jacobi(0,2) polynomials partially implemented
51  *
52  * Revision 1.4 2006/09/13 13:59:21 j_novak
53  * Higher tolerance thereshold for Map_af::val_lx
54  *
55  * Revision 1.3 2006/07/10 07:44:51 j_novak
56  * Correction of the comparison between rmin and rr (now has to be greater than
57  * some threshold).
58  *
59  * Revision 1.2 2006/07/05 12:36:51 n_vasset
60  * Added a test on rmin to see whether the point lies in the computational domains.
61  *
62  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
63  * LORENE
64  *
65  * Revision 1.5 1999/12/16 14:19:08 eric
66  * Introduction de l'argument const Param& par dans val_lx et val_lx_jk.
67  * (en remplacement de l'argument Tbl& param).
68  *
69  * Revision 1.4 1999/12/07 14:51:37 eric
70  * val_r_kj --> val_r_jk
71  * val_lx_kj -->val_lx_jk
72  * Changement ordre des arguments val_r, val_lx
73  *
74  * Revision 1.3 1999/12/06 16:47:21 eric
75  * Surcharge de val_lx avec la version sans param.
76  *
77  * Revision 1.2 1999/12/06 15:34:06 eric
78  * Ajout des fonctions val_r_kj et val_lx_kj.
79  *
80  * Revision 1.1 1999/12/06 13:12:16 eric
81  * Initial revision
82  *
83  *
84  * $Header: /cvsroot/Lorene/C++/Source/Map/map_af_radius.C,v 1.10 2016/12/05 16:17:57 j_novak Exp $
85  *
86  */
87 
88 #include <cmath>
89 
90 // Headers Lorene
91 #include "map.h"
92 
93  //------------------------------//
94  // val_r //
95  //------------------------------//
96 
97 
98 namespace Lorene {
99 double Map_af::val_r(int l, double xi, double, double) const {
100 
101  assert( l>=0 ) ;
102  assert( l<mg->get_nzone() ) ;
103 
104  double resu ;
105 
106  switch( mg->get_type_r(l) ) {
107 
108  case FIN: case RARE: {
109  resu = alpha[l] * xi + beta[l] ;
110  break ;
111  }
112 
113  case UNSURR: {
114  resu = double(1) / ( alpha[l] * xi + beta[l] ) ;
115  break ;
116  }
117 
118  default: {
119  cout << "Map_af::val_r: unknown type_r ! " << endl ;
120  abort () ;
121  }
122  }
123 
124  return resu ;
125 }
126 
127  //------------------------------//
128  // val_lx //
129  //------------------------------//
130 
131 void Map_af::val_lx(double rr, double, double, int& lz, double& xi) const {
132 
133  // In which domain is located r ?
134  // ----------------------------
135  int nz = mg->get_nzone() ;
136  lz = - 1 ;
137 
138  for (int l=0; l<nz; l++) {
139 
140  double rmax = alpha[l] + beta[l] ;
141  double rmin = beta[l] - alpha[l] ;
142  if (mg->get_type_r(l) == RARE) rmin = 0. ;
143  if (mg->get_type_r(l) == UNSURR) {
144  rmin = double(1)/rmin ;
145  rmax = double(1)/rmax ;
146  }
147  if ((rr - rmin >= -1.e-14*fabs(rmin)) && ( rr <= rmax )) {
148  lz = l ;
149  break ;
150  }
151  } // fin de la boucle sur les zones
152 
153  if (lz == -1) { // On n'a pas trouve la zone
154  cout.precision(16);
155  cout.setf(ios::showpoint);
156  cout << "Map_af::val_lx: the domain containing r = " << rr <<
157  " has not been found ! "
158  << endl ;
159  for (int l=0; l<nz; l++) {
160  double rmin = -alpha[l] + beta[l] ;
161  if (mg->get_type_r(l) == UNSURR) rmin = double(1)/rmin ;
162  if (mg->get_type_r(l) == RARE) rmin = 0. ;
163  cout << "domain " << l << " : r_min = " << rmin ;
164  double rmax = alpha[l] + beta[l] ;
165  if (mg->get_type_r(l) == UNSURR) rmax = double(1)/rmax ;
166  cout << " : r_max = " << rmax << endl ;
167  }
168  abort () ;
169  }
170 
171  // Computation of xi
172  // -----------------
173 
174  switch( mg->get_type_r(lz) ) {
175 
176  case FIN: case RARE: {
177  xi = ( rr - beta[lz] ) / alpha[lz] ;
178  break ;
179  }
180 
181  case UNSURR: {
182  xi = ( double(1)/rr - beta[lz] ) / alpha[lz] ;
183  break ;
184  }
185 
186  default: {
187  cout << "Map_af::val_lx: unknown type_r ! " << endl ;
188  abort () ;
189  }
190  }
191 
192 }
193 
194 
195 void Map_af::val_lx(double rr, double, double, const Param&,
196  int& lz, double& xi) const {
197 
198  val_lx(rr, 0., 0., lz, xi) ;
199 
200 }
201 
202 
203  //------------------------------//
204  // val_r_jk //
205  //------------------------------//
206 
207 
208 double Map_af::val_r_jk(int l, double xi, int, int) const {
209 
210  return val_r(l, xi, 0., 0.) ;
211 
212 }
213 
214  //------------------------------//
215  // val_lx_jk //
216  //------------------------------//
217 
218 void Map_af::val_lx_jk(double rr, int, int, const Param& par,
219  int& l, double& xi) const {
220 
221  val_lx(rr, 0., 0., par, l, xi) ;
222 
223 }
224 
225 
226 }
double * alpha
Array (size: mg->nzone ) of the values of in each domain.
Definition: map.h:2048
Lorene prototypes.
Definition: app_hor.h:67
virtual double val_r(int l, double xi, double theta, double pphi) const
Returns the value of the radial coordinate r for a given in a given domain.
Definition: map_af_radius.C:99
virtual double val_r_jk(int l, double xi, int j, int k) const
Returns the value of the radial coordinate r for a given and a given collocation point in in a give...
Parameter storage.
Definition: param.h:125
double * beta
Array (size: mg->nzone ) of the values of in each domain.
Definition: map.h:2050
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
virtual void val_lx(double rr, double theta, double pphi, int &l, double &xi) const
Computes the domain index l and the value of corresponding to a point given by its physical coordina...
virtual void val_lx_jk(double rr, int j, int k, const Param &par, int &l, double &xi) const
Computes the domain index l and the value of corresponding to a point of arbitrary r but collocation...
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition: map.h:688
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491