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