LORENE
change_var.C
1/*
2 * Copyright (c) 2003 Philippe Grandclement
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * LORENE is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with LORENE; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21
22
23/*
24 * $Id: change_var.C,v 1.8 2016/12/05 16:17:48 j_novak Exp $
25 * $Log: change_var.C,v $
26 * Revision 1.8 2016/12/05 16:17:48 j_novak
27 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
28 *
29 * Revision 1.7 2014/10/13 08:52:46 j_novak
30 * Lorene classes and functions now belong to the namespace Lorene.
31 *
32 * Revision 1.6 2014/10/06 15:13:03 j_novak
33 * Modified #include directives to use c++ syntax.
34 *
35 * Revision 1.5 2004/05/14 08:51:01 p_grandclement
36 * *** empty log message ***
37 *
38 * Revision 1.4 2004/03/05 09:18:48 p_grandclement
39 * Addition of operator sec_order_r2
40 *
41 * Revision 1.3 2003/12/11 16:10:38 e_gourgoulhon
42 * Changed #include <iostream.h> to #include "headcpp.h".
43 *
44 * Revision 1.2 2003/12/11 15:53:31 p_grandclement
45 * includ stdlib
46 *
47 * Revision 1.1 2003/12/11 14:48:48 p_grandclement
48 * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
49 *
50 *
51 * $Header: /cvsroot/Lorene/C++/Source/Change_var/change_var.C,v 1.8 2016/12/05 16:17:48 j_novak Exp $
52 *
53 */
54
55#include "headcpp.h"
56
57#include <cmath>
58#include <cstdlib>
59
60#include "proto.h"
61#include "change_var.h"
62
63// Les fonctions elementaires dont on a besoin
64namespace Lorene {
65double one (double) {
66 return 1 ;
67}
68
69double zero (double) {
70 return 0 ;
71}
72
73double ide (double x) {
74 return x ;
75}
76
77double part_ln (double x) {
78 return 1+x*x*log(x)/3. ;
79}
80
81double part_ln_der (double x) {
82 return 2./3.*x*log(x)+x/3. ;
83}
84
85double moins_log (double x) {
86 return -log(x) ;
87}
88
89double plus_sur (double x) {
90 return 1./x ;
91}
92
93double plus_log (double x) {
94 return log(x) ;
95}
96
97double moins_sur (double x) {
98 return -1./x ;
99}
100
101// Construction du changement de variable ...
102Change_var::Change_var (int type_change) {
103
104 switch (type_change) {
105 case STD:
106 func_F = zero ;
107 der_F = zero ;
108 func_G = one ;
109 der_G = zero ;
110 break ;
111
112 case W_BETA:
113 func_F = one ;
114 der_F = zero ;
115 func_G = ide ;
116 der_G = one ;
117 break ;
118
119 case W_BETA_INF:
120 func_F = part_ln ;
121 der_F = part_ln_der ;
122 func_G = ide ;
123 der_G = one ;
124 break ;
125
126 case H_BETA:
127 func_F = one ;
128 der_F = zero ;
129 func_G = one ;
130 der_G = zero ;
131 break ;
132
133 case LAMBDA_RN:
134 func_F = moins_log ;
135 der_F = moins_sur ;
136 func_G = one ;
137 der_G = zero ;
138 break ;
139
140 case NU_RN:
141 func_F = plus_log ;
142 der_F = plus_sur ;
143 func_G = one ;
144 der_G = zero ;
145 break ;
146
147 default:
148 cout << "Unknown type in Change_var::Change_var(int)" << endl ;
149 abort() ;
150 break ;
151 }
152
153 mult_F = 1 ;
154 add_F = 0 ;
155
156}
157
158
159// Construction du changement de variable ...
160Change_var::Change_var (int type_change, double mult) {
161
162 switch (type_change) {
163 case STD:
164 func_F = zero ;
165 der_F = zero ;
166 func_G = one ;
167 der_G = zero ;
168 break ;
169
170 case W_BETA:
171 func_F = one ;
172 der_F = zero ;
173 func_G = ide ;
174 der_G = one ;
175 break ;
176
177 case W_BETA_INF:
178 func_F = part_ln ;
179 der_F = part_ln_der ;
180 func_G = ide ;
181 der_G = one ;
182 break ;
183
184 case H_BETA:
185 func_F = one ;
186 der_F = zero ;
187 func_G = one ;
188 der_G = zero ;
189 break ;
190
191 case LAMBDA_RN:
192 func_F = moins_log ;
193 der_F = moins_sur ;
194 func_G = one ;
195 der_G = zero ;
196 break ;
197
198 case NU_RN:
199 func_F = plus_log ;
200 der_F = plus_sur ;
201 func_G = one ;
202 der_G = zero ;
203 break ;
204
205 default:
206 cout << "Unknown type in Change_var::Change_var(int)" << endl ;
207 abort() ;
208 break ;
209 }
210
211 mult_F = mult ;
212 add_F = 0 ;
213
214}
215
216// Construction du changement de variable ...
217Change_var::Change_var (int type_change, double mult, double add) {
218
219 switch (type_change) {
220 case STD:
221 func_F = zero ;
222 der_F = zero ;
223 func_G = one ;
224 der_G = zero ;
225 break ;
226
227 case W_BETA:
228 func_F = one ;
229 der_F = zero ;
230 func_G = ide ;
231 der_G = one ;
232 break ;
233
234 case W_BETA_INF:
235 func_F = part_ln ;
236 der_F = part_ln_der ;
237 func_G = ide ;
238 der_G = one ;
239 break ;
240
241 case H_BETA:
242 func_F = one ;
243 der_F = zero ;
244 func_G = one ;
245 der_G = zero ;
246 break ;
247
248 case LAMBDA_RN:
249 func_F = moins_log ;
250 der_F = moins_sur ;
251 func_G = one ;
252 der_G = zero ;
253 break ;
254
255 case NU_RN:
256 func_F = plus_log ;
257 der_F = plus_sur ;
258 func_G = one ;
259 der_G = zero ;
260 break ;
261
262 default:
263 cout << "Unknown type in Change_var::Change_var(int)" << endl ;
264 abort() ;
265 break ;
266 }
267
268 mult_F = mult ;
269 add_F = add ;
270
271}
272
273
275 func_F(so.func_F), der_F(so.der_F), func_G(so.func_G), der_G(so.der_G) {}
276
278
279double Change_var::val_F (double air) {
280 return (mult_F * (*func_F)(air) + add_F) ;
281}
282
283double Change_var::val_der_F (double air) {
284 return (mult_F * (*der_F)(air)) ;
285}
286
287double Change_var::val_G (double air) {
288 return (*func_G)(air) ;
289}
290
291double Change_var::val_der_G (double air) {
292 return (*der_G)(air) ;
293}
294
295}
This class defines a variable change to be used when solving elliptic equations.
Definition change_var.h:98
double mult_F
Pointer on the derivative of .
Definition change_var.h:106
double(* func_G)(double)
Pointer on the derivative of .
Definition change_var.h:103
double add_F
Multiplicative factor for F ## PROVISORY.
Definition change_var.h:107
double(* der_F)(double)
Pointer on the function .
Definition change_var.h:102
double val_F(double x)
Standard destructor.
Definition change_var.C:279
double val_der_F(double x)
Returns the value of at {\tt x}.
Definition change_var.C:283
Change_var(int var)
Additive factor for F ## PROVISORY.
Definition change_var.C:102
double val_der_G(double x)
Returns the value of at {\tt x}.
Definition change_var.C:291
double(* der_G)(double)
Pointer on the function .
Definition change_var.h:104
~Change_var()
Constructor by copy.
Definition change_var.C:277
double val_G(double x)
Returns the value of at {\tt x}.
Definition change_var.C:287
Cmp log(const Cmp &)
Neperian logarithm.
Definition cmp_math.C:299
Lorene prototypes.
Definition app_hor.h:67
Coord x
x coordinate centered on the grid
Definition map.h:738