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,rmax ;
91 
92  if (mg->get_type_r(l) == RARE){
93  rmin = 0. ;
94  rmax = alpha.val_point(l,1.,theta,pphi) ;
95  }
96  if (mg->get_type_r(l) == FIN) {
97  rmin = beta.val_point(l,1.,theta,pphi) - alpha.val_point(l,1,theta,pphi) ;
98  rmax = beta.val_point(l,1.,theta,pphi) + alpha.val_point(l,1,theta,pphi) ;
99  }
100  // if (mg->get_type_r(l) == UNSURR) {
101  // rmin = double(1)/rmin ;
102  // rmax = double(1)/rmax ;
103  // }
104  if ((rr - rmin >= -1.e-14*fabs(rmin)) && ( rr <= rmax )) {
105  lz = l ;
106  break ;
107  }
108  } // fin de la boucle sur les zones
109 
110  if (lz == -1) { // On n'a pas trouve la zone
111  cout.precision(16);
112  cout.setf(ios::showpoint);
113  cout << "Map_eps::val_lx: the domain containing r = " << rr <<
114  " has not been found ! "
115  << endl ;
116  // for (int l=0; l<nz; l++) {
117  // double rmin = -alpha[l] + beta[l] ;
118  // if (mg->get_type_r(l) == UNSURR) rmin = double(1)/rmin ;
119  // if (mg->get_type_r(l) == RARE) rmin = 0. ;
120  // cout << "domain " << l << " : r_min = " << rmin ;
121  // double rmax = alpha[l] + beta[l] ;
122  // if (mg->get_type_r(l) == UNSURR) rmax = double(1)/rmax ;
123  // cout << " : r_max = " << rmax << endl ;
124  // }
125  abort () ;
126  }
127 
128  // Computation of xi
129  // -----------------
130 
131  switch( mg->get_type_r(lz) ) {
132 
133  case RARE: {
134  xi = rr / alpha.val_point(lz,1.,theta,pphi) ;
135  break ;
136  }
137 
138  case FIN: {
139  xi = (rr-beta.val_point(lz,1.,theta,pphi))/alpha.val_point(lz,1.,theta,pphi) ;
140  break ;
141  }
142 
143 
144  case UNSURR: {
145  cout << "Map_eps::val_lx : Compactified domain not allowed !" << endl;
146  abort() ;
147  break ;
148  }
149 
150  default: {
151  cout << "Map_eps::val_lx: unknown type_r ! " << endl ;
152  abort () ;
153  }
154  }
155 
156 }
157 
158 
159 void Map_eps::val_lx(double rr, double theta, double pphi, const Param&,
160  int& lz, double& xi) const {
161 
162  val_lx(rr, theta, pphi, lz, xi) ;
163 
164 }
165 
166 
167  //------------------------------//
168  // val_r_jk //
169  //------------------------------//
170 
171 
172 double Map_eps::val_r_jk(int l, double xi, int j, int k) const {
173 
174  return val_r(l, xi, (+tet)(l,k,j,0), (+phi)(l,k,j,0)) ;
175 
176 }
177 
178  //------------------------------//
179  // val_lx_jk //
180  //------------------------------//
181 
182 void Map_eps::val_lx_jk(double rr, int j, int k, const Param& par,
183  int& l, double& xi) const {
184 
185  val_lx(rr, (+tet)(l,k,j,0), (+phi)(l,k,j,0), l, xi) ;
186 
187 }
188 
189 
190 }
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:731
Coord phi
coordinate centered on the grid
Definition: map.h:732
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:688
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...