LORENE
map_star_radius.C
1  /*
2  * Methods of the class Map_star relative to the function
3  * r = R_l(xi, theta', phi')
4  */
5 
6 /*
7  * Copyright (c) 2023 Gael Servignat
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 // Headers Lorene
28 #include "map.h"
29 
30  //------------------------------//
31  // val_r //
32  //------------------------------//
33 
34 
35 namespace Lorene {
36 double Map_star::val_r(int l, double xi, double theta, double pphi) const {
37 
38  assert( l>=0 ) ;
39  assert( l<mg->get_nzone() ) ;
40 
41  double resu ;
42 
43  switch( mg->get_type_r(l) ) {
44 
45  case RARE: {
46  resu = alpha.val_point(l, xi, theta, pphi) * xi ;
47  break ;
48  }
49 
50  case FIN: {
51  resu = alpha.val_point(l, xi, theta, pphi)*xi + beta.val_point(l, xi, theta, pphi) ;
52  break ;
53  }
54 
55 
56  case UNSURR: {
57  cout << "Map_star::val_r : Compactified domain not allowed !" << endl;
58  abort() ;
59  break ;
60  }
61 
62  default: {
63  cout << "Map_star::val_r: unknown type_r ! " << endl ;
64  abort () ;
65  }
66  }
67 
68  return resu ;
69 }
70 
71  //------------------------------//
72  // val_lx //
73  //------------------------------//
74 
75 void Map_star::val_lx(double rr, double theta, double pphi, int& lz, double& xi) const {
76 
77  // In which domain is located r ?
78  // ----------------------------
79  int nz = mg->get_nzone() ;
80  lz = - 1 ;
81 
82  for (int l=0; l<nz; l++) {
83  double rmin = 0. ;
84  double rmax = 0. ;
85 
86  if (mg->get_type_r(l) == RARE){
87  rmin = 0. ;
88  rmax = alpha.val_point(l,1.,theta,pphi) ;
89  }
90  if (mg->get_type_r(l) == FIN) {
91  rmin = beta.val_point(l,1.,theta,pphi) - alpha.val_point(l,1,theta,pphi) ;
92  rmax = beta.val_point(l,1.,theta,pphi) + alpha.val_point(l,1,theta,pphi) ;
93  }
94  if ((rr - rmin >= -1.e-14*fabs(rmin)) && ( rr <= rmax )) {
95  lz = l ;
96  break ;
97  }
98  } // fin de la boucle sur les zones
99 
100  if (lz == -1) { // On n'a pas trouve la zone
101  cout.precision(16);
102  cout.setf(ios::showpoint);
103  cout << "Map_star::val_lx: the domain containing r = " << rr <<
104  " has not been found ! "
105  << endl ;
106  abort () ;
107  }
108 
109  // Computation of xi
110  // -----------------
111 
112  switch( mg->get_type_r(lz) ) {
113 
114  case RARE: {
115  xi = rr / alpha.val_point(lz,1.,theta,pphi) ;
116  break ;
117  }
118 
119  case FIN: {
120  xi = (rr-beta.val_point(lz,1.,theta,pphi))/alpha.val_point(lz,1.,theta,pphi) ;
121  break ;
122  }
123 
124 
125  case UNSURR: {
126  cout << "Map_star::val_lx : Compactified domain not allowed !" << endl;
127  abort() ;
128  break ;
129  }
130 
131  default: {
132  cout << "Map_star::val_lx: unknown type_r ! " << endl ;
133  abort () ;
134  }
135  }
136 
137 }
138 
139 
140 void Map_star::val_lx(double rr, double theta, double pphi, const Param&,
141  int& lz, double& xi) const {
142 
143  val_lx(rr, theta, pphi, lz, xi) ;
144 
145 }
146 
147 
148  //------------------------------//
149  // val_r_jk //
150  //------------------------------//
151 
152 
153 double Map_star::val_r_jk(int l, double xi, int j, int k) const {
154 
155  assert( l>=0 ) ;
156  assert( l<mg->get_nzone() ) ;
157 
158  if (tet.c == 0x0)
159  tet.fait() ;
160  if (phi.c == 0x0)
161  phi.fait() ;
162 
163  double resu ;
164 
165  switch( mg->get_type_r(l) ) {
166 
167  case RARE: {
168  resu = alpha(l, k, j, 0) * xi ;
169  break ;
170  }
171 
172  case FIN: {
173  resu = alpha(l, k, j, 0)*xi + beta(l, k, j, 0) ;
174  break ;
175  }
176 
177  case UNSURR: {
178  cout << "Map_star::val_r : Compactified domain not allowed !" << endl;
179  abort() ;
180  break ;
181  }
182 
183  default: {
184  cout << "Map_star::val_r: unknown type_r ! " << endl ;
185  abort () ;
186  }
187  }
188 
189  return resu ;
190 }
191 
192  //------------------------------//
193  // val_lx_jk //
194  //------------------------------//
195 
196 void Map_star::val_lx_jk(double rr, int j, int k, const Param&,
197  int& lz, double& xi) const {
198 
199  if (tet.c == 0x0)
200  tet.fait() ;
201  if (phi.c == 0x0)
202  phi.fait() ;
203 
204  // In which domain is located r ?
205  // ----------------------------
206  int nz = mg->get_nzone() ;
207  lz = - 1 ;
208 
209  for (int l=0; l<nz; l++) {
210  double rmin = 0. ;
211  double rmax = 0. ;
212 
213  if (mg->get_type_r(l) == RARE){
214  rmin = 0. ;
215  rmax = alpha(l,k, j, 0) ;
216  }
217  if (mg->get_type_r(l) == FIN) {
218  rmin = beta(l, k, j, 0) - alpha(l, k, j, 0) ;
219  rmax = beta(l, k, j, 0) + alpha(l, k, j, 0) ;
220  }
221  if ((rr - rmin >= -1.e-14*fabs(rmin)) && ( rr <= rmax )) {
222  lz = l ;
223  break ;
224  }
225  } // fin de la boucle sur les zones
226 
227  if (lz == -1) { // On n'a pas trouve la zone
228  cout.precision(16);
229  cout.setf(ios::showpoint);
230  cout << "Map_star::val_lx: the domain containing r = " << rr <<
231  " has not been found ! "
232  << endl ;
233  for (int l=0; l<nz; l++) {
234  double rmin = beta(l, k, j, 0) - alpha(l, k, j, 0) ;
235  if (mg->get_type_r(l) == RARE) rmin = 0. ;
236  cout << "domain " << l << " : r_min = " << rmin ;
237  double rmax = beta(l, k, j, 0) + alpha(l, k, j, 0) ;; //alpha[l] + beta[l] ;
238  cout << " : r_max = " << rmax << endl ;
239  }
240  abort () ;
241  }
242 
243  // Computation of xi
244  // -----------------
245 
246  switch( mg->get_type_r(lz) ) {
247 
248  case RARE: {
249  xi = rr / alpha(lz, k, j, 0) ;
250  break ;
251  }
252 
253  case FIN: {
254  xi = (rr - beta(lz, k, j, 0)) / alpha(lz, k, j, 0) ;
255  break ;
256  }
257 
258  case UNSURR: {
259  cout << "Map_star::val_lx : Compactified domain not allowed !" << endl;
260  abort() ;
261  break ;
262  }
263  default: {
264  cout << "Map_star::val_lx: unknown type_r ! " << endl ;
265  abort () ;
266  }
267  }
268 
269 }
270 
271 
272 }
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...
Lorene prototypes.
Definition: app_hor.h:67
Mtbl * c
The coordinate values at each grid point.
Definition: coord.h:97
Coord tet
coordinate centered on the grid
Definition: map.h:743
Coord phi
coordinate centered on the grid
Definition: map.h:744
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...
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
void fait() const
Computes, at each point of the grid, the value of the coordinate or mapping derivative represented by...
Definition: coord.C:119
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition: map.h:700
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.
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...
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491
Valeur alpha
Array (size: mg->nzone*Nt*Np ) of the values of in each domain.
Definition: map_star.h:30