| 1 | /* |
| 2 | * Definition of Lorene class Vector |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak |
| 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 version 2 |
| 13 | * as published by the Free Software Foundation. |
| 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 | #ifndef __VECTOR_H_ |
| 27 | #define __VECTOR_H_ |
| 28 | |
| 29 | /* |
| 30 | * $Id: vector.h,v 1.42 2014/10/13 08:52:37 j_novak Exp $ |
| 31 | * $Log: vector.h,v $ |
| 32 | * Revision 1.42 2014/10/13 08:52:37 j_novak |
| 33 | * Lorene classes and functions now belong to the namespace Lorene. |
| 34 | * |
| 35 | * Revision 1.41 2008/12/03 10:18:56 j_novak |
| 36 | * Method 6 is now the default for calls to vector Poisson solver. |
| 37 | * |
| 38 | * Revision 1.40 2008/10/29 08:19:08 jl_cornou |
| 39 | * Typo in the doxygen documentation + spectral bases for pseudo vectors added |
| 40 | * and curl |
| 41 | * |
| 42 | * Revision 1.39 2008/08/27 08:45:21 jl_cornou |
| 43 | * Implemented routines to solve dirac systems for divergence-free vectors |
| 44 | * |
| 45 | * Revision 1.38 2007/12/21 16:06:16 j_novak |
| 46 | * Methods to filter Tensor, Vector and Sym_tensor objects. |
| 47 | * |
| 48 | * Revision 1.37 2007/05/11 11:38:16 n_vasset |
| 49 | * Added poisson_boundary2.C routine |
| 50 | * |
| 51 | * Revision 1.36 2007/01/16 15:05:59 n_vasset |
| 52 | * New constructor (taking a Scalar in mono-domain angular grid for |
| 53 | * boundary) for function sol_elliptic_boundary |
| 54 | * |
| 55 | * Revision 1.35 2005/06/09 07:56:25 f_limousin |
| 56 | * Implement a new function sol_elliptic_boundary() and |
| 57 | * Vector::poisson_boundary(...) which solve the vectorial poisson |
| 58 | * equation (method 6) with an inner boundary condition. |
| 59 | * |
| 60 | * Revision 1.34 2005/02/16 15:00:05 m_forot |
| 61 | * Add visu_streamlime function |
| 62 | * |
| 63 | * Revision 1.33 2005/02/14 13:01:48 j_novak |
| 64 | * p_eta and p_mu are members of the class Vector. Most of associated functions |
| 65 | * have been moved from the class Vector_divfree to the class Vector. |
| 66 | * |
| 67 | * Revision 1.32 2004/05/25 14:54:01 f_limousin |
| 68 | * Change arguments of method poisson with parameters. |
| 69 | * |
| 70 | * Revision 1.31 2004/05/09 20:54:22 e_gourgoulhon |
| 71 | * Added method flux (to compute the flux accross a sphere). |
| 72 | * |
| 73 | * Revision 1.30 2004/03/29 11:57:13 e_gourgoulhon |
| 74 | * Added methods ope_killing and ope_killing_conf. |
| 75 | * |
| 76 | * Revision 1.29 2004/03/28 21:25:14 e_gourgoulhon |
| 77 | * Minor modif comments (formula for V^\theta in Vector_divfree). |
| 78 | * |
| 79 | * Revision 1.28 2004/03/27 20:59:55 e_gourgoulhon |
| 80 | * Slight modif comment (doxygen \ingroup). |
| 81 | * |
| 82 | * Revision 1.27 2004/03/22 13:12:44 j_novak |
| 83 | * Modification of comments to use doxygen instead of doc++ |
| 84 | * |
| 85 | * Revision 1.26 2004/03/10 12:52:19 f_limousin |
| 86 | * Add a new argument "method" in poisson method. |
| 87 | * |
| 88 | * Revision 1.25 2004/03/03 09:07:02 j_novak |
| 89 | * In Vector::poisson(double, int), the flat metric is taken from the mapping. |
| 90 | * |
| 91 | * Revision 1.24 2004/02/26 22:45:44 e_gourgoulhon |
| 92 | * Added method derive_lie. |
| 93 | * |
| 94 | * Revision 1.23 2004/02/22 15:47:45 j_novak |
| 95 | * Added 2 more methods to solve the vector Poisson equation. Method 1 is not |
| 96 | * tested yet. |
| 97 | * |
| 98 | * Revision 1.22 2004/02/21 16:27:53 j_novak |
| 99 | * Modif. comments |
| 100 | * |
| 101 | * Revision 1.21 2004/02/16 17:40:14 j_novak |
| 102 | * Added a version of poisson with the flat metric as argument (avoids |
| 103 | * unnecessary calculations by decompose_div) |
| 104 | * |
| 105 | * Revision 1.20 2003/12/14 21:47:24 e_gourgoulhon |
| 106 | * Added method visu_arrows for visualization through OpenDX. |
| 107 | * |
| 108 | * Revision 1.19 2003/11/06 14:43:37 e_gourgoulhon |
| 109 | * Gave a name to const arguments in certain method prototypes (e.g. |
| 110 | * constructors) to correct a bug of DOC++. |
| 111 | * |
| 112 | * Revision 1.18 2003/11/03 22:31:02 e_gourgoulhon |
| 113 | * Class Vector_divfree: parameters of methods set_vr_eta_mu and set_vr_mu |
| 114 | * are now all references. |
| 115 | * |
| 116 | * Revision 1.17 2003/11/03 14:02:17 e_gourgoulhon |
| 117 | * Class Vector_divfree: the members p_eta and p_mu are no longer declared |
| 118 | * "const". |
| 119 | * |
| 120 | * Revision 1.16 2003/10/20 15:12:17 j_novak |
| 121 | * New method Vector::poisson |
| 122 | * |
| 123 | * Revision 1.15 2003/10/20 14:44:49 e_gourgoulhon |
| 124 | * Class Vector_divfree: added method poisson(). |
| 125 | * |
| 126 | * Revision 1.14 2003/10/20 09:32:10 j_novak |
| 127 | * Members p_potential and p_div_free of the Helmholtz decomposition |
| 128 | * + the method decompose_div(Metric). |
| 129 | * |
| 130 | * Revision 1.13 2003/10/17 16:36:53 e_gourgoulhon |
| 131 | * Class Vector_divfree: Added new methods set_vr_eta_mu and set_vr_mu. |
| 132 | * |
| 133 | * Revision 1.12 2003/10/16 21:36:01 e_gourgoulhon |
| 134 | * Added method Vector_divfree::update_vtvp(). |
| 135 | * |
| 136 | * Revision 1.11 2003/10/16 15:25:00 e_gourgoulhon |
| 137 | * Changes in documentation. |
| 138 | * |
| 139 | * Revision 1.10 2003/10/16 14:21:33 j_novak |
| 140 | * The calculation of the divergence of a Tensor is now possible. |
| 141 | * |
| 142 | * Revision 1.9 2003/10/13 20:49:26 e_gourgoulhon |
| 143 | * Corrected typo in the comments. |
| 144 | * |
| 145 | * Revision 1.8 2003/10/13 13:52:39 j_novak |
| 146 | * Better managment of derived quantities. |
| 147 | * |
| 148 | * Revision 1.7 2003/10/12 20:33:15 e_gourgoulhon |
| 149 | * Added new derived class Vector_divfree (preliminary). |
| 150 | * |
| 151 | * Revision 1.6 2003/10/06 13:58:45 j_novak |
| 152 | * The memory management has been improved. |
| 153 | * Implementation of the covariant derivative with respect to the exact Tensor |
| 154 | * type. |
| 155 | * |
| 156 | * Revision 1.5 2003/10/05 21:07:27 e_gourgoulhon |
| 157 | * Method std_spectral_base() is now virtual. |
| 158 | * |
| 159 | * Revision 1.4 2003/10/03 14:08:03 e_gourgoulhon |
| 160 | * Added constructor from Tensor. |
| 161 | * |
| 162 | * Revision 1.3 2003/09/29 13:48:17 j_novak |
| 163 | * New class Delta. |
| 164 | * |
| 165 | * Revision 1.2 2003/09/29 12:52:56 j_novak |
| 166 | * Methods for changing the triad are implemented. |
| 167 | * |
| 168 | * Revision 1.1 2003/09/26 08:07:32 j_novak |
| 169 | * New class vector |
| 170 | * |
| 171 | * |
| 172 | * $Header: /cvsroot/Lorene/C++/Include/vector.h,v 1.42 2014/10/13 08:52:37 j_novak Exp $ |
| 173 | * |
| 174 | */ |
| 175 | |
| 176 | namespace Lorene { |
| 177 | class Vector_divfree ; |
| 178 | |
| 179 | //-------------------------// |
| 180 | // class Vector // |
| 181 | //-------------------------// |
| 182 | |
| 183 | |
| 184 | /** |
| 185 | * Tensor field of valence 1. \ingroup (tensor) |
| 186 | * |
| 187 | */ |
| 188 | class Vector: public Tensor { |
| 189 | |
| 190 | // Derived data : |
| 191 | // ------------ |
| 192 | protected: |
| 193 | /** The potential \f$\phi\f$ giving the gradient part in the Helmholtz |
| 194 | * decomposition of any 3D vector \f$\vec{V}: \quad \vec{V} = |
| 195 | * \vec{\nabla} \phi + \vec{\nabla} \wedge \vec{\psi}\f$. |
| 196 | * Only in the case of contravariant vectors. |
| 197 | */ |
| 198 | mutable Scalar* p_potential[N_MET_MAX] ; |
| 199 | |
| 200 | /** The divergence-free vector \f$\vec{W} = \vec{\nabla} \wedge |
| 201 | * \vec{\psi}\f$ of the Helmholtz decomposition of any 3D vector |
| 202 | *\f$\vec{V}: \quad \vec{V} = \vec{\nabla} \phi + \vec{\nabla} |
| 203 | *\wedge \vec{\psi}\f$. Only in the case of contravariant vectors. |
| 204 | */ |
| 205 | mutable Vector_divfree* p_div_free[N_MET_MAX] ; |
| 206 | |
| 207 | /** Field \f$\eta\f$ such that the angular components \f$(V^\theta, V^\varphi)\f$ |
| 208 | * of the vector are written: |
| 209 | * \f[ |
| 210 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 211 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 212 | * \f] |
| 213 | * \f[ |
| 214 | * V^\varphi = {1\over\sin\theta} |
| 215 | * {\partial \eta \over \partial\varphi} |
| 216 | * + {\partial \mu \over \partial\theta} |
| 217 | * \f] |
| 218 | */ |
| 219 | mutable Scalar* p_eta ; |
| 220 | |
| 221 | /** Field \f$\mu\f$ such that the angular components \f$(V^\theta, V^\varphi)\f$ |
| 222 | * of the vector are written: |
| 223 | * \f[ |
| 224 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 225 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 226 | * \f] |
| 227 | * \f[ |
| 228 | * V^\varphi = {1\over\sin\theta} |
| 229 | * {\partial \eta \over \partial\varphi} |
| 230 | * + {\partial \mu \over \partial\theta} |
| 231 | * \f] |
| 232 | */ |
| 233 | mutable Scalar* p_mu ; |
| 234 | |
| 235 | /** Field \f$A\f$ defined by |
| 236 | * \f[ |
| 237 | * A = {\partial \eta \over \ partial r} + { \eta \over r} - {V^r \over r} |
| 238 | * \f] |
| 239 | * Insensitive to the longitudinal part of the vector, related to the curl. |
| 240 | */ |
| 241 | mutable Scalar* p_A ; |
| 242 | |
| 243 | // Constructors - Destructor |
| 244 | // ------------------------- |
| 245 | public: |
| 246 | /** Standard constructor. |
| 247 | * |
| 248 | * @param map the mapping |
| 249 | * @param tipe the type \c COV for a covariant vector (1-form) |
| 250 | * and \c CON for a contravariant one |
| 251 | * @param triad_i vectorial basis (triad) with respect to which |
| 252 | * the vector components are defined |
| 253 | */ |
| 254 | Vector(const Map& map, int tipe, const Base_vect& triad_i) ; |
| 255 | |
| 256 | /** Standard constructor with the triad passed as a pointer. |
| 257 | * |
| 258 | * @param map the mapping |
| 259 | * @param tipe the type \c COV for a covariant vector (1-form) |
| 260 | * and \c CON for a contravariant one |
| 261 | * @param triad_i pointer on the vectorial basis (triad) |
| 262 | * with respect to which the vector components are defined |
| 263 | */ |
| 264 | Vector(const Map& map, int tipe, const Base_vect* triad_i) ; |
| 265 | |
| 266 | Vector(const Vector& a) ; ///< Copy constructor |
| 267 | |
| 268 | /** Constructor from a \c Tensor . |
| 269 | * The \c Tensor must be of valence one. |
| 270 | */ |
| 271 | Vector(const Tensor& a) ; |
| 272 | |
| 273 | /** Constructor from a file (see \c Tensor::sauve(FILE*) ). |
| 274 | * |
| 275 | * @param map the mapping |
| 276 | * @param triad_i vectorial basis (triad) with respect to which |
| 277 | * the tensor components are defined. It will |
| 278 | * be checked that it coincides with the basis |
| 279 | * saved in the file. |
| 280 | * @param fich file which has been created by |
| 281 | * the function \c sauve(FILE*) . |
| 282 | */ |
| 283 | Vector(const Map& map, const Base_vect& triad_i, FILE* fich) ; |
| 284 | |
| 285 | virtual ~Vector() ; ///< Destructor |
| 286 | |
| 287 | |
| 288 | // Memory management |
| 289 | // ----------------- |
| 290 | protected: |
| 291 | virtual void del_deriv() const; ///< Deletes the derived quantities |
| 292 | |
| 293 | /// Sets the pointers on derived quantities to 0x0 |
| 294 | void set_der_0x0() const ; |
| 295 | |
| 296 | /** |
| 297 | * Logical destructor of the derivatives depending on the i-th |
| 298 | * element of \c met_depend in the class \c Vector. |
| 299 | */ |
| 300 | virtual void del_derive_met(int) const ; |
| 301 | |
| 302 | /** |
| 303 | * Sets all the i-th components of \c met_depend in the |
| 304 | * class \c Vector (\c p_potential , etc...) to 0x0. |
| 305 | */ |
| 306 | void set_der_met_0x0(int) const ; |
| 307 | |
| 308 | |
| 309 | // Mutators / assignment |
| 310 | // --------------------- |
| 311 | public: |
| 312 | /** Sets a new vectorial basis (triad) of decomposition and modifies |
| 313 | * the components accordingly. |
| 314 | */ |
| 315 | virtual void change_triad(const Base_vect& ) ; |
| 316 | |
| 317 | /// Assignment from a Vector |
| 318 | virtual void operator=(const Vector& a) ; |
| 319 | |
| 320 | /// Assignment from a Tensor |
| 321 | virtual void operator=(const Tensor& a) ; |
| 322 | |
| 323 | /** Defines the components through potentials \f$\eta\f$ and \f$\mu\f$ |
| 324 | * (see members \c p_eta and \c p_mu ), |
| 325 | * as well as the \f$V^r\f$ component of the vector. |
| 326 | * |
| 327 | * @param vr_i [input] component \f$V^r\f$ of the vector |
| 328 | * @param eta_i [input] angular potential \f$\eta\f$ |
| 329 | * @param mu_i [input] angular potential \f$\mu\f$ |
| 330 | * |
| 331 | */ |
| 332 | void set_vr_eta_mu(const Scalar& vr_i, const Scalar& eta_i, |
| 333 | const Scalar& mu_i) ; |
| 334 | |
| 335 | /**Makes the Helmholtz decomposition (see documentation of |
| 336 | * \c p_potential ) of \c this with respect to a given |
| 337 | * \c Metric , only in the case of contravariant vectors. |
| 338 | */ |
| 339 | void decompose_div(const Metric&) const ; |
| 340 | |
| 341 | /**Returns the potential in the Helmholtz decomposition. |
| 342 | * |
| 343 | * It first makes the Helmholtz decomposition (see documentation of |
| 344 | * \c p_potential ) of \c this with respect to a given |
| 345 | * \c Metric and then returns \f$\phi\f$. Only in the case |
| 346 | * of contravariant vectors. |
| 347 | */ |
| 348 | const Scalar& potential(const Metric& ) const ; |
| 349 | |
| 350 | /**Returns the div-free vector in the Helmholtz decomposition. |
| 351 | * |
| 352 | * It first makes the Helmholtz decomposition (see documentation of |
| 353 | * \c p_potential ) of \c this with respect to a given |
| 354 | * \c Metric and then returns \f$\vec{W}\f$. Only in the case |
| 355 | * of contravariant vectors. |
| 356 | */ |
| 357 | const Vector_divfree& div_free(const Metric& ) const; |
| 358 | |
| 359 | /** Applies exponential filters to all components |
| 360 | * (see \c Scalar::exponential_filter_r ). Does a loop for Cartesian |
| 361 | * components, and works in terms of the r-component, \f$\eta\f$ and |
| 362 | * \f$\mu\f$ for spherical components. |
| 363 | */ |
| 364 | virtual void exponential_filter_r(int lzmin, int lzmax, int p, |
| 365 | double alpha= -16.) ; |
| 366 | |
| 367 | /** Applies exponential filters to all components |
| 368 | * (see \c Scalar::exponential_filter_ylm ). Does a loop for Cartesian |
| 369 | * components, and works in terms of the r-component, \f$\eta\f$ and |
| 370 | * \f$\mu\f$ for spherical components. |
| 371 | */ |
| 372 | virtual void exponential_filter_ylm(int lzmin, int lzmax, int p, |
| 373 | double alpha= -16.) ; |
| 374 | |
| 375 | |
| 376 | // Accessors |
| 377 | // --------- |
| 378 | public: |
| 379 | Scalar& set(int ) ; ///< Read/write access to a component |
| 380 | |
| 381 | const Scalar& operator()(int ) const; ///<Readonly access to a component |
| 382 | |
| 383 | /** |
| 384 | * Returns the position in the \c Scalar array \c cmp of a |
| 385 | * component given by its index. |
| 386 | * |
| 387 | * @return position in the \c Scalar array \c cmp |
| 388 | * corresponding to the index given in \c idx . \c idx |
| 389 | * must be a 1-D \c Itbl of size 1, the element of which |
| 390 | * must be one of the spatial indices 1, 2 or 3. |
| 391 | */ |
| 392 | virtual int position(const Itbl& idx) const { |
| 393 | assert (idx.get_ndim() == 1) ; |
| 394 | assert (idx.get_dim(0) == 1) ; |
| 395 | assert ((idx(0) >= 1) && (idx(0) <= 3)) ; |
| 396 | |
| 397 | return (idx(0) - 1) ; |
| 398 | |
| 399 | } ; |
| 400 | |
| 401 | /** |
| 402 | * Returns the index of a component given by its position in the |
| 403 | * \c Scalar array \c cmp . |
| 404 | * |
| 405 | * @return the index is stored in an 1-D array (\c Itbl ) of |
| 406 | * size 1 giving its value for the component located at |
| 407 | * the position \c place in the \c Scalar array |
| 408 | * \c cmp . The element of this \c Itbl |
| 409 | * corresponds to a spatial index 1, 2 or 3. |
| 410 | */ |
| 411 | virtual Itbl indices(int place) const { |
| 412 | assert((place>=0) && (place<3)) ; |
| 413 | |
| 414 | Itbl res(1) ; |
| 415 | res = place + 1; |
| 416 | return res ; |
| 417 | |
| 418 | }; |
| 419 | |
| 420 | /** |
| 421 | * Sets the standard spectal bases of decomposition for each component. |
| 422 | * |
| 423 | */ |
| 424 | virtual void std_spectral_base() ; |
| 425 | |
| 426 | /** |
| 427 | * Sets the standard spectal bases of decomposition for each component for a pseudo_vector. |
| 428 | * |
| 429 | */ |
| 430 | virtual void pseudo_spectral_base() ; |
| 431 | |
| 432 | /** Gives the field \f$\eta\f$ such that the angular components |
| 433 | * \f$(V^\theta, V^\varphi)\f$ of the vector are written: |
| 434 | * \f[ |
| 435 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 436 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 437 | * \f] |
| 438 | * \f[ |
| 439 | * V^\varphi = {1\over\sin\theta} |
| 440 | * {\partial \eta \over \partial\varphi} |
| 441 | * + {\partial \mu \over \partial\theta} |
| 442 | * \f] |
| 443 | */ |
| 444 | virtual const Scalar& eta() const ; |
| 445 | |
| 446 | /** Gives the field \f$\mu\f$ such that the angular components |
| 447 | * \f$(V^\theta, V^\varphi)\f$ of the vector are written: |
| 448 | * \f[ |
| 449 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 450 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 451 | * \f] |
| 452 | * \f[ |
| 453 | * V^\varphi = {1\over\sin\theta} |
| 454 | * {\partial \eta \over \partial\varphi} |
| 455 | * + {\partial \mu \over \partial\theta} |
| 456 | * \f] |
| 457 | */ |
| 458 | virtual const Scalar& mu() const ; |
| 459 | |
| 460 | |
| 461 | /** Gives the field \f$A\f$ defined by |
| 462 | * \f[ |
| 463 | * A = {\partial \eta \over \partial r} + { \eta \over r} - {V^r \over r} |
| 464 | * \f] |
| 465 | * Related to the curl, A is insensitive to the longitudinal part of the vector. |
| 466 | */ |
| 467 | virtual const Scalar& A() const ; |
| 468 | |
| 469 | |
| 470 | /** Computes the components \f$V^\theta\f$ and \f$V^\varphi\f$ from the |
| 471 | * potential \f$\eta\f$ and \f$\mu\f$, according to: |
| 472 | * \f[ |
| 473 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 474 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 475 | * \f] |
| 476 | * \f[ |
| 477 | * V^\varphi = {1\over\sin\theta} |
| 478 | * {\partial \eta \over \partial\varphi} |
| 479 | * + {\partial \mu \over \partial\theta} |
| 480 | * \f] |
| 481 | */ |
| 482 | void update_vtvp() ; |
| 483 | |
| 484 | |
| 485 | // Differential operators/ PDE solvers |
| 486 | // ----------------------------------- |
| 487 | public: |
| 488 | /**The divergence of \c this with respect to a \c Metric . |
| 489 | * The \c Vector is assumed to be contravariant. |
| 490 | */ |
| 491 | const Scalar& divergence(const Metric&) const ; |
| 492 | |
| 493 | /** The curl of \c this with respect to a (flat) \c Metric . |
| 494 | * The \c Vector is assumed to be contravariant. |
| 495 | */ |
| 496 | const Vector_divfree curl() const ; |
| 497 | |
| 498 | /** Computes the Lie derivative of \c this with respect to some |
| 499 | * vector field \c v |
| 500 | */ |
| 501 | Vector derive_lie(const Vector& v) const ; |
| 502 | |
| 503 | /** Computes the Killing operator associated with a given metric. |
| 504 | * The Killing operator is defined by \f$ D^i V^j + D^j V^i \f$ |
| 505 | * for a contravariant vector and by \f$ D_i V_j + D_j V_i \f$ |
| 506 | * for a covariant vector. |
| 507 | * @param gam metric with respect to which the covariant derivative |
| 508 | * \f$ D_i \f$ is defined. |
| 509 | */ |
| 510 | Sym_tensor ope_killing(const Metric& gam) const ; |
| 511 | |
| 512 | /** Computes the conformal Killing operator associated with a given metric. |
| 513 | * The conformal Killing operator is defined by |
| 514 | * \f$ D^i V^j + D^j V^i - \frac{2}{3} D_k V^k \, \gamma^{ij} \f$ |
| 515 | * for a contravariant vector and by |
| 516 | * \f$ D_i V_j + D_j V_i - \frac{2}{3} D^k V_k \, \gamma_{ij}\f$ |
| 517 | * for a covariant vector. |
| 518 | * @param gam metric \f$\gamma_{ij}\f$ with respect to which the covariant |
| 519 | * derivative \f$ D_i \f$ is defined. |
| 520 | */ |
| 521 | Sym_tensor ope_killing_conf(const Metric& gam) const ; |
| 522 | |
| 523 | /**Solves the vector Poisson equation with \c *this as a source. |
| 524 | * |
| 525 | * The equation solved is \f$\Delta N^i +\lambda \nabla^i |
| 526 | * \nabla_k N^k = S^i\f$. |
| 527 | * \c *this must be given with \c dzpuis = 4. |
| 528 | * It uses the Helmholtz decomposition (see documentation of |
| 529 | * \c p_potential ), with a flat metric, deduced from the triad. |
| 530 | * |
| 531 | * @param lambda [input] \f$\lambda\f$. |
| 532 | * @param method [input] method used to solve the equation |
| 533 | * (see Vector::poisson(double, Metric_flat, int) for details). |
| 534 | * |
| 535 | * @return the solution \f$N^i\f$. |
| 536 | */ |
| 537 | Vector poisson(double lambda, int method = 6) const ; |
| 538 | |
| 539 | /**Solves the vector Poisson equation with \c *this as a source. |
| 540 | * |
| 541 | * The equation solved is \f$\Delta N^i +\lambda \nabla^i |
| 542 | * \nabla_k N^k = S^i\f$. |
| 543 | * \c *this must be given with \c dzpuis = 4. |
| 544 | * It uses the Helmholtz decomposition (see documentation of |
| 545 | * \c p_potential ), with the flat metric \c met_f given |
| 546 | * in argument. |
| 547 | * |
| 548 | * @param lambda [input] \f$\lambda\f$. |
| 549 | * @param met_f [input] the flat metric for the Helmholtz decomposition. |
| 550 | * @param method [input] method used to solve the equation: |
| 551 | * \li 0 : It uses the Helmholtz decomposition (see documentation of |
| 552 | * \c p_potential ), with the flat metric \c met_f given |
| 553 | * in argument (the default). |
| 554 | * \li 1 : It solves, first for the divergence (calculated using |
| 555 | * \c met_f ), then the \e r -component, the \f$\eta\f$ |
| 556 | * potential, and fianlly the \f$\mu\f$ potential (see documentation |
| 557 | * of \c Vector_div_free . |
| 558 | * \li 2 : The sources is transformed to cartesian components and the |
| 559 | * equation is solved using Shibata method (see Granclement |
| 560 | * \e et \e al. JCPH 2001. |
| 561 | * \li 6 : Solves for the \e r -component and \f$ \eta \f$ together in a |
| 562 | * system, and for the \f$ \mu \f$ potential (which decouples). The |
| 563 | * solution is then built from these fields through the method |
| 564 | * \c Vector::set_vr_eta_mu(). It is the default method. |
| 565 | * |
| 566 | * @return the solution \f$N^i\f$. |
| 567 | */ |
| 568 | Vector poisson(double lambda, const Metric_flat& met_f, int method = 6) const ; |
| 569 | |
| 570 | /**Solves the vector Poisson equation with \c *this as a source |
| 571 | * and parameters controlling the solution. |
| 572 | * |
| 573 | * The equatiopn solved is \f$\Delta N^i +\lambda \nabla^i |
| 574 | * \nabla_k N^k = S^i\f$. |
| 575 | * \c *this must be given with \c dzpuis = 4. |
| 576 | * It uses the Helmholtz decomposition (see documentation of |
| 577 | * \c p_potential ), with a flat metric, deduced from the triad. |
| 578 | * |
| 579 | * @param lambda [input] \f$\lambda\f$. |
| 580 | * @param par [input/output] possible parameters |
| 581 | * @param uu [input/output] solution \e u with the |
| 582 | * boundary condition \e u =0 at spatial infinity. |
| 583 | */ |
| 584 | |
| 585 | Vector poisson(const double lambda, Param& par, |
| 586 | int method = 6) const ; |
| 587 | |
| 588 | /**Solves the vector Poisson equation with \c *this as a source |
| 589 | * with a boundary condition on the excised sphere. |
| 590 | * |
| 591 | * The equation solved is \f$\Delta N^i +\lambda \nabla^i |
| 592 | * \nabla_k N^k = S^i\f$. |
| 593 | * \c *this must be given with \c dzpuis = 4. |
| 594 | * It uses the Helmholtz decomposition (see documentation of |
| 595 | * \c p_potential ) |
| 596 | * |
| 597 | * @param lambda [input] \f$\lambda\f$. |
| 598 | * @param resu [output] the solution \f$N^i\f$. |
| 599 | */ |
| 600 | void poisson_boundary(double lambda, const Mtbl_cf& limit_vr, |
| 601 | const Mtbl_cf& limit_eta, const Mtbl_cf& limit_mu, |
| 602 | int num_front, double fact_dir, double fact_neu, |
| 603 | Vector& resu) const ; |
| 604 | |
| 605 | |
| 606 | /**Alternative to previous poisson_boundary method for vectors ; |
| 607 | * this uses method 6 for vectorial solving, updated version |
| 608 | * (as in the poisson_vector_block routine). |
| 609 | * Boundary arguments are here required as scalar fields. |
| 610 | */ |
| 611 | void poisson_boundary2(double lam, Vector& resu, Scalar boundvr, |
| 612 | Scalar boundeta, Scalar boundmu, double dir_vr, |
| 613 | double neum_vr, double dir_eta, double neum_eta, |
| 614 | double dir_mu, double neum_mu ) const ; |
| 615 | |
| 616 | |
| 617 | Vector poisson_dirichlet(double lambda, const Valeur& limit_vr, |
| 618 | const Valeur& limit_vt, const Valeur& limit_vp, |
| 619 | int num_front) const ; |
| 620 | |
| 621 | /**Solves the vector Poisson equation with \c *this as a source |
| 622 | * with a boundary condition on the excised sphere. |
| 623 | * |
| 624 | * The equation solved is \f$\Delta N^i +\lambda \nabla^i |
| 625 | * \nabla_k N^k = S^i\f$. |
| 626 | * \c *this must be given with \c dzpuis = 4. |
| 627 | * It uses the Helmholtz decomposition (see documentation of |
| 628 | * \c p_potential ) |
| 629 | * |
| 630 | * @param lambda [input] \f$\lambda\f$. |
| 631 | * @param resu [output] the solution \f$N^i\f$. |
| 632 | */ |
| 633 | Vector poisson_neumann(double lambda, const Valeur& limit_vr, |
| 634 | const Valeur& limit_vt, const Valeur& limit_vp, |
| 635 | int num_front) const ; |
| 636 | |
| 637 | /**Solves the vector Poisson equation with \c *this as a source |
| 638 | * with a boundary condition on the excised sphere. |
| 639 | * |
| 640 | * The equation solved is \f$\Delta N^i +\lambda \nabla^i |
| 641 | * \nabla_k N^k = S^i\f$. |
| 642 | * \c *this must be given with \c dzpuis = 4. |
| 643 | * It uses the Helmholtz decomposition (see documentation of |
| 644 | * \c p_potential ) |
| 645 | * |
| 646 | * @param lambda [input] \f$\lambda\f$. |
| 647 | * @param resu [output] the solution \f$N^i\f$. |
| 648 | */ |
| 649 | Vector poisson_robin(double lambda, const Valeur& limit_vr, |
| 650 | const Valeur& limit_vt, const Valeur& limit_vp, |
| 651 | double fact_dir, double fact_neu, |
| 652 | int num_front) const ; |
| 653 | |
| 654 | |
| 655 | /** Computes the flux of the vector accross a sphere \e r = const. |
| 656 | * |
| 657 | * @param radius radius of the sphere \e S on which the flux is |
| 658 | * to be taken; the center of \e S is assumed to be the |
| 659 | * center of the mapping (member \c mp). |
| 660 | * \c radius can take the value \c __infinity (to get the flux |
| 661 | * at spatial infinity). |
| 662 | * @param met metric \f$ \gamma \f$ giving the area element |
| 663 | * of the sphere |
| 664 | * @return \f$ \oint_S V^i ds_i \f$, where \f$ V^i \f$ is the vector |
| 665 | * represented by \c *this and \f$ ds_i \f$ is the area element |
| 666 | * induced on \e S by \f$ \gamma \f$. |
| 667 | */ |
| 668 | double flux(double radius, const Metric& met) const ; |
| 669 | |
| 670 | void poisson_block(double lambda, Vector& resu) const ; |
| 671 | |
| 672 | // Graphics |
| 673 | // -------- |
| 674 | public: |
| 675 | /** 3D visualization via OpenDX. |
| 676 | * |
| 677 | * @param xmin [input] defines with \c xmax the x range of the visualization box |
| 678 | * @param xmax [input] defines with \c xmin the x range of the visualization box |
| 679 | * @param ymin [input] defines with \c ymax the y range of the visualization box |
| 680 | * @param ymax [input] defines with \c ymin the y range of the visualization box |
| 681 | * @param zmin [input] defines with \c zmax the z range of the visualization box |
| 682 | * @param zmax [input] defines with \c zmin the z range of the visualization box |
| 683 | * @param title [input] title for the graph (for OpenDX legend) |
| 684 | * @param filename [input] name for the file which will be the input for |
| 685 | * OpenDX; the default 0x0 is transformed into "vector_arrows" |
| 686 | * @param start_dx [input] determines whether OpenDX must be launched (as a |
| 687 | * subprocess) to view the field; if set to \c false , only input files |
| 688 | * for future usage of OpenDX are created |
| 689 | * @param nx [input] number of points in the x direction (uniform sampling) |
| 690 | * @param ny [input] number of points in the y direction (uniform sampling) |
| 691 | * @param nz [input] number of points in the z direction (uniform sampling) |
| 692 | * |
| 693 | */ |
| 694 | void visu_arrows(double xmin, double xmax, double ymin, double ymax, |
| 695 | double zmin, double zmax, const char* title0 = 0x0, |
| 696 | const char* filename0 = 0x0, bool start_dx = true, int nx = 8, int ny = 8, |
| 697 | int nz = 8) const ; |
| 698 | |
| 699 | void visu_streamline(double xmin, double xmax, double ymin, double ymax, |
| 700 | double zmin, double zmax, const char* title0 = 0x0, |
| 701 | const char* filename0 = 0x0, bool start_dx = true, int nx = 8, int ny = 8, |
| 702 | int nz = 8) const ; |
| 703 | |
| 704 | |
| 705 | |
| 706 | }; |
| 707 | |
| 708 | |
| 709 | |
| 710 | //---------------------------------// |
| 711 | // class Vector_divfree // |
| 712 | //---------------------------------// |
| 713 | |
| 714 | |
| 715 | /** |
| 716 | * Divergence-free vectors. \ingroup (tensor) |
| 717 | * |
| 718 | * This class is designed to store divergence-free vectors, |
| 719 | * with the component expressed in a orthonormal spherical basis |
| 720 | * \f$(e_r,e_\theta,e_\varphi)\f$. |
| 721 | * |
| 722 | * |
| 723 | */ |
| 724 | class Vector_divfree: public Vector { |
| 725 | |
| 726 | // Data : |
| 727 | // ----- |
| 728 | protected: |
| 729 | /// Metric with respect to which the divergence is defined |
| 730 | const Metric* const met_div ; |
| 731 | |
| 732 | // Constructors - Destructor |
| 733 | // ------------------------- |
| 734 | public: |
| 735 | /** Standard constructor. |
| 736 | * |
| 737 | * @param map the mapping |
| 738 | * @param triad_i vectorial basis (triad) with respect to which |
| 739 | * the vector components are defined |
| 740 | * @param met the metric with respect to which the divergence is defined |
| 741 | */ |
| 742 | Vector_divfree(const Map& map, const Base_vect& triad_i, |
| 743 | const Metric& met) ; |
| 744 | |
| 745 | Vector_divfree(const Vector_divfree& ) ; ///< Copy constructor |
| 746 | |
| 747 | /** Constructor from a file (see \c Tensor::sauve(FILE*) ). |
| 748 | * |
| 749 | * @param map the mapping |
| 750 | * @param triad_i vectorial basis (triad) with respect to which |
| 751 | * the tensor components are defined. It will |
| 752 | * be checked that it coincides with the basis |
| 753 | * saved in the file. |
| 754 | * @param met the metric with respect to which the divergence is defined |
| 755 | * @param fich file which has been created by |
| 756 | * the function \c sauve(FILE*) . |
| 757 | */ |
| 758 | Vector_divfree(const Map& map, const Base_vect& triad_i, |
| 759 | const Metric& met, FILE* fich) ; |
| 760 | |
| 761 | virtual ~Vector_divfree() ; ///< Destructor |
| 762 | |
| 763 | |
| 764 | // Memory management |
| 765 | // ----------------- |
| 766 | protected: |
| 767 | virtual void del_deriv() const; ///< Deletes the derived quantities |
| 768 | |
| 769 | /// Sets the pointers on derived quantities to 0x0 |
| 770 | void set_der_0x0() const ; |
| 771 | |
| 772 | |
| 773 | // Mutators / assignment |
| 774 | // --------------------- |
| 775 | |
| 776 | public: |
| 777 | /// Assignment from another \c Vector_divfree |
| 778 | void operator=(const Vector_divfree& a) ; |
| 779 | |
| 780 | /// Assignment from a \c Vector |
| 781 | virtual void operator=(const Vector& a) ; |
| 782 | |
| 783 | /// Assignment from a \c Tensor |
| 784 | virtual void operator=(const Tensor& a) ; |
| 785 | |
| 786 | /** Sets the angular potentials \f$\mu\f$ (see member |
| 787 | * \c p_mu ), and the \f$V^r\f$ component |
| 788 | * of the vector. The potential \f$\eta\f$ is then deduced from |
| 789 | * \f$V^r\f$ by the divergence-free condition. |
| 790 | * The components \f$V^\theta\f$ and \f$V^\varphi\f$ are updated consistently |
| 791 | * by a call to the method \c update_vtvp() . |
| 792 | * |
| 793 | * @param vr_i [input] component \f$V^r\f$ of the vector |
| 794 | * @param mu_i [input] angular potential \f$\mu\f$ |
| 795 | * |
| 796 | */ |
| 797 | void set_vr_mu(const Scalar& vr_i, const Scalar& mu_i) ; |
| 798 | |
| 799 | /** Defines the components through \f$V_r\f$, \f$\eta\f$ and \f$\mu\f$. |
| 800 | * (see members \c p_eta and \c p_mu ), |
| 801 | * |
| 802 | * @param vr_i [input] r-component of the vector |
| 803 | * @param eta_i [input] Angular potential \f$\eta\f$ |
| 804 | * @param mu_i [input] Angular potential \f$\mu\f$ |
| 805 | * |
| 806 | */ |
| 807 | void set_vr_eta_mu(const Scalar& vr_i, const Scalar& eta_i, const Scalar& mu_i) ; |
| 808 | |
| 809 | /** Defines the components through potentials \f$A\f$ and \f$\mu\f$. |
| 810 | * (see members \c p_A and \c p_mu ), |
| 811 | * |
| 812 | * @param A_i [input] Angular potential \f$A\f$ |
| 813 | * @param mu_i [input] Angular potential \f$\mu\f$ |
| 814 | * |
| 815 | */ |
| 816 | void set_A_mu(const Scalar& A_i, const Scalar& mu_i, const Param* par_bc) ; |
| 817 | |
| 818 | // Computational methods |
| 819 | // --------------------- |
| 820 | public: |
| 821 | /** Gives the field \f$\eta\f$ such that the angular components |
| 822 | * \f$(V^\theta, V^\varphi)\f$ of the vector are written: |
| 823 | * \f[ |
| 824 | * V^\theta = {\partial \eta \over \partial\theta} - |
| 825 | * {1\over\sin\theta} {\partial \mu \over \partial\varphi} |
| 826 | * \f] |
| 827 | * \f[ |
| 828 | * V^\varphi = {1\over\sin\theta} |
| 829 | * {\partial \eta \over \partial\varphi} |
| 830 | * + {\partial \mu \over \partial\theta} |
| 831 | * \f] |
| 832 | */ |
| 833 | virtual const Scalar& eta() const ; |
| 834 | |
| 835 | /** Computes the solution of a vectorial Poisson equation |
| 836 | * with \c *this \f$= \vec{V}\f$ as a source: |
| 837 | * \f[ |
| 838 | * \Delta \vec{W} = \vec{V} |
| 839 | * \f] |
| 840 | * |
| 841 | * @return solution \f$\vec{W}\f$ of the above equation with the boundary |
| 842 | * condition \f$\vec{W}=0\f$ at spatial infinity. |
| 843 | */ |
| 844 | Vector_divfree poisson() const ; |
| 845 | |
| 846 | /** Computes the components \f$V^r\f$ and \f$\eta\f$ from the potential |
| 847 | * A and the divergence-free condition, according to : |
| 848 | * \f[ |
| 849 | * {\partial \eta \over \ partial r} + { \eta \over r} |
| 850 | * - {V^r \over r} = A |
| 851 | * \f] |
| 852 | * \f[ |
| 853 | * {\partial V^r \over \partial r} + {2 V^r \over r} |
| 854 | * + {1 \over r} \Delta_{\vartheta \varphi} \eta = 0 |
| 855 | * \f] |
| 856 | */ |
| 857 | void update_etavr() ; |
| 858 | |
| 859 | /** Computes the solution of a vectorial Poisson equation |
| 860 | * with \c *this \f$= \vec{V}\f$ as a source: |
| 861 | * \f[ |
| 862 | * \Delta \vec{W} = \vec{V} |
| 863 | * \f] |
| 864 | * |
| 865 | * @return solution \f$\vec{W}\f$ of the above equation with the boundary |
| 866 | * condition \f$\vec{W}=0\f$ at spatial infinity. |
| 867 | */ |
| 868 | Vector_divfree poisson(Param& par) const ; |
| 869 | protected: |
| 870 | |
| 871 | /** Solves a system of two-coupled first-order PDEs obtained from the |
| 872 | * divergence-free condition and the requirement that the potential A |
| 873 | * has a given value. The system reads : |
| 874 | * \f[ |
| 875 | * {\partial \eta \over \partial r} + {\eta \over r} - {V^r \over r} = A |
| 876 | * \f] |
| 877 | * \f[ |
| 878 | * {\partial V^r \over \partial r} + {2 V^r \over r} |
| 879 | * + {1 \over r}\Delta_{\vartheta \varphi}\eta = 0 |
| 880 | * \f] |
| 881 | */ |
| 882 | void sol_Dirac_A(const Scalar& aaa, Scalar& eta, Scalar& vr, |
| 883 | const Param* par_bc = 0x0) const ; |
| 884 | |
| 885 | /** Solves via a tau method a system of two-coupled first-order PDEs |
| 886 | * obtained from the divergence-free condition and the requirement |
| 887 | * that the potential A has a given value. The system reads : |
| 888 | * \f[ |
| 889 | * {\partial \eta \over \partial r} + {\eta \over r} - {V^r \over r} = A |
| 890 | * \f] |
| 891 | * \f[ |
| 892 | * {\partial V^r \over \partial r} + {2 V^r \over r} |
| 893 | * + {1 \over r}\Delta_{\vartheta \varphi}\eta = 0 |
| 894 | * \f] |
| 895 | */ |
| 896 | void sol_Dirac_A_tau(const Scalar& aaa, Scalar& eta, Scalar& vr, |
| 897 | const Param* par_bc = 0x0) const ; |
| 898 | |
| 899 | /** Solves via a poisson method a system of two-coupled first-order PDEs |
| 900 | * obtained from the divergence-free condition and the requirement |
| 901 | * that the potential A has a given value. The system reads : |
| 902 | * \f[ |
| 903 | * {\partial \eta \over \partial r} + {\eta \over r} - {V^r \over r} = A |
| 904 | * \f] |
| 905 | * \f[ |
| 906 | * {\partial V^r \over \partial r} + {2 V^r \over r} |
| 907 | * + {1 \over r}\Delta_{\vartheta \varphi}\eta = 0 |
| 908 | * \f] |
| 909 | */ |
| 910 | void sol_Dirac_A_poisson(const Scalar& aaa, Scalar& eta, Scalar& vr, |
| 911 | const Param* par_bc = 0x0) const ; |
| 912 | |
| 913 | /** Solves a one-domain system of two-coupled first-order PDEs obtained from the |
| 914 | * divergence-free condition and the requirement that the potential A |
| 915 | * has a given value. The system reads : |
| 916 | * \f[ |
| 917 | * {\partial \eta \over \partial r} + {\eta \over r} - {V^r \over r} = A |
| 918 | * \f] |
| 919 | * \f[ |
| 920 | * {\partial V^r \over \partial r} + {2 V^r \over r} |
| 921 | * + {1 \over r}\Delta_{\vartheta \varphi}\eta = 0 |
| 922 | * \f] |
| 923 | */ |
| 924 | void sol_Dirac_A_1z(const Scalar& aaa, Scalar& eta, Scalar& vr, |
| 925 | const Param* par_bc = 0x0) const ; |
| 926 | |
| 927 | }; |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | } |
| 934 | #endif |