LORENE
map_eps_radius.C
1 /*
2  * Methods of the class Map_eps relative to the function
3  * r = R_l(xi, theta', phi')
4  */
5 
6 /*
7  * This file is part of LORENE.
8  *
9  * LORENE is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * LORENE is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with LORENE; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  *
23  */
24 
25 
26 
27 
28 
29 
30 
31 
32 #include <cmath>
33 
34 // Headers Lorene
35 #include "map.h"
36 
37  //------------------------------//
38  // val_r //
39  //------------------------------//
40 
41 
42 namespace Lorene {
43 double Map_eps::val_r(int l, double xi, double theta, double pphi) const {
44 
45  assert( l>=0 ) ;
46  assert( l<mg->get_nzone() ) ;
47 
48  double resu ;
49 
50  switch( mg->get_type_r(l) ) {
51 
52  case RARE: {
53  resu = alpha.val_point(l, xi, theta, pphi) * xi ;
54  break ;
55  }
56 
57  case FIN: {
58  resu = alpha.val_point(l, xi, theta, pphi)*xi + beta.val_point(l, xi, theta, pphi) ;
59  break ;
60  }
61 
62 
63  case UNSURR: {
64  cout << "Map_eps::val_r : Compactified domain not allowed !" << endl;
65  abort() ;
66  break ;
67  }
68 
69  default: {
70  cout << "Map_eps::val_r: unknown type_r ! " << endl ;
71  abort () ;
72  }
73  }
74 
75  return resu ;
76 }
77 
78  //------------------------------//
79  // val_lx //
80  //------------------------------//
81 
82 void Map_eps::val_lx(double rr, double theta, double pphi, int& lz, double& xi) const {
83 
84  // In which domain is located r ?
85  // ----------------------------
86  int nz = mg->get_nzone() ;
87  lz = - 1 ;
88 
89  for (int l=0; l<nz; l++) {
90  double rmin = 0. ;
91  double rmax = 0. ;
92 
93  if (mg->get_type_r(l) == RARE){
94  rmin = 0. ;
95  rmax = alpha.val_point(l,1.,theta,pphi) ;
96  }
97  if (mg->get_type_r(l) == FIN) {
98  rmin = beta.val_point(l,1.,theta,pphi) - alpha.val_point(l,1,theta,pphi) ;
99  rmax = beta.val_point(l,1.,theta,pphi) + alpha.val_point(l,1,theta,pphi) ;
100  }
101  // if (mg->get_type_r(l) == UNSURR) {
102  // rmin = double(1)/rmin ;
103  // rmax = double(1)/rmax ;
104  // }
105  if ((rr - rmin >= -1.e-14*fabs(rmin)) && ( rr <= rmax )) {
106  lz = l ;
107  break ;
108  }
109  } // fin de la boucle sur les zones
110 
111  if (lz == -1) { // On n'a pas trouve la zone
112  cout.precision(16);
113  cout.setf(ios::showpoint);
114  cout << "Map_eps::val_lx: the domain containing r = " << rr <<
115  " has not been found ! "
116  << endl ;
117  // for (int l=0; l<nz; l++) {
118  // double rmin = -alpha[l] + beta[l] ;
119  // if (mg->get_type_r(l) == UNSURR) rmin = double(1)/rmin ;
120  // if (mg->get_type_r(l) == RARE) rmin = 0. ;
121  // cout << "domain " << l << " : r_min = " << rmin ;
122  // double rmax = alpha[l] + beta[l] ;
123  // if (mg->get_type_r(l) == UNSURR) rmax = double(1)/rmax ;
124  // cout << " : r_max = " << rmax << endl ;
125  // }
126  abort () ;
127  }
128 
129  // Computation of xi
130  // -----------------
131 
132  switch( mg->get_type_r(lz) ) {
133 
134  case RARE: {
135  xi = rr / alpha.val_point(lz,1.,theta,pphi) ;
136  break ;
137  }
138 
139  case FIN: {
140  xi = (rr-beta.val_point(lz,1.,theta,pphi))/alpha.val_point(lz,1.,theta,pphi) ;
141  break ;
142  }
143 
144 
145  case UNSURR: {
146  cout << "Map_eps::val_lx : Compactified domain not allowed !" << endl;
147  abort() ;
148  break ;
149  }
150 
151  default: {
152  cout << "Map_eps::val_lx: unknown type_r ! " << endl ;
153  abort () ;
154  }
155  }
156 
157 }
158 
159 
160 void Map_eps::val_lx(double rr, double theta, double pphi, const Param&,
161  int& lz, double& xi) const {
162 
163  val_lx(rr, theta, pphi, lz, xi) ;
164 
165 }
166 
167 
168  //------------------------------//
169  // val_r_jk //
170  //------------------------------//
171 
172 
173 double Map_eps::val_r_jk(int l, double xi, int j, int k) const {
174 
175  return val_r(l, xi, (+tet)(l,k,j,0), (+phi)(l,k,j,0)) ;
176 
177 }
178 
179  //------------------------------//
180  // val_lx_jk //
181  //------------------------------//
182 
183 void Map_eps::val_lx_jk(double rr, int j, int k, const Param&,
184  int& l, double& xi) const {
185 
186  val_lx(rr, (+tet)(l,k,j,0), (+phi)(l,k,j,0), l, xi) ;
187 
188 }
189 
190 
191 }
Lorene prototypes.
Definition: app_hor.h:67
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...
Coord tet
coordinate centered on the grid
Definition: map.h:737
Coord phi
coordinate centered on the grid
Definition: map.h:738
double val_point(int l, double x, double theta, double phi) const
Computes the value of the field represented by *this at an arbitrary point, by means of the spectral ...
Definition: valeur.C:885
Parameter storage.
Definition: param.h:125
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition: map.h:694
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...
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.
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491
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...