| 1 | /* |
| 2 | * Definition of Lorene class Cmp |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999-2000 Jean-Alain Marck |
| 8 | * Copyright (c) 1999-2002 Eric Gourgoulhon |
| 9 | * Copyright (c) 1999-2001 Philippe Grandclement |
| 10 | * Copyright (c) 2000-2002 Jerome Novak |
| 11 | * Copyright (c) 2000-2001 Keisuke Taniguchi |
| 12 | * |
| 13 | * This file is part of LORENE. |
| 14 | * |
| 15 | * LORENE is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License as published by |
| 17 | * the Free Software Foundation; either version 2 of the License, or |
| 18 | * (at your option) any later version. |
| 19 | * |
| 20 | * LORENE is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with LORENE; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | #ifndef __CMP_H_ |
| 33 | #define __CMP_H_ |
| 34 | |
| 35 | |
| 36 | /* |
| 37 | * $Id: cmp.h,v 1.23 2016/09/19 15:26:22 j_novak Exp $ |
| 38 | * $Log: cmp.h,v $ |
| 39 | * Revision 1.23 2016/09/19 15:26:22 j_novak |
| 40 | * Correction of several bugs preventing the shared library compilation. |
| 41 | * |
| 42 | * Revision 1.22 2014/10/13 08:52:33 j_novak |
| 43 | * Lorene classes and functions now belong to the namespace Lorene. |
| 44 | * |
| 45 | * Revision 1.21 2014/10/06 15:09:39 j_novak |
| 46 | * Modified #include directives to use c++ syntax. |
| 47 | * |
| 48 | * Revision 1.20 2012/08/12 17:35:36 p_cerda |
| 49 | * Magnetstar: adding new member to class Cmp |
| 50 | * |
| 51 | * Revision 1.19 2010/02/02 13:34:12 e_gourgoulhon |
| 52 | * Marked DEPRECATED (in the documentation). |
| 53 | * |
| 54 | * Revision 1.18 2005/08/30 08:35:10 p_grandclement |
| 55 | * Addition of the Tau version of the vectorial Poisson equation for the Tensors |
| 56 | * |
| 57 | * Revision 1.17 2005/08/02 06:09:58 m_saijo |
| 58 | * Modified comment lines (div_r, multi_r, mult_rsint, div_rsint) |
| 59 | * |
| 60 | * Revision 1.16 2004/12/29 16:20:20 k_taniguchi |
| 61 | * Addition of the function poisson_ylm. |
| 62 | * |
| 63 | * Revision 1.15 2004/11/30 20:38:10 k_taniguchi |
| 64 | * Addition of the function poisson_falloff. |
| 65 | * |
| 66 | * Revision 1.14 2004/10/11 15:08:59 j_novak |
| 67 | * The radial manipulation functions take Scalar as arguments, instead of Cmp. |
| 68 | * Added a conversion operator from Scalar to Cmp. |
| 69 | * The Cmp radial manipulation function make conversion to Scalar, call to the |
| 70 | * Map_radial version with a Scalar argument and back. |
| 71 | * |
| 72 | * Revision 1.13 2004/03/31 11:21:02 f_limousin |
| 73 | * Method Cmp::poisson_neumann_interne has been implemented to solve |
| 74 | * the continuity equation for strange stars. |
| 75 | * |
| 76 | * Revision 1.12 2004/03/22 13:12:40 j_novak |
| 77 | * Modification of comments to use doxygen instead of doc++ |
| 78 | * |
| 79 | * Revision 1.11 2004/03/01 09:54:58 j_novak |
| 80 | * Suppression of the Cmp version of avance_dalembert (now only with Scalar's) |
| 81 | * |
| 82 | * Revision 1.10 2003/11/06 14:43:37 e_gourgoulhon |
| 83 | * Gave a name to const arguments in certain method prototypes (e.g. |
| 84 | * constructors) to correct a bug of DOC++. |
| 85 | * |
| 86 | * Revision 1.9 2003/09/24 20:52:37 e_gourgoulhon |
| 87 | * Added constructor by conversion of a Scalar. |
| 88 | * |
| 89 | * Revision 1.8 2003/08/26 09:46:10 j_novak |
| 90 | * Added the method multipole_spectrum |
| 91 | * |
| 92 | * Revision 1.7 2003/06/20 14:16:10 f_limousin |
| 93 | * Add the function compare(). |
| 94 | * |
| 95 | * Revision 1.6 2003/06/20 09:27:09 j_novak |
| 96 | * Modif commentaires. |
| 97 | * |
| 98 | * Revision 1.5 2002/09/13 09:17:31 j_novak |
| 99 | * Modif. commentaires |
| 100 | * |
| 101 | * Revision 1.4 2002/06/17 14:05:16 j_novak |
| 102 | * friend functions are now also declared outside the class definition |
| 103 | * |
| 104 | * Revision 1.3 2002/05/17 12:08:46 e_gourgoulhon |
| 105 | * Corrected error in the comment about dzpuis: multiplied --> divided |
| 106 | * |
| 107 | * Revision 1.2 2002/01/03 15:30:27 j_novak |
| 108 | * Some comments modified. |
| 109 | * |
| 110 | * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 111 | * LORENE |
| 112 | * |
| 113 | * Revision 2.101 2001/10/29 15:36:03 novak |
| 114 | * Ajout de Cmp::div_r() |
| 115 | * |
| 116 | * Revision 2.100 2001/10/16 10:03:57 novak |
| 117 | * *** empty log message *** |
| 118 | * |
| 119 | * Revision 2.99 2001/08/31 14:52:10 novak |
| 120 | * Back to 2.97 version 2.98 was useless |
| 121 | * |
| 122 | * Revision 2.97 2001/07/19 14:01:39 novak |
| 123 | * new arguments for Cmp::avance_dalembert |
| 124 | * |
| 125 | * Revision 2.96 2001/05/29 16:09:40 eric |
| 126 | * Modif commentaires (mise en conformite Doc++ 3.4.7). |
| 127 | * |
| 128 | * Revision 2.95 2001/05/26 15:07:20 eric |
| 129 | * Ajout de operator% : multiplication de deux Cmp avec desaliasage |
| 130 | * |
| 131 | * Revision 2.94 2001/05/25 09:30:07 phil |
| 132 | * ajout de filtre_phi |
| 133 | * |
| 134 | * Revision 2.93 2001/03/30 13:36:22 phil |
| 135 | * ajout de raccord_externe |
| 136 | * |
| 137 | * Revision 2.92 2001/03/26 08:11:50 eric |
| 138 | * Modif commentaires. |
| 139 | * |
| 140 | * Revision 2.91 2001/03/22 10:25:19 phil |
| 141 | * modification prototypage de raccord_zec.C |
| 142 | * |
| 143 | * Revision 2.90 2001/02/12 18:08:10 phil |
| 144 | * ajout de Cmp::fixe_decroissance |
| 145 | * |
| 146 | * Revision 2.89 2000/12/13 14:50:05 phil |
| 147 | * changement nom variable dzpuis dans raccord_c1_zec |
| 148 | * |
| 149 | * Revision 2.88 2000/12/13 14:35:53 phil |
| 150 | * *** empty log message *** |
| 151 | * |
| 152 | * Revision 2.87 2000/12/13 14:26:42 phil |
| 153 | * *** empty log message *** |
| 154 | * |
| 155 | * Revision 2.86 2000/12/13 14:25:26 phil |
| 156 | * vire commentaires des raccords (provisioire) |
| 157 | * |
| 158 | * Revision 2.85 2000/12/13 14:19:49 phil |
| 159 | * modif commentaires |
| 160 | * |
| 161 | * Revision 2.84 2000/12/13 14:08:36 phil |
| 162 | * ajout procedure raccord_c1_zec |
| 163 | * |
| 164 | * Revision 2.83 2000/12/04 16:48:47 novak |
| 165 | * *** empty log message *** |
| 166 | * |
| 167 | * Revision 2.82 2000/12/04 15:06:15 novak |
| 168 | * *** empty log message *** |
| 169 | * |
| 170 | * Revision 2.81 2000/11/15 13:24:28 phil |
| 171 | * modification de asymptot |
| 172 | * |
| 173 | * Revision 2.80 2000/11/15 13:19:13 phil |
| 174 | * *** empty log message *** |
| 175 | * |
| 176 | * Revision 2.79 2000/11/15 13:17:01 phil |
| 177 | * *** empty log message *** |
| 178 | * |
| 179 | * Revision 2.78 2000/11/15 13:15:45 phil |
| 180 | * gestion affichage dans asymptot |
| 181 | * |
| 182 | * Revision 2.77 2000/10/20 09:43:30 phil |
| 183 | * changement commentaires |
| 184 | * |
| 185 | * Revision 2.76 2000/10/19 14:07:06 novak |
| 186 | * Ajout de la fonction membre avance_dalembert (experimentale) |
| 187 | * |
| 188 | * Revision 2.75 2000/10/19 09:20:36 phil |
| 189 | * *** empty log message *** |
| 190 | * |
| 191 | * Revision 2.74 2000/10/19 09:13:45 phil |
| 192 | * ajout des fonctions : |
| 193 | * filtre(int) |
| 194 | * set_val_inf(double) |
| 195 | * set_val_hor(double,int) |
| 196 | * |
| 197 | * Revision 2.73 2000/10/05 14:18:14 eric |
| 198 | * La fonction check_poisson est rebaptisee test_poisson. |
| 199 | * |
| 200 | * Revision 2.72 2000/10/05 13:56:52 eric |
| 201 | * *** empty log message *** |
| 202 | * |
| 203 | * Revision 2.71 2000/10/05 13:52:25 eric |
| 204 | * Ajout de la fonction check_poisson. |
| 205 | * |
| 206 | * Revision 2.70 2000/09/13 12:21:44 eric |
| 207 | * Modif commentaires. |
| 208 | * |
| 209 | * Revision 2.69 2000/09/13 12:11:48 eric |
| 210 | * Ajout de la fonction allocate_all(). |
| 211 | * |
| 212 | * Revision 2.68 2000/09/07 15:26:40 keisuke |
| 213 | * Add a new argument Cmp& uu in Cmp::poisson_regular. |
| 214 | * |
| 215 | * Revision 2.67 2000/09/04 09:11:06 keisuke |
| 216 | * Suppress Cmp::poisson_regular (version without parameter). |
| 217 | * |
| 218 | * Revision 2.66 2000/08/31 13:04:30 eric |
| 219 | * Ajout des fonctions mult_rsint et div_rsint. |
| 220 | * |
| 221 | * Revision 2.65 2000/08/29 13:51:36 keisuke |
| 222 | * *** empty log message *** |
| 223 | * |
| 224 | * Revision 2.64 2000/08/29 13:46:14 keisuke |
| 225 | * Add the polar and azimuthal derivatives of the diverging potential |
| 226 | * in Cmp::poisson_regular. |
| 227 | * Modify the argumants of Cmp::poisson_regular. |
| 228 | * |
| 229 | * Revision 2.63 2000/08/28 15:48:22 keisuke |
| 230 | * Modif Cmp::poisson_regular |
| 231 | * |
| 232 | * Revision 2.62 2000/08/28 15:43:11 keisuke |
| 233 | * Modif Cmp::poisson_regular |
| 234 | * |
| 235 | * Revision 2.61 2000/08/04 12:09:58 eric |
| 236 | * Ajout de l'operator()(int l) et de la fonction set(int l) pour |
| 237 | * l'acces aux Tbl individuels. |
| 238 | * |
| 239 | * Revision 2.60 2000/08/04 09:18:05 keisuke |
| 240 | * Transformation Cmp::poisson_regular_param en Cmp::poisson_regular |
| 241 | * |
| 242 | * Revision 2.59 2000/08/03 14:01:29 keisuke |
| 243 | * Modif Cmp::poisson_regular et ajout de Cmp::poisson_regular_param |
| 244 | * |
| 245 | * Revision 2.58 2000/07/29 12:50:01 keisuke |
| 246 | * Modif Cmp::poisson_regular |
| 247 | * |
| 248 | * Revision 2.57 2000/07/20 13:33:50 keisuke |
| 249 | * Modif Cmp::poisson_regular |
| 250 | * |
| 251 | * Revision 2.56 2000/07/20 10:25:09 keisuke |
| 252 | * Modif Cmp::poisson_regular |
| 253 | * |
| 254 | * Revision 2.55 2000/07/19 15:50:23 keisuke |
| 255 | * Ajout de Cmp::poisson_regular |
| 256 | * |
| 257 | * Revision 2.54 2000/05/22 14:38:32 phil |
| 258 | * ajout de dec_dzpuis et inc_dzpuis |
| 259 | * |
| 260 | * Revision 2.53 2000/04/27 15:18:57 phil |
| 261 | * *** empty log message *** |
| 262 | * |
| 263 | * Revision 2.52 2000/03/28 17:44:41 phil |
| 264 | * Cmp::raccord() -> Cmp::raccord(int) |
| 265 | * |
| 266 | * Revision 2.51 2000/03/28 17:31:31 phil |
| 267 | * *** empty log message *** |
| 268 | * |
| 269 | * Revision 2.50 2000/03/28 17:25:35 phil |
| 270 | * ajout de Cmp::raccord() |
| 271 | * |
| 272 | * Revision 2.49 2000/03/25 12:52:45 eric |
| 273 | * Ajout de la fonction asymptot(int ). |
| 274 | * |
| 275 | * Revision 2.48 2000/03/20 13:33:31 phil |
| 276 | * commentaires |
| 277 | * |
| 278 | * Revision 2.47 2000/03/17 17:32:54 phil |
| 279 | * *** empty log message *** |
| 280 | * |
| 281 | * Revision 2.46 2000/03/17 17:07:14 phil |
| 282 | * *** empty log message *** |
| 283 | * |
| 284 | * Revision 2.45 2000/03/17 16:56:00 phil |
| 285 | * ajout de poisson_dirichlet et de son amie poisson_neumann |
| 286 | * |
| 287 | * Revision 2.44 2000/03/06 10:55:44 eric |
| 288 | * Ajout des methodes import_symy et import_asymy. |
| 289 | * |
| 290 | * Revision 2.43 2000/02/28 16:29:48 eric |
| 291 | * Ajout des fonctions import_gal, import_align, import_anti. |
| 292 | * |
| 293 | * Revision 2.42 2000/01/28 16:08:55 eric |
| 294 | * Ajout des fonctions dz_nonzero et check_dzpuis. |
| 295 | * |
| 296 | * Revision 2.41 2000/01/07 16:28:15 eric |
| 297 | * Suppression de la fonction membre gradient. |
| 298 | * |
| 299 | * Revision 2.40 1999/12/21 13:03:22 eric |
| 300 | * Changement de prototype de la routine poisson avec Param& : la solution est |
| 301 | * desormais passee en argument (et non plus en valeur de retour) |
| 302 | * pour permettre l'initialisation de methodes de resolution iteratives. |
| 303 | * |
| 304 | * Revision 2.39 1999/12/21 10:06:52 eric |
| 305 | * Il y a desormais deux versions de poisson: une sans Param et une |
| 306 | * avec Param. |
| 307 | * |
| 308 | * Revision 2.38 1999/12/10 16:19:33 eric |
| 309 | * Modif commentaires. |
| 310 | * |
| 311 | * Revision 2.37 1999/12/10 15:59:01 eric |
| 312 | * Modif commentaires fonction set. |
| 313 | * |
| 314 | * Revision 2.36 1999/12/09 10:45:54 eric |
| 315 | * Ajout du calcul d'integrale (membre p_integ et fonctions |
| 316 | * integrale et integrale_domains). |
| 317 | * |
| 318 | * Revision 2.35 1999/12/08 12:38:38 eric |
| 319 | * Ajout de la fonction import. |
| 320 | * |
| 321 | * Revision 2.34 1999/12/07 14:53:13 eric |
| 322 | * Changement ordre des arguments (phi,theta,r) --> (r,theta,phi) |
| 323 | * dans la routine val_point. |
| 324 | * |
| 325 | * Revision 2.33 1999/12/06 16:47:00 eric |
| 326 | * Ajout de la fonction val_point. |
| 327 | * |
| 328 | * Revision 2.32 1999/12/02 17:59:11 phil |
| 329 | * *** empty log message *** |
| 330 | * |
| 331 | * Revision 2.31 1999/12/02 14:28:46 eric |
| 332 | * Reprototypage de la fonction poisson(): const. |
| 333 | * Commentaires. |
| 334 | * |
| 335 | * Revision 2.30 1999/11/30 14:20:54 eric |
| 336 | * Reprototypage des fonctions membres mult_r, mult_r_zec, |
| 337 | * dec2_dzpuis et inc2_dzpuis : Cmp --> void. |
| 338 | * |
| 339 | * Revision 2.29 1999/11/29 13:18:06 eric |
| 340 | * Modif commentaires. |
| 341 | * |
| 342 | * Revision 2.28 1999/11/29 12:56:11 eric |
| 343 | * Introduction des membres p_lap, ind_lap. |
| 344 | * Changement prototype de la fonction laplacien. |
| 345 | * |
| 346 | * Revision 2.27 1999/11/26 14:22:54 eric |
| 347 | * Ajout du membre dzpuis et des fonctions de manipulation associees. |
| 348 | * |
| 349 | * Revision 2.26 1999/11/25 16:27:00 eric |
| 350 | * Reorganisation complete du calcul et stokage des derivees partielles. |
| 351 | * |
| 352 | * Revision 2.25 1999/11/23 16:21:32 eric |
| 353 | * Suppression du membre statique Cmp_Zero. |
| 354 | * Suppression du constructeur par defaut. |
| 355 | * |
| 356 | * Revision 2.24 1999/11/22 16:48:00 phil |
| 357 | * Cmp_Zero est desormais public |
| 358 | * |
| 359 | * Revision 2.23 1999/11/22 16:34:17 eric |
| 360 | * Ajout de l'element global Cmp_Zero. |
| 361 | * |
| 362 | * Revision 2.22 1999/11/22 15:41:42 eric |
| 363 | * Ajout des operateurs set(l,k,j,i) et (l,k,j,i). |
| 364 | * Ajout de la fonction annule(int l). |
| 365 | * |
| 366 | * Revision 2.21 1999/11/15 14:12:28 eric |
| 367 | * Ajout des fonctions mathematiques cos, sin, ..., min, max, norme,... |
| 368 | * |
| 369 | * Revision 2.20 1999/11/12 17:08:10 eric |
| 370 | * Ajout de la partie manquante de l'arithmetique. |
| 371 | * |
| 372 | * Revision 2.19 1999/10/28 09:36:56 eric |
| 373 | * Ajout de la fonction affiche_seuil. |
| 374 | * |
| 375 | * Revision 2.18 1999/10/28 09:01:24 eric |
| 376 | * Constructeur par lecture de fichier. |
| 377 | * Ajout de la fonction annule(int, int). |
| 378 | * |
| 379 | * Revision 2.17 1999/10/27 16:46:23 phil |
| 380 | * ajout de mult_r_zec |
| 381 | * |
| 382 | * Revision 2.16 1999/10/27 15:38:40 eric |
| 383 | * Suppression du membre c. |
| 384 | * |
| 385 | * Revision 2.15 1999/10/27 08:42:40 eric |
| 386 | * Introduction du membre Valeur va. |
| 387 | * Le pointeur Valeur* c est desormais un membre prive constant qui pointe |
| 388 | * sur va. |
| 389 | * Suppression de la fonction nouveau(), ainsi que du constructeur par |
| 390 | * defaut. |
| 391 | * |
| 392 | * Revision 2.14 1999/10/22 08:14:19 eric |
| 393 | * Depoussierage. |
| 394 | * Documentation. |
| 395 | * |
| 396 | * Revision 2.13 1999/10/19 14:40:51 phil |
| 397 | * ajout de inc2_dzpuis() |
| 398 | * |
| 399 | * Revision 2.12 1999/09/16 13:16:47 phil |
| 400 | * ajout de Cmp mult_r() |
| 401 | * |
| 402 | * Revision 2.11 1999/09/15 10:29:44 phil |
| 403 | * ajout de dec2_dzpuis() |
| 404 | * |
| 405 | * Revision 2.10 1999/09/14 17:13:05 phil |
| 406 | * ajout de Cmp operator*(double,const Cmp&) |
| 407 | * |
| 408 | * Revision 2.9 1999/09/14 13:45:27 phil |
| 409 | * suppression de la divergence |
| 410 | * |
| 411 | * Revision 2.8 1999/09/14 12:50:31 phil |
| 412 | * ajout de Cmp deriv(int) et de Cmp divergence() |
| 413 | * |
| 414 | * Revision 2.7 1999/09/07 16:08:04 phil |
| 415 | * ajout de la fonction membre gradient |
| 416 | * |
| 417 | * Revision 2.6 1999/09/06 14:50:27 phil |
| 418 | * ajout du laplacien |
| 419 | * |
| 420 | * Revision 2.5 1999/09/06 14:35:05 phil |
| 421 | * ajout de poisson |
| 422 | * |
| 423 | * Revision 2.4 1999/03/03 11:13:46 hyc |
| 424 | * *** empty log message *** |
| 425 | * |
| 426 | * Revision 2.3 1999/03/03 11:07:27 hyc |
| 427 | * *** empty log message *** |
| 428 | * |
| 429 | * |
| 430 | * $Header: /cvsroot/Lorene/C++/Include/cmp.h,v 1.23 2016/09/19 15:26:22 j_novak Exp $ |
| 431 | * |
| 432 | */ |
| 433 | |
| 434 | #include <cstdio> |
| 435 | |
| 436 | #include "valeur.h" |
| 437 | #include "map.h" |
| 438 | |
| 439 | namespace Lorene { |
| 440 | class Param ; |
| 441 | |
| 442 | /** |
| 443 | * Component of a tensorial field *** DEPRECATED : use class \c Scalar instead ***. \ingroup (otens) |
| 444 | */ |
| 445 | |
| 446 | class Cmp { |
| 447 | |
| 448 | // Data : |
| 449 | // ----- |
| 450 | private: |
| 451 | const Map* mp ; ///< Reference mapping |
| 452 | |
| 453 | /// Logical state (\c ETATNONDEF , \c ETATQCQ or \c ETATZERO ). |
| 454 | int etat ; |
| 455 | |
| 456 | /** |
| 457 | * Power of \e r by which the quantity represented by \c this |
| 458 | * must be divided in the external compactified zone in order |
| 459 | * to get the correct physical values |
| 460 | */ |
| 461 | int dzpuis ; |
| 462 | |
| 463 | public: |
| 464 | Valeur va ; ///< The numerical value of the \c Cmp |
| 465 | |
| 466 | // Derived data : |
| 467 | // ------------ |
| 468 | private: |
| 469 | /// Pointer on \f$\partial/\partial r\f$ of \c *this |
| 470 | mutable Cmp* p_dsdr ; |
| 471 | /// Pointer on \f$1/r \partial/\partial \theta\f$ of \c *this |
| 472 | mutable Cmp* p_srdsdt ; |
| 473 | /// Pointer on \f$1/(r\sin\theta) \partial/\partial \phi\f$ of \c *this |
| 474 | mutable Cmp* p_srstdsdp ; |
| 475 | |
| 476 | /** Pointer on \f$\partial/\partial x\f$ of \c *this , |
| 477 | * where \f$x=r\sin\theta \cos\phi\f$ |
| 478 | */ |
| 479 | mutable Cmp* p_dsdx ; |
| 480 | |
| 481 | /** Pointer on \f$\partial/\partial y\f$ of \c *this , |
| 482 | * where \f$y=r\sin\theta \sin\phi\f$ |
| 483 | */ |
| 484 | mutable Cmp* p_dsdy ; |
| 485 | |
| 486 | /** Pointer on \f$\partial/\partial z\f$ of \c *this , |
| 487 | * where \f$z=r\cos\theta\f$ |
| 488 | */ |
| 489 | mutable Cmp* p_dsdz ; |
| 490 | |
| 491 | /** Pointer on the Laplacian of \c *this |
| 492 | */ |
| 493 | mutable Cmp* p_lap ; |
| 494 | |
| 495 | /** Power of \e r by which the last computed Laplacian has been |
| 496 | * multiplied in the external compactified domain. |
| 497 | */ |
| 498 | mutable int ind_lap ; |
| 499 | |
| 500 | /** Pointer on the space integral of \c *this (values in each |
| 501 | * domain) |
| 502 | */ |
| 503 | mutable Tbl* p_integ ; |
| 504 | |
| 505 | // Constructors - Destructor |
| 506 | // ------------------------- |
| 507 | |
| 508 | public: |
| 509 | explicit Cmp(const Map& map) ; ///< Constructor from mapping |
| 510 | explicit Cmp(const Map* p_map) ; ///< Constructor from mapping |
| 511 | Cmp(const Cmp& a) ; ///< Copy constructor |
| 512 | |
| 513 | /// Constructor from a file (see \c sauve(FILE*) ) |
| 514 | Cmp(const Map&, const Mg3d&, FILE* ) ; |
| 515 | |
| 516 | ~Cmp() ; ///< Destructor |
| 517 | |
| 518 | // Assignment |
| 519 | // ----------- |
| 520 | public: |
| 521 | /// Assignment to another \c Cmp defined on the same mapping |
| 522 | void operator=(const Cmp& a) ; |
| 523 | |
| 524 | void operator=(const Valeur& a) ; ///< Assignment to a \c Valeur |
| 525 | void operator=(const Mtbl& a) ; ///< Assignment to a \c Mtbl |
| 526 | void operator=(double ) ; ///< Assignment to a \c double |
| 527 | void operator=(int ) ; ///< Assignment to an \c int |
| 528 | |
| 529 | /** Assignment to another \c Cmp defined on a different mapping. |
| 530 | * This assignment is performed point to point by means of the |
| 531 | * spectral expansion of the original \c Cmp . |
| 532 | * @param ci [input] \c Cmp to be imported. |
| 533 | */ |
| 534 | void import(const Cmp& ci) ; |
| 535 | |
| 536 | /** Assignment to another \c Cmp defined on a different mapping. |
| 537 | * Case where the \c Cmp is symmetric with respect to the plane y=0. |
| 538 | * This assignment is performed point to point by means of the |
| 539 | * spectral expansion of the original \c Cmp . |
| 540 | * @param ci [input] \c Cmp to be imported. |
| 541 | */ |
| 542 | void import_symy(const Cmp& ci) ; |
| 543 | |
| 544 | /** Assignment to another \c Cmp defined on a different mapping. |
| 545 | * Case where the \c Cmp is antisymmetric with respect to the |
| 546 | * plane y=0. |
| 547 | * This assignment is performed point to point by means of the |
| 548 | * spectral expansion of the original \c Cmp . |
| 549 | * @param ci [input] \c Cmp to be imported. |
| 550 | */ |
| 551 | void import_asymy(const Cmp& ci) ; |
| 552 | |
| 553 | /** Assignment to another \c Cmp defined on a different mapping. |
| 554 | * This assignment is performed point to point by means of the |
| 555 | * spectral expansion of the original \c Cmp . |
| 556 | * @param nzet [input] Number of domains of the destination |
| 557 | * mapping (i.e. \c this->mp ) where the |
| 558 | * importation is performed: the assignment |
| 559 | * is done for the domains whose indices are |
| 560 | * between 0 and \c nzet-1 . In the other |
| 561 | * domains, \c *this is set to zero. |
| 562 | * @param ci [input] \c Cmp to be imported. |
| 563 | */ |
| 564 | void import(int nzet, const Cmp& ci) ; |
| 565 | |
| 566 | /** Assignment to another \c Cmp defined on a different mapping. |
| 567 | * Case where the \c Cmp is symmetric with respect to the plane y=0. |
| 568 | * This assignment is performed point to point by means of the |
| 569 | * spectral expansion of the original \c Cmp . |
| 570 | * @param nzet [input] Number of domains of the destination |
| 571 | * mapping (i.e. \c this->mp ) where the |
| 572 | * importation is performed: the assignment |
| 573 | * is done for the domains whose indices are |
| 574 | * between 0 and \c nzet-1 . In the other |
| 575 | * domains, \c *this is set to zero. |
| 576 | * @param ci [input] \c Cmp to be imported. |
| 577 | */ |
| 578 | void import_symy(int nzet, const Cmp& ci) ; |
| 579 | |
| 580 | /** Assignment to another \c Cmp defined on a different mapping. |
| 581 | * Case where the \c Cmp is antisymmetric with respect to the |
| 582 | * plane y=0. |
| 583 | * This assignment is performed point to point by means of the |
| 584 | * spectral expansion of the original \c Cmp . |
| 585 | * @param nzet [input] Number of domains of the destination |
| 586 | * mapping (i.e. \c this->mp ) where the |
| 587 | * importation is performed: the assignment |
| 588 | * is done for the domains whose indices are |
| 589 | * between 0 and \c nzet-1 . In the other |
| 590 | * domains, \c *this is set to zero. |
| 591 | * @param ci [input] \c Cmp to be imported. |
| 592 | */ |
| 593 | void import_asymy(int nzet, const Cmp& ci) ; |
| 594 | |
| 595 | private: |
| 596 | /** Assignment to another \c Cmp defined on a different mapping, |
| 597 | * when the two mappings do not have a particular relative orientation. |
| 598 | * |
| 599 | * This assignment is performed point to point by means of the |
| 600 | * spectral expansion of the original \c Cmp . |
| 601 | * @param nzet [input] Number of domains of the destination |
| 602 | * mapping (i.e. \c this->mp ) where the |
| 603 | * importation is performed: the assignment |
| 604 | * is done for the domains whose indices are |
| 605 | * between 0 and \c nzet-1 . In the other |
| 606 | * domains, \c *this is set to zero. |
| 607 | * @param ci [input] \c Cmp to be imported. |
| 608 | */ |
| 609 | void import_gal(int nzet, const Cmp& ci) ; |
| 610 | |
| 611 | /** Assignment to another \c Cmp defined on a different mapping, |
| 612 | * when the two mappings have aligned Cartesian axis. |
| 613 | * |
| 614 | * This assignment is performed point to point by means of the |
| 615 | * spectral expansion of the original \c Cmp . |
| 616 | * @param nzet [input] Number of domains of the destination |
| 617 | * mapping (i.e. \c this->mp ) where the |
| 618 | * importation is performed: the assignment |
| 619 | * is done for the domains whose indices are |
| 620 | * between 0 and \c nzet-1 . In the other |
| 621 | * domains, \c *this is set to zero. |
| 622 | * @param ci [input] \c Cmp to be imported. |
| 623 | */ |
| 624 | void import_align(int nzet, const Cmp& ci) ; |
| 625 | |
| 626 | /** Assignment to another \c Cmp defined on a different mapping, |
| 627 | * when the two mappings have anti-aligned Cartesian axis (i.e. |
| 628 | * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$). |
| 629 | * |
| 630 | * This assignment is performed point to point by means of the |
| 631 | * spectral expansion of the original \c Cmp . |
| 632 | * @param nzet [input] Number of domains of the destination |
| 633 | * mapping (i.e. \c this->mp ) where the |
| 634 | * importation is performed: the assignment |
| 635 | * is done for the domains whose indices are |
| 636 | * between 0 and \c nzet-1 . In the other |
| 637 | * domains, \c *this is set to zero. |
| 638 | * @param ci [input] \c Cmp to be imported. |
| 639 | */ |
| 640 | void import_anti(int nzet, const Cmp& ci) ; |
| 641 | |
| 642 | /** Assignment to another \c Cmp defined on a different mapping, |
| 643 | * when the two mappings have aligned Cartesian axis. |
| 644 | * Case where the \c Cmp is symmetric with respect to the plane y=0. |
| 645 | * |
| 646 | * This assignment is performed point to point by means of the |
| 647 | * spectral expansion of the original \c Cmp . |
| 648 | * @param nzet [input] Number of domains of the destination |
| 649 | * mapping (i.e. \c this->mp ) where the |
| 650 | * importation is performed: the assignment |
| 651 | * is done for the domains whose indices are |
| 652 | * between 0 and \c nzet-1 . In the other |
| 653 | * domains, \c *this is set to zero. |
| 654 | * @param ci [input] \c Cmp to be imported. |
| 655 | */ |
| 656 | void import_align_symy(int nzet, const Cmp& ci) ; |
| 657 | |
| 658 | /** Assignment to another \c Cmp defined on a different mapping, |
| 659 | * when the two mappings have anti-aligned Cartesian axis (i.e. |
| 660 | * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$). |
| 661 | * Case where the \c Cmp is symmetric with respect to the plane y=0. |
| 662 | * |
| 663 | * This assignment is performed point to point by means of the |
| 664 | * spectral expansion of the original \c Cmp . |
| 665 | * @param nzet [input] Number of domains of the destination |
| 666 | * mapping (i.e. \c this->mp ) where the |
| 667 | * importation is performed: the assignment |
| 668 | * is done for the domains whose indices are |
| 669 | * between 0 and \c nzet-1 . In the other |
| 670 | * domains, \c *this is set to zero. |
| 671 | * @param ci [input] \c Cmp to be imported. |
| 672 | */ |
| 673 | void import_anti_symy(int nzet, const Cmp& ci) ; |
| 674 | |
| 675 | /** Assignment to another \c Cmp defined on a different mapping, |
| 676 | * when the two mappings have aligned Cartesian axis. |
| 677 | * Case where the \c Cmp is antisymmetric with respect to the |
| 678 | * plane y=0. |
| 679 | * |
| 680 | * This assignment is performed point to point by means of the |
| 681 | * spectral expansion of the original \c Cmp . |
| 682 | * @param nzet [input] Number of domains of the destination |
| 683 | * mapping (i.e. \c this->mp ) where the |
| 684 | * importation is performed: the assignment |
| 685 | * is done for the domains whose indices are |
| 686 | * between 0 and \c nzet-1 . In the other |
| 687 | * domains, \c *this is set to zero. |
| 688 | * @param ci [input] \c Cmp to be imported. |
| 689 | */ |
| 690 | void import_align_asymy(int nzet, const Cmp& ci) ; |
| 691 | |
| 692 | /** Assignment to another \c Cmp defined on a different mapping, |
| 693 | * when the two mappings have anti-aligned Cartesian axis (i.e. |
| 694 | * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$). |
| 695 | * Case where the \c Cmp is antisymmetric with respect to the |
| 696 | * plane y=0. |
| 697 | * |
| 698 | * This assignment is performed point to point by means of the |
| 699 | * spectral expansion of the original \c Cmp . |
| 700 | * @param nzet [input] Number of domains of the destination |
| 701 | * mapping (i.e. \c this->mp ) where the |
| 702 | * importation is performed: the assignment |
| 703 | * is done for the domains whose indices are |
| 704 | * between 0 and \c nzet-1 . In the other |
| 705 | * domains, \c *this is set to zero. |
| 706 | * @param ci [input] \c Cmp to be imported. |
| 707 | */ |
| 708 | void import_anti_asymy(int nzet, const Cmp& ci) ; |
| 709 | |
| 710 | |
| 711 | |
| 712 | // Access to individual elements |
| 713 | // ----------------------------- |
| 714 | public: |
| 715 | |
| 716 | /** Read/write of the value in a given domain. |
| 717 | * NB: to gain in efficiency, the method \c del_deriv() (to delete |
| 718 | * the derived members) is not called by this function. It must |
| 719 | * thus be invoqued by the user. |
| 720 | * |
| 721 | * @param l [input] domain index |
| 722 | * @return Tbl containing the value of the field in domain \c l . |
| 723 | */ |
| 724 | Tbl& set(int l) { |
| 725 | assert(etat == ETATQCQ) ; |
| 726 | return va.set(l) ; |
| 727 | }; |
| 728 | |
| 729 | /** Read-only of the value in a given domain. |
| 730 | * @param l [input] domain index |
| 731 | * @return Tbl containing the value of the field in domain \c l . |
| 732 | */ |
| 733 | const Tbl& operator()(int l) const { |
| 734 | assert(etat == ETATQCQ) ; |
| 735 | return va(l) ; |
| 736 | }; |
| 737 | |
| 738 | |
| 739 | /** Read/write of a particular element. |
| 740 | * NB: to gain in efficiency, the method \c del_deriv() (to delete |
| 741 | * the derived members) is not called by this function. It must |
| 742 | * thus be invoqued by the user. |
| 743 | * |
| 744 | * @param l [input] domain index |
| 745 | * @param k [input] \f$\phi\f$ index |
| 746 | * @param j [input] \f$\theta\f$ index |
| 747 | * @param i [input] \e r (\f$\xi\f$) index |
| 748 | */ |
| 749 | double& set(int l, int k, int j, int i) { |
| 750 | assert(etat == ETATQCQ) ; |
| 751 | return va.set(l, k, j, i) ; |
| 752 | }; |
| 753 | |
| 754 | |
| 755 | /** Read-only of a particular element. |
| 756 | * @param l [input] domain index |
| 757 | * @param k [input] \f$\phi\f$ index |
| 758 | * @param j [input] \f$\theta\f$ index |
| 759 | * @param i [input] \e r (\f$\xi\f$) index |
| 760 | */ |
| 761 | double operator()(int l, int k, int j, int i) const { |
| 762 | assert(etat != ETATNONDEF) ; |
| 763 | if (etat == ETATZERO) { |
| 764 | double zero = 0. ; |
| 765 | return zero ; |
| 766 | } |
| 767 | else{ |
| 768 | return va(l, k, j, i) ; |
| 769 | } |
| 770 | }; |
| 771 | |
| 772 | /** Computes the value of the field represented by \c *this at an |
| 773 | * arbitrary point \f$(r, \theta, \phi)\f$, by means of the spectral |
| 774 | * expansion. |
| 775 | * @param r [input] value of the coordinate \e r |
| 776 | * @param theta [input] value of the coordinate \f$\theta\f$ |
| 777 | * @param phi [input] value of the coordinate \f$\phi\f$ |
| 778 | * @return value at the point \f$(r, \theta, \phi)\f$ |
| 779 | * of the field represented by \c *this . |
| 780 | */ |
| 781 | double val_point(double r, double theta, double phi) const ; |
| 782 | |
| 783 | |
| 784 | // Memory management |
| 785 | // ----------------- |
| 786 | private: |
| 787 | void del_t() ; ///< Logical destructor |
| 788 | void del_deriv() ; ///< Logical destructor of the derivatives |
| 789 | void set_der_0x0() ; ///< Sets the pointers for derivatives to 0x0 |
| 790 | |
| 791 | public: |
| 792 | |
| 793 | /** |
| 794 | * Sets the logical state to \c ETATNONDEF (undefined). |
| 795 | * Calls the logical destructor of the \c Valeur \c va and |
| 796 | * deallocates the memory occupied by all the derivatives. |
| 797 | */ |
| 798 | void set_etat_nondef() ; |
| 799 | |
| 800 | /** |
| 801 | * Sets the logical state to \c ETATZERO (zero). |
| 802 | * Calls the logical destructor of the \c Valeur \c va and |
| 803 | * deallocates the memory occupied by all the derivatives. |
| 804 | */ |
| 805 | void set_etat_zero() ; |
| 806 | |
| 807 | /** |
| 808 | * Sets the logical state to \c ETATQCQ (ordinary state). |
| 809 | * If the state is already \c ETATQCQ , this function does nothing. |
| 810 | * Otherwise, it calls the logical destructor of the \c Valeur \c va and |
| 811 | * deallocates the memory occupied by all the derivatives. |
| 812 | */ |
| 813 | void set_etat_qcq() ; |
| 814 | |
| 815 | /** |
| 816 | * Sets the logical state to \c ETATQCQ (ordinary state) |
| 817 | * and performs the memory allocation of all the |
| 818 | * elements, down to the \c double arrays of the \c Tbl s. |
| 819 | * This function performs in fact recursive calls to \c set_etat_qcq() |
| 820 | * on each element of the chain \c Cmp -> |
| 821 | * \c Valeur -> \c Mtbl -> \c Tbl . |
| 822 | */ |
| 823 | void allocate_all() ; |
| 824 | |
| 825 | /** |
| 826 | * Sets the \c Cmp to zero in a hard way. |
| 827 | * 1/ Sets the logical state to \c ETATQCQ , i.e. to an ordinary state. |
| 828 | * 2/ Fills the \c Valeur \c va with zeros. |
| 829 | * NB: this function must be used for debugging purposes only. |
| 830 | * For other operations, the functions \c set_etat_zero() |
| 831 | * or \c annule(int, int) must be perferred. |
| 832 | */ |
| 833 | void annule_hard() ; |
| 834 | |
| 835 | /** |
| 836 | * Sets the \c Cmp to zero in a given domain. |
| 837 | * @param l [input] Index of the domain in which the \c Cmp |
| 838 | * will be set (logically) to zero. |
| 839 | */ |
| 840 | void annule(int l) ; |
| 841 | |
| 842 | /** |
| 843 | * Sets the \c Cmp to zero in several domains. |
| 844 | * @param l_min [input] The \c Cmp will be set (logically) to zero |
| 845 | * in the domains whose indices are in the range |
| 846 | * \c [l_min,l_max]. |
| 847 | * @param l_max [input] see the comments for \c l_min . |
| 848 | * |
| 849 | * Note that \c annule(0,va.mg->get_nzone()-1) is equivalent to |
| 850 | * \c set_etat_zero() . |
| 851 | */ |
| 852 | void annule(int l_min, int l_max) ; |
| 853 | |
| 854 | /** |
| 855 | * Sets the \c n lasts coefficients in \e r to 0 in the external domain. |
| 856 | */ |
| 857 | void filtre (int n) ; |
| 858 | |
| 859 | /** |
| 860 | * Sets the \c n lasts coefficients in \f$\Phi\f$ to 0 in the |
| 861 | * domain \c zone . |
| 862 | */ |
| 863 | void filtre_phi (int n, int zone) ; |
| 864 | |
| 865 | /** |
| 866 | * Sets the value of the \c Cmp to \c val at infinity. This is usefull |
| 867 | * for dealing with undefined values. The external domain must be |
| 868 | * compactified. |
| 869 | */ |
| 870 | void set_val_inf (double val) ; |
| 871 | |
| 872 | /** |
| 873 | * Sets the value of the \c Cmp to \c val on the inner boudary of the |
| 874 | * shell number \c zone .This is usefull |
| 875 | * for dealing with undefined values. |
| 876 | */ |
| 877 | void set_val_hor (double val, int zone) ; |
| 878 | /** |
| 879 | * Substracts all the components behaving like \f$r^{-n}\f$ in the external |
| 880 | * domain, with \e n strictly lower than \c puis , so that \c *this |
| 881 | * decreases at least like \f$r^{\tt puis} \f$ at infinity. |
| 882 | */ |
| 883 | void fixe_decroissance (int puis) ; |
| 884 | |
| 885 | /** |
| 886 | * Gives the spectrum in terms of multipolar modes \e l . |
| 887 | * @return a \c Tbl of size (nzone, lmax), where lmax is the |
| 888 | * maximal multipolar momentum over all domains. The \e l -th |
| 889 | * element contains the L1 norm of the \e l -th multipole |
| 890 | * (i.e. a sum over all \e m of the norms (coefficient space) |
| 891 | * of the component of a given \f$Y_l^m\f$. |
| 892 | */ |
| 893 | Tbl multipole_spectrum () ; |
| 894 | |
| 895 | // Extraction of information |
| 896 | // ------------------------- |
| 897 | public: |
| 898 | /// Returns the logical state |
| 899 | int get_etat() const {return etat;} ; |
| 900 | /// Returns the mapping |
| 901 | const Map* get_mp() const {return mp;}; |
| 902 | /// Returns \c dzpuis |
| 903 | int get_dzpuis() const {return dzpuis;} ; |
| 904 | |
| 905 | /** Returns \c true if the last domain is compactified and |
| 906 | * \c *this is not zero in this domain |
| 907 | */ |
| 908 | bool dz_nonzero() const ; |
| 909 | |
| 910 | /** Returns \c false if the last domain is compactified |
| 911 | * and \c *this is not zero in this domain and \c dzpuis |
| 912 | * is not equal to \c dzi , otherwise return true. |
| 913 | */ |
| 914 | bool check_dzpuis(int dzi) const ; |
| 915 | |
| 916 | |
| 917 | // Outputs |
| 918 | // ------- |
| 919 | public: |
| 920 | void sauve(FILE *) const ; ///< Save in a file |
| 921 | |
| 922 | /** Prints only the values greater than a given threshold. |
| 923 | * @param ostr [input] Output stream used for the printing |
| 924 | * @param type [input] Type of display : 0 = prints only the |
| 925 | * coefficients, 1 = prints only the values in configuration |
| 926 | * space, 2 = prints both |
| 927 | * @param precision [input] Number of printed digits (default: 4) |
| 928 | * @param threshold [input] Value above which an array element is printed |
| 929 | * (default: 1.e-7) |
| 930 | */ |
| 931 | void affiche_seuil(ostream& ostr, int type = 0, int precision = 4, |
| 932 | double threshold = 1.e-7) const ; |
| 933 | |
| 934 | /// Display |
| 935 | friend ostream& operator<<(ostream& , const Cmp & ) ; |
| 936 | |
| 937 | |
| 938 | // Member arithmetics |
| 939 | // ------------------ |
| 940 | public: |
| 941 | void operator+=(const Cmp &) ; ///< += Cmp |
| 942 | void operator-=(const Cmp &) ; ///< -= Cmp |
| 943 | void operator*=(const Cmp &) ; ///< *= Cmp |
| 944 | |
| 945 | // Manipulation of spectral bases |
| 946 | // ------------------------------ |
| 947 | /** Sets the spectral bases of the \c Valeur \c va to the standard ones |
| 948 | * for a scalar |
| 949 | */ |
| 950 | void std_base_scal() ; |
| 951 | |
| 952 | |
| 953 | // Differential operators and others |
| 954 | // --------------------------------- |
| 955 | public: |
| 956 | /** Returns \f$\partial / \partial r\f$ of \c *this . |
| 957 | * Note that in the external compactified domain (ZEC), it returns |
| 958 | * instead \f$r^2 \partial/ \partial r\f$. |
| 959 | */ |
| 960 | const Cmp& dsdr() const ; |
| 961 | |
| 962 | /** Returns \f$1/r \partial / \partial \theta\f$ of \c *this . |
| 963 | * Note that in the external compactified domain (ZEC), it returns |
| 964 | * instead \f$r \partial/ \partial \theta\f$. |
| 965 | */ |
| 966 | const Cmp& srdsdt() const ; |
| 967 | |
| 968 | /** Returns \f$1/(r\sin\theta) \partial / \partial \phi\f$ of \c *this . |
| 969 | * Note that in the external compactified domain (ZEC), it returns |
| 970 | * instead \f$r/\sin\theta \partial/ \partial \phi\f$. |
| 971 | */ |
| 972 | const Cmp& srstdsdp() const ; |
| 973 | |
| 974 | /** Returns \f$\partial/\partial x\f$ of \c *this , |
| 975 | * where \f$x=r\sin\theta \cos\phi\f$. |
| 976 | * Note that in the external compactified domain (ZEC), it returns |
| 977 | * instead \f$r^2 \partial/ \partial x\f$. |
| 978 | */ |
| 979 | const Cmp& dsdx() const ; |
| 980 | |
| 981 | /** Returns \f$\partial/\partial y\f$ of \c *this , |
| 982 | * where \f$y=r\sin\theta \sin\phi\f$. |
| 983 | * Note that in the external compactified domain (ZEC), it returns |
| 984 | * instead \f$r^2 \partial/ \partial y\f$. |
| 985 | */ |
| 986 | const Cmp& dsdy() const ; |
| 987 | |
| 988 | /** Returns \f$\partial/\partial z\f$ of \c *this , |
| 989 | * where \f$z=r\cos\theta\f$. |
| 990 | * Note that in the external compactified domain (ZEC), it returns |
| 991 | * instead \f$r^2 \partial/ \partial z\f$. |
| 992 | */ |
| 993 | const Cmp& dsdz() const ; |
| 994 | |
| 995 | /** Returns \f$\partial/\partial x_i\f$ of \c *this , |
| 996 | * where \f$x_i = (x, y, z)\f$. |
| 997 | * Note that in the external compactified domain (ZEC), it returns |
| 998 | * instead \f$r^2 \partial/ \partial x_i\f$. |
| 999 | * @param i [input] i=0 for \e x , i=1 for \e y , i=2 for \e z . |
| 1000 | */ |
| 1001 | const Cmp& deriv(int i) const ; |
| 1002 | |
| 1003 | /** Returns the Laplacian of \c *this |
| 1004 | * @param zec_mult_r [input] Determines the quantity computed in |
| 1005 | * the external compactified domain (ZEC) |
| 1006 | * (\e u in the field represented by \c *this ) : \\ |
| 1007 | * zec_mult_r = 0 : \f$\Delta u\f$ \\ |
| 1008 | * zec_mult_r = 2 : \f$r^2 \, \Delta u\f$ \\ |
| 1009 | * zec_mult_r = 4 (default) : \f$r^4 \, \Delta u\f$ |
| 1010 | */ |
| 1011 | const Cmp& laplacien(int zec_mult_r = 4) const ; |
| 1012 | |
| 1013 | /// Division by \e r everywhere. |
| 1014 | void div_r() ; |
| 1015 | |
| 1016 | /// Multiplication by \e r everywhere. |
| 1017 | void mult_r() ; |
| 1018 | |
| 1019 | /** Multiplication by \e r in the external compactified domain (ZEC) |
| 1020 | */ |
| 1021 | void mult_r_zec() ; |
| 1022 | |
| 1023 | /// Multiplication by \f$r\sin\theta\f$ |
| 1024 | void mult_rsint() ; |
| 1025 | |
| 1026 | /// Multiplication by \f\cos\theta\f$ |
| 1027 | void mult_cost() ; |
| 1028 | |
| 1029 | /// Division by \f$r\sin\theta\f$ |
| 1030 | void div_rsint() ; |
| 1031 | |
| 1032 | /** Decreases by 1 the value of \c dzpuis and changes accordingly |
| 1033 | * the values of the \c Cmp in the external compactified domain (ZEC). |
| 1034 | */ |
| 1035 | void dec_dzpuis() ; |
| 1036 | |
| 1037 | /** Increases by the value of \c dzpuis and changes accordingly |
| 1038 | * the values of the \c Cmp in the external compactified domain (ZEC). |
| 1039 | */ |
| 1040 | void inc_dzpuis() ; |
| 1041 | |
| 1042 | /** Decreases by 2 the value of \c dzpuis and changes accordingly |
| 1043 | * the values of the \c Cmp in the external compactified domain (ZEC). |
| 1044 | */ |
| 1045 | void dec2_dzpuis() ; |
| 1046 | |
| 1047 | /** Increases by 2 the value of \c dzpuis and changes accordingly |
| 1048 | * the values of the \c Cmp in the external compactified domain (ZEC). |
| 1049 | */ |
| 1050 | void inc2_dzpuis() ; |
| 1051 | |
| 1052 | void set_dzpuis(int ) ; ///< Set a value to \c dzpuis |
| 1053 | |
| 1054 | /** Computes the integral over all space of \c *this . |
| 1055 | * The computed quantity is (\e u being the field represented by |
| 1056 | * \c *this ) |
| 1057 | * \f$\int u \, r^2 \sin\theta \, dr\, d\theta \, d\phi\f$. |
| 1058 | * Note that in the external compactified domain (ZEC), \c dzpuis |
| 1059 | * must be 4 for the computation to take place. |
| 1060 | */ |
| 1061 | double integrale() const ; |
| 1062 | |
| 1063 | /** Computes the integral in each domain of \c *this . |
| 1064 | * The computed quantity is (\e u being the field represented by |
| 1065 | * \c *this ) |
| 1066 | * \f$\int u \, r^2 \sin\theta \, dr\, d\theta \, d\phi\f$ |
| 1067 | * in each domain. The result is returned a \c Tbl on the |
| 1068 | * various domains. |
| 1069 | * Note that in the external compactified domain (ZEC), \c dzpuis |
| 1070 | * must be 4 for the computation to take place. |
| 1071 | */ |
| 1072 | const Tbl& integrale_domains() const ; |
| 1073 | |
| 1074 | /** Asymptotic expansion at r = infinity. |
| 1075 | * |
| 1076 | * Determines the coefficients \f$a_k(\theta, \phi)\f$ of the expansion |
| 1077 | * \f[ |
| 1078 | * \sum_{k=0}^n {a_k(\theta, \phi) \over r^k} |
| 1079 | * \f] |
| 1080 | * of \c *this when \f$r \rightarrow \infty\f$. |
| 1081 | * |
| 1082 | * @param n order of the expansion |
| 1083 | * @param flag : output |
| 1084 | * @return Array of n+1 \c Valeur s on \c mg->angu |
| 1085 | * describing the coefficients \f$a_k(\theta, \phi)\f$. |
| 1086 | * This array is allocated by the routine. |
| 1087 | * |
| 1088 | */ |
| 1089 | Valeur** asymptot(int n, const int flag = 0) const ; |
| 1090 | |
| 1091 | |
| 1092 | // PDE resolution |
| 1093 | // -------------- |
| 1094 | public: |
| 1095 | /** Solves the scalar Poisson equation with \c *this as a source. |
| 1096 | * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is |
| 1097 | * represented by the \c Cmp \c *this . |
| 1098 | * Note that \c dzpuis must be equal to 2, 3 or 4, i.e. that the |
| 1099 | * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or |
| 1100 | * \f$r^4 \sigma\f$ in the external compactified domain. |
| 1101 | * The solution \e u with the boundary condition \e u =0 at spatial |
| 1102 | * infinity is the returned \c Cmp . |
| 1103 | */ |
| 1104 | Cmp poisson() const ; |
| 1105 | |
| 1106 | /** Same as Poisson with a Tau method |
| 1107 | */ |
| 1108 | Cmp poisson_tau() const ; |
| 1109 | |
| 1110 | Cmp poisson_falloff(int k_falloff) const ; |
| 1111 | |
| 1112 | Cmp poisson_ylm(int nylm, double* intvec) const ; |
| 1113 | |
| 1114 | /** Solves the scalar Poisson equation with \c *this as a source |
| 1115 | * (version with parameters to control the resolution). |
| 1116 | * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is |
| 1117 | * represented by the \c Cmp \c *this . |
| 1118 | * Note that \c dzpuis must be equal to 2 or 4, i.e. that the |
| 1119 | * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or |
| 1120 | * \f$r^4 \sigma\f$ in the external compactified domain. |
| 1121 | * @param par [input/output] possible parameters |
| 1122 | * @param uu [input/output] solution \e u with the boundary condition |
| 1123 | * \e u =0 at spatial infinity. |
| 1124 | */ |
| 1125 | void poisson(Param& par, Cmp& uu) const ; |
| 1126 | |
| 1127 | /** Same as Poisson with a Tau method |
| 1128 | */ |
| 1129 | void poisson_tau(Param& par, Cmp& uu) const ; |
| 1130 | |
| 1131 | void poisson_falloff(Param& par, Cmp& uu, int k_falloff) const ; |
| 1132 | |
| 1133 | void poisson_ylm(Param& par, Cmp& uu, int nylm, double* intvec) const ; |
| 1134 | |
| 1135 | /** |
| 1136 | * Is identicall to \c Cmp::poisson() . The regularity condition at the |
| 1137 | * origin is replace by a boundary condition of the Dirichlet type. |
| 1138 | * |
| 1139 | * @param limite [input] : angular function. The boundary condition is |
| 1140 | * given by \c limite[num] . |
| 1141 | * @param num [input] : index of the boudary at which the condition is to |
| 1142 | * be fullfilled. |
| 1143 | * |
| 1144 | * More precisely we impose the solution is equal to \c limite[num] at the |
| 1145 | * boundary between the domains \c num and \c num+1 (the latter one being |
| 1146 | * a shell). |
| 1147 | * |
| 1148 | */ |
| 1149 | Cmp poisson_dirichlet (const Valeur& limite, int num) const ; |
| 1150 | |
| 1151 | /** |
| 1152 | * Idem as \c Cmp::poisson_dirichlet , the boundary condition being on |
| 1153 | * the radial derivative of the solution. |
| 1154 | */ |
| 1155 | Cmp poisson_neumann (const Valeur&, int) const ; |
| 1156 | |
| 1157 | /** |
| 1158 | * Idem as \c Cmp::poisson_neumann , the boundary condition is on |
| 1159 | * the radial derivative of the solution. But in this method, the |
| 1160 | * poisson equation is solved in the shell only. We have so to |
| 1161 | * impose a boundary condition on the surface of the star. |
| 1162 | * This is used for example to solve the continuity equation |
| 1163 | * for the fluid in the star. |
| 1164 | */ |
| 1165 | Cmp poisson_neumann_interne (const Valeur&, Param& par, Cmp& resu) const ; |
| 1166 | Cmp poisson_frontiere_double (const Valeur&, const Valeur&, int) const ; |
| 1167 | |
| 1168 | /** Solves the scalar Poisson equation with \c *this as a source |
| 1169 | * (version with parameters to control the resolution). |
| 1170 | * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is |
| 1171 | * represented by the \c Cmp \c *this . |
| 1172 | * The regularized source |
| 1173 | * \f$\sigma_{\rm regu} = \sigma - \sigma_{\rm div}\f$ |
| 1174 | * is constructed and solved. |
| 1175 | * Note that \c dzpuis must be equal to 2 or 4, i.e. that the |
| 1176 | * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or |
| 1177 | * \f$r^4 \sigma\f$ in the external compactified domain. |
| 1178 | * @param k_div [input] regularization degree of the procedure |
| 1179 | * @param nzet [input] number of domains covering the star |
| 1180 | * @param unsgam1 [input] parameter \f$1/(\gamma-1)\f$ where \f$\gamma\f$ |
| 1181 | * denotes the adiabatic index |
| 1182 | * @param par [input/output] possible parameters |
| 1183 | @param uu [input/output] solution |
| 1184 | * @param uu_regu [output] solution of the regular part of |
| 1185 | * the source. |
| 1186 | * @param uu_div [output] solution of the diverging part of |
| 1187 | * the source. |
| 1188 | * @param duu_div [output] derivative of the diverging potential. |
| 1189 | * @param source_regu [output] regularized source |
| 1190 | * @param source_div [output] diverging part of the source |
| 1191 | */ |
| 1192 | void poisson_regular(int k_div, int nzet, double unsgam1, Param& par, |
| 1193 | Cmp& uu, Cmp& uu_regu, Cmp& uu_div, |
| 1194 | Tenseur& duu_div, |
| 1195 | Cmp& source_regu, Cmp& source_div) const ; |
| 1196 | |
| 1197 | /** Checks if a Poisson equation with \c *this as a source |
| 1198 | * has been correctly solved. |
| 1199 | * |
| 1200 | * @param uu [input] Solution \e u of the Poisson equation |
| 1201 | * \f$\Delta u = \sigma\f$, \f$\sigma\f$ being |
| 1202 | * represented by the \c Cmp \c *this . |
| 1203 | * |
| 1204 | * @param ostr [input/output] Output stream used for displaying |
| 1205 | * \c err . |
| 1206 | * |
| 1207 | * @param detail [input] \li if \c true displays \c err(0,*) , |
| 1208 | * \c err(1,*) and \c err(2,*) |
| 1209 | * \li if \c false (default), displays only |
| 1210 | * the relative error \c err(0,*). |
| 1211 | * |
| 1212 | * @return 2-D \c Tbl \c err decribing the errors in each |
| 1213 | * domain: |
| 1214 | * \li \c err(0,l) : Relative error in domain no. \c l , |
| 1215 | * defined as the maximum value of |
| 1216 | * \f$|\Delta u - \sigma|\f$ in that domain divided by \e m , |
| 1217 | * where \e m is the maximum value of \f$|\sigma|\f$ |
| 1218 | * over all domains if \c dzpuis = 0} or \f$\sigma\f$ is |
| 1219 | * zero in the external compactified domain (ECD). If |
| 1220 | * \c dzpuis != 0} and \f$\sigma\f$ does not vanish in the |
| 1221 | * ECD, the value of \e m used in the |
| 1222 | * non-compactified domains is the maximum value over |
| 1223 | * these domains, whereas the value of \e m used in the |
| 1224 | * external compactified domain is the maximum value |
| 1225 | * on that particular domain. |
| 1226 | * \li \c err(1,l) : Maximum value of the absolute error |
| 1227 | * \f$|\Delta u - \sigma|\f$ in domain no. \c l |
| 1228 | * \li \c err(2,l) : Maximum value of \f$|\sigma|\f$ in domain |
| 1229 | * no. \c l |
| 1230 | */ |
| 1231 | Tbl test_poisson(const Cmp& uu, ostream& ostr, |
| 1232 | bool detail = false) const ; |
| 1233 | /** |
| 1234 | * Performs the \f$C^n\f$ matching of the nucleus with respect to the |
| 1235 | * first shell. |
| 1236 | */ |
| 1237 | void raccord(int n) ; |
| 1238 | |
| 1239 | /** |
| 1240 | * Performs the \f$C^1\f$ matching of the external domain with respect to |
| 1241 | * the last shell using function like \f$\frac{1}{r^i}\f$ with |
| 1242 | * \f${\tt puis} \leq i \leq {\tt puis+nbre}\f$ for each spherical harmonics |
| 1243 | * with \f$l \leq {\tt lmax}\f$. |
| 1244 | */ |
| 1245 | void raccord_c1_zec (int puis, int nbre, int lmax) ; |
| 1246 | /** |
| 1247 | * Matching of the external domain with the outermost shell |
| 1248 | */ |
| 1249 | void raccord_externe (int puis, int nbre, int lmax) ; |
| 1250 | }; |
| 1251 | ostream& operator<<(ostream& , const Cmp & ) ; |
| 1252 | |
| 1253 | /** |
| 1254 | * \defgroup cmp_m Cmp Mathematics |
| 1255 | * \ingroup (otens) |
| 1256 | * @{ |
| 1257 | */ |
| 1258 | |
| 1259 | Cmp operator+(const Cmp& ) ; ///< + Cmp |
| 1260 | Cmp operator-(const Cmp& ) ; ///< \c - Cmp |
| 1261 | Cmp operator+(const Cmp&, const Cmp &) ; ///< Cmp + Cmp |
| 1262 | Cmp operator+(const Cmp&, double ) ; ///< Cmp + double |
| 1263 | Cmp operator+(double, const Cmp& ) ; ///< double + Cmp |
| 1264 | Cmp operator+(const Cmp&, int ) ; ///< Cmp + int |
| 1265 | Cmp operator+(int, const Cmp& ) ; ///< int + Cmp |
| 1266 | Cmp operator-(const Cmp &, const Cmp &) ; ///< Cmp - Cmp |
| 1267 | Cmp operator-(const Cmp&, double ) ; ///< Cmp - double |
| 1268 | Cmp operator-(double, const Cmp& ) ; ///< double - Cmp |
| 1269 | Cmp operator-(const Cmp&, int ) ; ///< Cmp - int |
| 1270 | Cmp operator-(int, const Cmp& ) ; ///< int - Cmp |
| 1271 | Cmp operator*(const Cmp &, const Cmp &) ; ///< Cmp * Cmp |
| 1272 | Cmp operator%(const Cmp &, const Cmp &) ; ///< Cmp * Cmp with desaliasing |
| 1273 | Cmp operator*(const Cmp&, double ) ; ///< Cmp * double |
| 1274 | Cmp operator*(double, const Cmp &) ; ///< double * Cmp |
| 1275 | Cmp operator*(const Cmp&, int ) ; ///< Cmp * int |
| 1276 | Cmp operator*(int, const Cmp& ) ; ///< int * Cmp |
| 1277 | Cmp operator/(const Cmp &, const Cmp &) ; ///< Cmp / Cmp |
| 1278 | Cmp operator/(const Cmp&, double ) ; ///< Cmp / double |
| 1279 | Cmp operator/(double, const Cmp &) ; ///< double / Cmp |
| 1280 | Cmp operator/(const Cmp&, int ) ; ///< Cmp / int |
| 1281 | Cmp operator/(int, const Cmp &) ; ///< int / Cmp |
| 1282 | |
| 1283 | Cmp sin(const Cmp& ) ; ///< Sine |
| 1284 | Cmp cos(const Cmp& ) ; ///< Cosine |
| 1285 | Cmp tan(const Cmp& ) ; ///< Tangent |
| 1286 | Cmp asin(const Cmp& ) ; ///< Arcsine |
| 1287 | Cmp acos(const Cmp& ) ; ///< Arccosine |
| 1288 | Cmp atan(const Cmp& ) ; ///< Arctangent |
| 1289 | Cmp exp(const Cmp& ) ; ///< Exponential |
| 1290 | Cmp log(const Cmp& ) ; ///< Neperian logarithm |
| 1291 | Cmp log10(const Cmp& ) ; ///< Basis 10 logarithm |
| 1292 | Cmp sqrt(const Cmp& ) ; ///< Square root |
| 1293 | Cmp racine_cubique (const Cmp& ) ; ///< Cube root |
| 1294 | Cmp pow(const Cmp& , int ) ; ///< Power \f${\tt Cmp} ^{\tt int}\f$ |
| 1295 | Cmp pow(const Cmp& , double ) ; ///< Power \f${\tt Cmp} ^{\tt double}\f$ |
| 1296 | Cmp abs(const Cmp& ) ; ///< Absolute value |
| 1297 | |
| 1298 | /** |
| 1299 | * Maximum values of a \c Cmp in each domain. |
| 1300 | * @return 1-D \c Tbl of size the number of domains, the elements of which |
| 1301 | * are the set of the maximum values in each domain. |
| 1302 | */ |
| 1303 | Tbl max(const Cmp& ) ; |
| 1304 | |
| 1305 | /** |
| 1306 | * Minimum values of a \c Cmp in each domain. |
| 1307 | * @return 1-D \c Tbl of size the number of domains, the elements of which |
| 1308 | * are the set of the minimum values in each domain. |
| 1309 | */ |
| 1310 | Tbl min(const Cmp& ) ; |
| 1311 | |
| 1312 | /** |
| 1313 | * Sums of the absolute values of all the values of the \c Cmp |
| 1314 | * in each domain. |
| 1315 | * @return 1-D \c Tbl of size the number of domains, the elements of which |
| 1316 | * are the set of the sums of the absolute values in each domain. |
| 1317 | */ |
| 1318 | Tbl norme(const Cmp& ) ; |
| 1319 | |
| 1320 | /** |
| 1321 | * Relative difference between two \c Cmp (norme version). |
| 1322 | * @return 1-D \c Tbl of size the number of domains, the elements of which |
| 1323 | * are \c norme[a(l)-b(l)]/norme[b(l)] if \c b(l)!=0 and |
| 1324 | * \c norme[a(l)-b(l)] if \c b(l)=0 , where \c a(l) and |
| 1325 | * \c b(l) denote symbolically the values of \c a and \c b |
| 1326 | * in domain no. \c l . |
| 1327 | */ |
| 1328 | Tbl diffrel(const Cmp& a, const Cmp& b) ; |
| 1329 | |
| 1330 | /** |
| 1331 | * Relative difference between two \c Cmp (max version). |
| 1332 | * @return 1-D \c Tbl of size the number of domains, the elements of which |
| 1333 | * are \c max[abs(a(l)-b(l))]/max[abs(b(l))] if \c b(l)!=0 and |
| 1334 | * \c max[abs(a(l)-b(l))] if \c b(l)=0 , where \c a(l) and |
| 1335 | * \c b(l) denote symbolically the values of \c a and \c b |
| 1336 | * in domain no. \c l . |
| 1337 | */ |
| 1338 | Tbl diffrelmax(const Cmp& a, const Cmp& b) ; |
| 1339 | |
| 1340 | /** @}*/ |
| 1341 | |
| 1342 | } |
| 1343 | #endif |