00001 /* 00002 * Computations of partial derivatives d/dx, d/dy and d/dz of a Cmp. 00003 */ 00004 00005 /* 00006 * Copyright (c) 1999-2001 Eric Gourgoulhon 00007 * Copyright (c) 1999-2001 Philippe Grandclement 00008 * 00009 * This file is part of LORENE. 00010 * 00011 * LORENE is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * LORENE is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with LORENE; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 * 00025 */ 00026 00027 00028 char cmp_deriv_C[] = "$Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_deriv.C,v 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon Exp $" ; 00029 00030 00031 00032 /* 00033 * $Id: cmp_deriv.C,v 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon Exp $ 00034 * $Log: cmp_deriv.C,v $ 00035 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon 00036 * LORENE 00037 * 00038 * Revision 1.7 2000/09/11 15:55:12 eric 00039 * Calcul de dsdx, dsdy et dsdz: suppression des methodes Map::deriv_x, etc... 00040 * et introduction des methodes Map::comp_x_from_spherical, etc... 00041 * 00042 * Revision 1.6 2000/02/08 14:20:14 phil 00043 * vire set_etat_qcq 00044 * 00045 * Revision 1.5 2000/01/27 17:27:49 phil 00046 * coorection etat du resultat 00047 * 00048 * Revision 1.4 2000/01/26 13:11:36 eric 00049 * Modifs pour tenir compte du reprototypage complet des routines de derivation 00050 * des mappings (Map::dsdr, etc...). Le resultat p_* est desormais alloue 00051 * a l'exterieur de la routine Map::*. 00052 * 00053 * Revision 1.3 1999/11/29 14:38:16 eric 00054 * *** empty log message *** 00055 * 00056 * Revision 1.2 1999/11/29 12:57:07 eric 00057 * Introduction du laplacien. 00058 * 00059 * Revision 1.1 1999/11/25 16:28:17 eric 00060 * Initial revision 00061 * 00062 * 00063 * $Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_deriv.C,v 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon Exp $ 00064 * 00065 */ 00066 00067 // Headers C 00068 #include <stdlib.h> 00069 00070 // Headers Lorene 00071 #include "cmp.h" 00072 00073 //---------------------// 00074 // d/dr // 00075 //---------------------// 00076 00077 const Cmp& Cmp::dsdr() const { 00078 00079 // Protection 00080 assert(etat != ETATNONDEF) ; 00081 00082 // If the derivative has not been previously computed, the 00083 // computation must be done by the appropriate routine of the mapping : 00084 00085 if (p_dsdr == 0x0) { 00086 p_dsdr = new Cmp(mp) ; 00087 mp->dsdr(*this, *p_dsdr) ; 00088 } 00089 00090 return *p_dsdr ; 00091 00092 } 00093 00094 //------------------------// 00095 // 1/r d/dtheta // 00096 //------------------------// 00097 00098 const Cmp& Cmp::srdsdt() const { 00099 00100 // Protection 00101 assert(etat != ETATNONDEF) ; 00102 00103 // If the derivative has not been previously computed, the 00104 // computation must be done by the appropriate routine of the mapping : 00105 00106 if (p_srdsdt == 0x0) { 00107 p_srdsdt = new Cmp(mp) ; 00108 mp->srdsdt(*this, *p_srdsdt) ; 00109 } 00110 00111 return *p_srdsdt ; 00112 00113 } 00114 00115 00116 //----------------------------------// 00117 // 1/(r sin(theta) d/dphi // 00118 //----------------------------------// 00119 00120 const Cmp& Cmp::srstdsdp() const { 00121 00122 // Protection 00123 assert(etat != ETATNONDEF) ; 00124 00125 // If the derivative has not been previously computed, the 00126 // computation must be done by the appropriate routine of the mapping : 00127 00128 if (p_srstdsdp == 0x0) { 00129 p_srstdsdp = new Cmp(mp) ; 00130 mp->srstdsdp(*this, *p_srstdsdp) ; 00131 } 00132 00133 return *p_srstdsdp ; 00134 00135 } 00136 00137 //---------------------// 00138 // d/dx // 00139 //---------------------// 00140 00141 const Cmp& Cmp::dsdx() const { 00142 00143 // Protection 00144 assert(etat != ETATNONDEF) ; 00145 00146 // If the derivative has not been previously computed, the 00147 // computation must be done by the appropriate routine of the mapping : 00148 00149 if (p_dsdx == 0x0) { 00150 p_dsdx = new Cmp(mp) ; 00151 mp->comp_x_from_spherical(dsdr(), srdsdt(), srstdsdp(), *p_dsdx) ; 00152 } 00153 00154 return *p_dsdx ; 00155 00156 } 00157 00158 //---------------------// 00159 // d/dy // 00160 //---------------------// 00161 00162 const Cmp& Cmp::dsdy() const { 00163 00164 // Protection 00165 assert(etat != ETATNONDEF) ; 00166 00167 // If the derivative has not been previously computed, the 00168 // computation must be done by the appropriate routine of the mapping : 00169 00170 if (p_dsdy == 0x0) { 00171 p_dsdy = new Cmp(mp) ; 00172 mp->comp_y_from_spherical(dsdr(), srdsdt(), srstdsdp(), *p_dsdy) ; 00173 } 00174 00175 return *p_dsdy ; 00176 00177 } 00178 00179 //---------------------// 00180 // d/dz // 00181 //---------------------// 00182 00183 const Cmp& Cmp::dsdz() const { 00184 00185 // Protection 00186 assert(etat != ETATNONDEF) ; 00187 00188 // If the derivative has not been previously computed, the 00189 // computation must be done by the appropriate routine of the mapping : 00190 00191 if (p_dsdz == 0x0) { 00192 p_dsdz = new Cmp(mp) ; 00193 mp->comp_z_from_spherical(dsdr(), srdsdt(), *p_dsdz) ; 00194 } 00195 00196 return *p_dsdz ; 00197 00198 } 00199 00200 //---------------------// 00201 // d/dx^i // 00202 //---------------------// 00203 00204 const Cmp& Cmp::deriv(int i) const { 00205 00206 switch (i) { 00207 00208 case 0 : { 00209 return dsdx() ; 00210 } 00211 00212 case 1 : { 00213 return dsdy() ; 00214 } 00215 00216 case 2 : { 00217 return dsdz() ; 00218 } 00219 00220 default : { 00221 cout << "Cmp::deriv : index i out of range !" << endl ; 00222 cout << " i = " << i << endl ; 00223 abort() ; 00224 return dsdx() ; // Pour satisfaire le compilateur ! 00225 } 00226 00227 } 00228 00229 } 00230 00231 //---------------------// 00232 // Laplacian // 00233 //---------------------// 00234 00235 const Cmp& Cmp::laplacien(int zec_mult_r) const { 00236 00237 // Protection 00238 assert(etat != ETATNONDEF) ; 00239 00240 // If the Laplacian has not been previously computed, the 00241 // computation must be done by the appropriate routine of the mapping : 00242 if ( (p_lap == 0x0) || (zec_mult_r != ind_lap) ) { 00243 if (p_lap != 0x0) { 00244 delete p_lap ; // the Laplacian had been computed but with 00245 // a different value of zec_mult_r 00246 } 00247 p_lap = new Cmp(mp) ; 00248 mp->laplacien(*this, zec_mult_r, *p_lap) ; 00249 ind_lap = zec_mult_r ; 00250 } 00251 00252 return *p_lap ; 00253 00254 } 00255 00256 00257 00258
1.4.6