LORENE
map_log_radius.C
1 /*
2  * Methods of the class Map_log relative to the function
3  * r = R_l(xi, theta', phi')
4  */
5 
6 /*
7  * Copyright (c) 2004 Philippe Grandclement
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_log_radius.C,v 1.5 2016/12/05 16:17:58 j_novak Exp $
32  * $Log: map_log_radius.C,v $
33  * Revision 1.5 2016/12/05 16:17:58 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.4 2014/10/13 08:53:06 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.3 2014/10/06 15:13:13 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.2 2004/06/22 12:20:17 j_novak
43  * *** empty log message ***
44  *
45  * Revision 1.1 2004/06/22 08:49:58 p_grandclement
46  * Addition of everything needed for using the logarithmic mapping
47  *
48  *
49  * $Header: /cvsroot/Lorene/C++/Source/Map/map_log_radius.C,v 1.5 2016/12/05 16:17:58 j_novak Exp $
50  *
51  */
52 
53 #include <cmath>
54 
55 // Headers Lorene
56 #include "map.h"
57 
58  //------------------------------//
59  // val_r //
60  //------------------------------//
61 
62 
63 namespace Lorene {
64 double Map_log::val_r(int l, double xi, double, double) const {
65 
66  assert( l>=0 ) ;
67  assert( l<mg->get_nzone() ) ;
68 
69  double resu ;
70 
71  switch (type_var(l)) {
72  case AFFINE : {
73 
74  switch( mg->get_type_r(l) ) {
75  case FIN: case RARE: {
76  resu = alpha(l) * xi + beta(l) ;
77  break ;
78  }
79 
80  case UNSURR: {
81  resu = double(1) / ( alpha(l) * xi + beta(l) ) ;
82  break ;
83  }
84 
85  default: {
86  cout << "Map_log::val_r: unknown type_r ! " << endl ;
87  abort () ;
88  }
89  }
90  break ;
91  }
92 
93  case LOG : {
94  switch( mg->get_type_r(l) ) {
95  case FIN: {
96  resu = exp(alpha(l) * xi + beta(l)) ;
97  break ;
98  }
99 
100  default: {
101  cout << "Map_log::val_r: unknown type_r ! " << endl ;
102  abort () ;
103  }
104  }
105  break ;
106  }
107 
108  default: {
109  cout << "Map_log::val_r: unknown type_r ! " << endl ;
110  abort () ;
111  }
112  }
113 
114  return resu ;
115 }
116 
117  //------------------------------//
118  // val_lx //
119  //------------------------------//
120 
121 void Map_log::val_lx(double rr, double, double, int& lz, double& xi) const {
122 
123  // In which domain is located r ?
124  // ----------------------------
125  int nz = mg->get_nzone() ;
126  lz = - 1 ;
127 
128  for (int l=0; l<nz; l++) {
129 
130  double rmax = 0;
131  switch (type_var(l)) {
132  case AFFINE : {
133  rmax = alpha(l) + beta(l) ;
134  break ;
135  }
136  case LOG : {
137  rmax = exp(alpha(l) + beta(l)) ;
138  break ;
139  }
140  default : {
141  cout << "Case unknown in Map_log::val_lx" << endl ;
142  break ;
143  }
144  }
145 
146  if (mg->get_type_r(l) == UNSURR) rmax = double(1)/rmax ;
147 
148  if ( rr <= rmax ) {
149  lz = l ;
150  break ;
151  }
152  } // fin de la boucle sur les zones
153 
154  if (lz == -1) { // On n'a pas trouve la zone
155  cout.precision(16);
156  cout.setf(ios::showpoint);
157  cout << "Map_log::val_lx: the domain containing r = " << rr <<
158  " has not been found ! "
159  << endl ;
160  abort () ;
161  }
162 
163  // Computation of xi
164  // -----------------
165 
166  switch (type_var(lz)) {
167  case AFFINE: {
168  switch( mg->get_type_r(lz) ) {
169  case FIN: case RARE: {
170  xi = ( rr - beta(lz) ) / alpha(lz) ;
171  break ;
172  }
173 
174  case UNSURR: {
175  xi = ( double(1)/rr - beta(lz) ) / alpha(lz) ;
176  break ;
177  }
178 
179  default: {
180  cout << "Map_log::val_lx: unknown type_r ! " << endl ;
181  abort () ;
182  }
183  }
184  break ;
185  }
186  case LOG :{
187  switch( mg->get_type_r(lz) ) {
188  case FIN: {
189  xi = ( log(rr) - beta(lz) ) / alpha(lz) ;
190  break ;
191  }
192  default: {
193  cout << "Map_log::val_lx: unknown type_r ! " << endl ;
194  abort () ;
195  }
196  }
197  break ;
198  }
199  default : {
200  cout << "Map_log::val_lx: unknown type_r ! " << endl ;
201  abort () ;
202  }
203  }
204 }
205 
206 
207 void Map_log::val_lx(double rr, double, double, const Param&,
208  int& lz, double& xi) const {
209 
210  val_lx(rr, 0., 0., lz, xi) ;
211 
212 }
213 
214 
215  //------------------------------//
216  // val_r_jk //
217  //------------------------------//
218 
219 
220 double Map_log::val_r_jk(int l, double xi, int, int) const {
221 
222  return val_r(l, xi, 0., 0.) ;
223 
224 }
225 
226  //------------------------------//
227  // val_lx_jk //
228  //------------------------------//
229 
230 void Map_log::val_lx_jk(double rr, int, int, const Param& par,
231  int& l, double& xi) const {
232 
233  val_lx(rr, 0., 0., par, l, xi) ;
234 
235 }
236 
237 
238 }
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.
Tbl beta
Array (size: mg->nzone ) of the values of in each domain.
Definition: map.h:3611
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
Lorene prototypes.
Definition: app_hor.h:67
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...
Itbl type_var
Array (size: mg->nzone ) of the type of variable in each domain.
Definition: map.h:3615
Tbl alpha
Array (size: mg->nzone ) of the values of in each domain.
Definition: map.h:3609
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...
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491
virtual double val_r_jk(int l, double xi, int j, int k) const
< Comparison operator