Debian Codegraph @

C++/Source/Map/map_log_deriv.C

raw
1 /*
2 * Computations of Scalar partial derivatives for a Map_log mapping
3 */
4
5 /*
6 * Copyright (c) 2004 Philippe Grandclement
7 *
8 * This file is part of LORENE.
9 *
10 * LORENE is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * LORENE is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with LORENE; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26
27 char map_log_deriv_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_log_deriv.C,v 1.3 2014/10/13 08:53:05 j_novak Exp $" ;
28
29 /*
30 * $Id: map_log_deriv.C,v 1.3 2014/10/13 08:53:05 j_novak Exp $
31 * $Log: map_log_deriv.C,v $
32 * Revision 1.3 2014/10/13 08:53:05 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.2 2012/01/17 10:33:43 j_penner
36 * added a derivative with respect to the computational coordinate xi
37 *
38 * Revision 1.1 2004/06/22 08:49:58 p_grandclement
39 * Addition of everything needed for using the logarithmic mapping
40 *
41 *
42 * $Header: /cvsroot/Lorene/C++/Source/Map/map_log_deriv.C,v 1.3 2014/10/13 08:53:05 j_novak Exp $
43 *
44 */
45
46 // Header Lorene
47 #include "map.h"
48 #include "tensor.h"
49
50 //---------------------------------------------------
51 // d/d\xi
52 //---------------------------------------------------
53 namespace Lorene {
54 void Map_log::dsdxi(const Scalar& uu, Scalar& resu) const {
55
56 assert (uu.get_etat() != ETATNONDEF) ;
57 assert (uu.get_mp().get_mg() == mg) ;
58
59
60 if (uu.get_etat() == ETATZERO) {
61 resu.set_etat_zero() ;
62 }
63 else {
64 assert( uu.get_etat() == ETATQCQ ) ;
65
66 const Valeur& uuva = uu.get_spectral_va() ;
67
68 uuva.coef() ; // (uu.va).c_cf is up to date
69
70 int nz = mg->get_nzone() ;
71 int nzm1 = nz - 1 ;
72
73 if ( uu.get_dzpuis() == 0 ) {
74 resu = uuva.dsdx() ; // dsdx == d/d\xi
75
76 if (mg->get_type_r(nzm1) == UNSURR) {
77 resu.set_dzpuis(2) ; // r^2 d/dr has been computed in the
78 // external domain
79 }
80 }
81 else {
82 assert(mg->get_type_r(nzm1) == UNSURR) ;
83
84 int dzp = uu.get_dzpuis() ;
85
86 resu = uuva.dsdx() ;
87 resu.annule_domain(nzm1) ; // zero in the CED
88
89 // Special treatment in the CED
90 Valeur tmp_ced = - uuva.dsdx() ;
91 tmp_ced.annule(0, nz-2) ; // only non zero in the CED
92 tmp_ced.mult_xm1_zec() ;
93 tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ;
94
95 // Recombination shells + CED :
96 resu.set_spectral_va() += tmp_ced ;
97
98 resu.set_dzpuis(dzp+1) ;
99
100 }
101 resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi
102 }
103 }
104
105 //---------------------------------------------------
106 // Derivee standard par rapport au "vrai" rayon .....
107 //---------------------------------------------------
108 void Map_log::dsdr(const Scalar& uu, Scalar& resu) const {
109
110 assert (uu.get_etat() != ETATNONDEF) ;
111 assert (uu.get_mp().get_mg() == mg) ;
112
113
114 if (uu.get_etat() == ETATZERO) {
115 resu.set_etat_zero() ;
116 }
117 else {
118 assert( uu.get_etat() == ETATQCQ ) ;
119
120 const Valeur& uuva = uu.get_spectral_va() ;
121
122 uuva.coef() ; // (uu.va).c_cf is up to date
123
124 int nz = mg->get_nzone() ;
125 int nzm1 = nz - 1 ;
126
127 if ( uu.get_dzpuis() == 0 ) {
128 resu = uuva.dsdx() * dxdr ; // dxdr = dxi/dR, - dxi/dU (ZEC)
129
130 if (mg->get_type_r(nzm1) == UNSURR) {
131 resu.set_dzpuis(2) ; // r^2 d/dr has been computed in the
132 // external domain
133 }
134 }
135 else {
136 assert(mg->get_type_r(nzm1) == UNSURR) ;
137
138 int dzp = uu.get_dzpuis() ;
139
140 resu = uuva.dsdx() * dxdr ;
141 resu.annule_domain(nzm1) ; // zero in the CED
142
143 // Special treatment in the CED
144 Valeur tmp_ced = - uuva.dsdx() ;
145 tmp_ced.annule(0, nz-2) ; // only non zero in the CED
146 tmp_ced.mult_xm1_zec() ;
147 tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ;
148
149 // Recombination shells + CED :
150 resu.set_spectral_va() += tmp_ced ;
151
152 resu.set_dzpuis(dzp+1) ;
153
154 }
155 resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi
156 }
157 }
158
159 //---------------------------------------------------
160 // Derivee par rapport au rayon numerique (r ou lnr)
161 //---------------------------------------------------
162 void Map_log::dsdradial (const Scalar& uu, Scalar& resu) const {
163
164 assert (uu.get_etat() != ETATNONDEF) ;
165 assert (uu.get_mp().get_mg() == mg) ;
166
167
168 if (uu.get_etat() == ETATZERO) {
169 resu.set_etat_zero() ;
170 }
171 else {
172 assert( uu.get_etat() == ETATQCQ ) ;
173
174 const Valeur& uuva = uu.get_spectral_va() ;
175
176 uuva.coef() ; // (uu.va).c_cf is up to date
177
178 int nz = mg->get_nzone() ;
179 int nzm1 = nz - 1 ;
180
181 if ( uu.get_dzpuis() == 0 ) {
182 resu = uuva.dsdx() * dxdlnr ; // dxdr = dxi/dR, - dxi/dU (ZEC)
183
184 if (mg->get_type_r(nzm1) == UNSURR) {
185 resu.set_dzpuis(2) ; // r^2 d/dr has been computed in the
186 // external domain
187 }
188 }
189 else {
190 assert(mg->get_type_r(nzm1) == UNSURR) ;
191
192 int dzp = uu.get_dzpuis() ;
193
194 resu = uuva.dsdx() * dxdlnr ;
195 resu.annule_domain(nzm1) ; // zero in the CED
196
197 // Special treatment in the CED
198 Valeur tmp_ced = - uuva.dsdx() ;
199 tmp_ced.annule(0, nz-2) ; // only non zero in the CED
200 tmp_ced.mult_xm1_zec() ;
201 tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ;
202
203 // Recombination shells + CED :
204 resu.set_spectral_va() += tmp_ced ;
205
206 resu.set_dzpuis(dzp+1) ;
207
208 }
209 resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi
210 }
211 }
212 }