| 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 |
|
| 28 |
char 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 |
|
| 83 |
namespace Lorene { |
| 84 |
const 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 |
|
| 105 |
const 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 |
|
| 127 |
const 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 |
|
| 148 |
const 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) ; |
| 158 |
mp->comp_x_from_spherical(dsdr(), srdsdt(), srstdsdp(), *p_dsdx) ; |
| 159 |
} |
| 160 |
|
| 161 |
return *p_dsdx ; |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
//---------------------// |
| 166 |
// d/dy // |
| 167 |
//---------------------// |
| 168 |
|
| 169 |
const 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) ; |
| 179 |
mp->comp_y_from_spherical(dsdr(), srdsdt(), srstdsdp(), *p_dsdy) ; |
| 180 |
} |
| 181 |
|
| 182 |
return *p_dsdy ; |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
//---------------------// |
| 187 |
// d/dz // |
| 188 |
//---------------------// |
| 189 |
|
| 190 |
const 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) ; |
| 200 |
mp->comp_z_from_spherical(dsdr(), srdsdt(), *p_dsdz) ; |
| 201 |
} |
| 202 |
|
| 203 |
return *p_dsdz ; |
| 204 |
|
| 205 |
} |
| 206 |
|
| 207 |
//---------------------// |
| 208 |
// d/dx^i // |
| 209 |
//---------------------// |
| 210 |
|
| 211 |
const 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 |
|
| 242 |
const 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 |
} |