LORENE
cmp_deriv.C
1/*
2 * Computations of partial derivatives d/dx, d/dy and d/dz of a Cmp.
3 */
4
5/*
6 * Copyright (c) 1999-2001 Eric Gourgoulhon
7 * Copyright (c) 1999-2001 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 cmp_deriv_C[] = "$Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_deriv.C,v 1.3 2014/10/13 08:52:47 j_novak Exp $" ;
29
30
31
32/*
33 * $Id: cmp_deriv.C,v 1.3 2014/10/13 08:52:47 j_novak Exp $
34 * $Log: cmp_deriv.C,v $
35 * Revision 1.3 2014/10/13 08:52:47 j_novak
36 * Lorene classes and functions now belong to the namespace Lorene.
37 *
38 * Revision 1.2 2014/10/06 15:13:03 j_novak
39 * Modified #include directives to use c++ syntax.
40 *
41 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
42 * LORENE
43 *
44 * Revision 1.7 2000/09/11 15:55:12 eric
45 * Calcul de dsdx, dsdy et dsdz: suppression des methodes Map::deriv_x, etc...
46 * et introduction des methodes Map::comp_x_from_spherical, etc...
47 *
48 * Revision 1.6 2000/02/08 14:20:14 phil
49 * vire set_etat_qcq
50 *
51 * Revision 1.5 2000/01/27 17:27:49 phil
52 * coorection etat du resultat
53 *
54 * Revision 1.4 2000/01/26 13:11:36 eric
55 * Modifs pour tenir compte du reprototypage complet des routines de derivation
56 * des mappings (Map::dsdr, etc...). Le resultat p_* est desormais alloue
57 * a l'exterieur de la routine Map::*.
58 *
59 * Revision 1.3 1999/11/29 14:38:16 eric
60 * *** empty log message ***
61 *
62 * Revision 1.2 1999/11/29 12:57:07 eric
63 * Introduction du laplacien.
64 *
65 * Revision 1.1 1999/11/25 16:28:17 eric
66 * Initial revision
67 *
68 *
69 * $Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_deriv.C,v 1.3 2014/10/13 08:52:47 j_novak Exp $
70 *
71 */
72
73// Headers C
74#include <cstdlib>
75
76// Headers Lorene
77#include "cmp.h"
78
79 //---------------------//
80 // d/dr //
81 //---------------------//
82
83namespace Lorene {
84const Cmp& Cmp::dsdr() const {
85
86 // Protection
87 assert(etat != ETATNONDEF) ;
88
89 // If the derivative has not been previously computed, the
90 // computation must be done by the appropriate routine of the mapping :
91
92 if (p_dsdr == 0x0) {
93 p_dsdr = new Cmp(mp) ;
94 mp->dsdr(*this, *p_dsdr) ;
95 }
96
97 return *p_dsdr ;
98
99}
100
101 //------------------------//
102 // 1/r d/dtheta //
103 //------------------------//
104
105const Cmp& Cmp::srdsdt() const {
106
107 // Protection
108 assert(etat != ETATNONDEF) ;
109
110 // If the derivative has not been previously computed, the
111 // computation must be done by the appropriate routine of the mapping :
112
113 if (p_srdsdt == 0x0) {
114 p_srdsdt = new Cmp(mp) ;
115 mp->srdsdt(*this, *p_srdsdt) ;
116 }
117
118 return *p_srdsdt ;
119
120}
121
122
123 //----------------------------------//
124 // 1/(r sin(theta) d/dphi //
125 //----------------------------------//
126
127const Cmp& Cmp::srstdsdp() const {
128
129 // Protection
130 assert(etat != ETATNONDEF) ;
131
132 // If the derivative has not been previously computed, the
133 // computation must be done by the appropriate routine of the mapping :
134
135 if (p_srstdsdp == 0x0) {
136 p_srstdsdp = new Cmp(mp) ;
137 mp->srstdsdp(*this, *p_srstdsdp) ;
138 }
139
140 return *p_srstdsdp ;
141
142}
143
144 //---------------------//
145 // d/dx //
146 //---------------------//
147
148const Cmp& Cmp::dsdx() const {
149
150 // Protection
151 assert(etat != ETATNONDEF) ;
152
153 // If the derivative has not been previously computed, the
154 // computation must be done by the appropriate routine of the mapping :
155
156 if (p_dsdx == 0x0) {
157 p_dsdx = new Cmp(mp) ;
159 }
160
161 return *p_dsdx ;
162
163}
164
165 //---------------------//
166 // d/dy //
167 //---------------------//
168
169const Cmp& Cmp::dsdy() const {
170
171 // Protection
172 assert(etat != ETATNONDEF) ;
173
174 // If the derivative has not been previously computed, the
175 // computation must be done by the appropriate routine of the mapping :
176
177 if (p_dsdy == 0x0) {
178 p_dsdy = new Cmp(mp) ;
180 }
181
182 return *p_dsdy ;
183
184}
185
186 //---------------------//
187 // d/dz //
188 //---------------------//
189
190const Cmp& Cmp::dsdz() const {
191
192 // Protection
193 assert(etat != ETATNONDEF) ;
194
195 // If the derivative has not been previously computed, the
196 // computation must be done by the appropriate routine of the mapping :
197
198 if (p_dsdz == 0x0) {
199 p_dsdz = new Cmp(mp) ;
201 }
202
203 return *p_dsdz ;
204
205}
206
207 //---------------------//
208 // d/dx^i //
209 //---------------------//
210
211const Cmp& Cmp::deriv(int i) const {
212
213 switch (i) {
214
215 case 0 : {
216 return dsdx() ;
217 }
218
219 case 1 : {
220 return dsdy() ;
221 }
222
223 case 2 : {
224 return dsdz() ;
225 }
226
227 default : {
228 cout << "Cmp::deriv : index i out of range !" << endl ;
229 cout << " i = " << i << endl ;
230 abort() ;
231 return dsdx() ; // Pour satisfaire le compilateur !
232 }
233
234 }
235
236}
237
238 //---------------------//
239 // Laplacian //
240 //---------------------//
241
242const Cmp& Cmp::laplacien(int zec_mult_r) const {
243
244 // Protection
245 assert(etat != ETATNONDEF) ;
246
247 // If the Laplacian has not been previously computed, the
248 // computation must be done by the appropriate routine of the mapping :
249 if ( (p_lap == 0x0) || (zec_mult_r != ind_lap) ) {
250 if (p_lap != 0x0) {
251 delete p_lap ; // the Laplacian had been computed but with
252 // a different value of zec_mult_r
253 }
254 p_lap = new Cmp(mp) ;
255 mp->laplacien(*this, zec_mult_r, *p_lap) ;
256 ind_lap = zec_mult_r ;
257 }
258
259 return *p_lap ;
260
261}
262
263
264
265
266}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
Cmp * p_dsdx
Pointer on of *this , where .
Definition cmp.h:479
const Map * mp
Reference mapping.
Definition cmp.h:451
Cmp * p_srstdsdp
Pointer on of *this.
Definition cmp.h:474
Cmp * p_srdsdt
Pointer on of *this.
Definition cmp.h:472
const Cmp & dsdz() const
Returns of *this , where .
Definition cmp_deriv.C:190
const Cmp & srstdsdp() const
Returns of *this .
Definition cmp_deriv.C:127
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition cmp.h:454
const Cmp & dsdy() const
Returns of *this , where .
Definition cmp_deriv.C:169
const Cmp & deriv(int i) const
Returns of *this , where .
Definition cmp_deriv.C:211
const Cmp & laplacien(int zec_mult_r=4) const
Returns the Laplacian of *this.
Definition cmp_deriv.C:242
const Cmp & srdsdt() const
Returns of *this .
Definition cmp_deriv.C:105
Cmp * p_dsdr
Pointer on of *this.
Definition cmp.h:470
const Cmp & dsdx() const
Returns of *this , where .
Definition cmp_deriv.C:148
Cmp * p_dsdy
Pointer on of *this , where .
Definition cmp.h:484
const Cmp & dsdr() const
Returns of *this .
Definition cmp_deriv.C:84
Cmp * p_lap
Pointer on the Laplacian of *this.
Definition cmp.h:493
int ind_lap
Power of r by which the last computed Laplacian has been multiplied in the external compactified doma...
Definition cmp.h:498
Cmp * p_dsdz
Pointer on of *this , where .
Definition cmp.h:489
virtual void srdsdt(const Cmp &ci, Cmp &resu) const =0
Computes of a Cmp .
virtual void comp_x_from_spherical(const Scalar &v_r, const Scalar &v_theta, const Scalar &v_phi, Scalar &v_x) const =0
Computes the Cartesian x component (with respect to bvect_cart ) of a vector given by its spherical c...
virtual void dsdr(const Cmp &ci, Cmp &resu) const =0
Computes of a Cmp .
virtual void comp_z_from_spherical(const Scalar &v_r, const Scalar &v_theta, Scalar &v_z) const =0
Computes the Cartesian z component (with respect to bvect_cart ) of a vector given by its spherical c...
virtual void comp_y_from_spherical(const Scalar &v_r, const Scalar &v_theta, const Scalar &v_phi, Scalar &v_y) const =0
Computes the Cartesian y component (with respect to bvect_cart ) of a vector given by its spherical c...
virtual void srstdsdp(const Cmp &ci, Cmp &resu) const =0
Computes of a Cmp .
virtual void laplacien(const Scalar &uu, int zec_mult_r, Scalar &lap) const =0
Computes the Laplacian of a scalar field.
Lorene prototypes.
Definition app_hor.h:64