LORENE
sym_tensor_tt_etamu.C
1 /*
2  * Methods of class Sym_tensor_tt related to eta and mu
3  *
4  * (see file sym_tensor.h for documentation)
5  *
6  */
7 
8 /*
9  * Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
10  *
11  * This file is part of LORENE.
12  *
13  * LORENE is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * LORENE is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with LORENE; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
28 
29 
30 
31 
32 /*
33  * $Id: sym_tensor_tt_etamu.C,v 1.19 2016/12/05 16:18:17 j_novak Exp $
34  * $Log: sym_tensor_tt_etamu.C,v $
35  * Revision 1.19 2016/12/05 16:18:17 j_novak
36  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37  *
38  * Revision 1.18 2014/10/13 08:53:44 j_novak
39  * Lorene classes and functions now belong to the namespace Lorene.
40  *
41  * Revision 1.17 2014/10/06 15:13:19 j_novak
42  * Modified #include directives to use c++ syntax.
43  *
44  * Revision 1.16 2006/10/24 13:03:19 j_novak
45  * New methods for the solution of the tensor wave equation. Perhaps, first
46  * operational version...
47  *
48  * Revision 1.15 2005/04/01 14:28:32 j_novak
49  * Members p_eta and p_mu are now defined in class Sym_tensor.
50  *
51  * Revision 1.14 2004/06/04 09:25:58 e_gourgoulhon
52  * Method eta(): eta is no longer computed from h^rr but from khi (in the
53  * case where khi is known).
54  *
55  * Revision 1.13 2004/05/25 15:08:44 f_limousin
56  * Add parameters in argument of the functions update, eta and mu for
57  * the case of a Map_et.
58  *
59  * Revision 1.12 2004/05/24 13:45:29 e_gourgoulhon
60  * Added parameter dzp to method Sym_tensor_tt::update.
61  *
62  * Revision 1.11 2004/05/05 14:24:54 e_gourgoulhon
63  * Corrected a bug in method set_khi_mu: the division of khi by r^2
64  * was ommitted in the case dzp=2 !!!
65  *
66  * Revision 1.10 2004/04/08 16:38:43 e_gourgoulhon
67  * Sym_tensor_tt::set_khi_mu: added argument dzp (dzpuis of resulting h^{ij}).
68  *
69  * Revision 1.9 2004/03/04 09:53:04 e_gourgoulhon
70  * Methods eta(), mu() and upate(): use of Scalar::mult_r_dzpuis and
71  * change of dzpuis behavior of eta and mu.
72  *
73  * Revision 1.8 2004/03/03 13:16:21 j_novak
74  * New potential khi (p_khi) and the functions manipulating it.
75  *
76  * Revision 1.7 2004/02/05 13:44:50 e_gourgoulhon
77  * Major modif. of methods eta(), mu() and update() to treat
78  * any value of dzpuis, thanks to the new definitions of
79  * Scalar::mult_r(), Scalar::dsdr(), etc...
80  *
81  * Revision 1.6 2004/01/28 13:25:41 j_novak
82  * The ced_mult_r arguments have been suppressed from the Scalar::*dsd* methods.
83  * In the div/mult _r_dzpuis, there is no more default value.
84  *
85  * Revision 1.5 2003/11/05 15:28:31 e_gourgoulhon
86  * Corrected error in update.
87  *
88  * Revision 1.4 2003/11/04 23:03:34 e_gourgoulhon
89  * First full version of method update().
90  * Add method set_rr_mu.
91  * Method set_eta_mu ---> set_rr_eta_mu.
92  *
93  * Revision 1.3 2003/11/04 09:35:27 e_gourgoulhon
94  * First operational version of update_tp().
95  *
96  * Revision 1.2 2003/11/03 22:33:36 e_gourgoulhon
97  * Added methods update_tp and set_eta_mu.
98  *
99  * Revision 1.1 2003/11/03 17:08:37 e_gourgoulhon
100  * First version
101  *
102  *
103  * $Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor_tt_etamu.C,v 1.19 2016/12/05 16:18:17 j_novak Exp $
104  *
105  */
106 
107 // Headers C
108 #include <cstdlib>
109 #include <cassert>
110 
111 // Headers Lorene
112 #include "tensor.h"
113 
114  //--------------//
115  // khi //
116  //--------------//
117 
118 namespace Lorene {
119 const Scalar& Sym_tensor_tt::khi() const {
120 
121  if (p_khi == 0x0) { // a new computation is necessary
122 
123  // All this has a meaning only for spherical components:
124  assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ;
125 
126  // khi is computed from $h^{rr}$ component
127 
128  p_khi = new Scalar(operator()(1,1)) ;
129  p_khi->mult_r() ;
130  p_khi->mult_r() ;
131  }
132 
133  return *p_khi ;
134 
135 }
136 
137 
138  //--------------//
139  // eta //
140  //--------------//
141 
142 
143 const Scalar& Sym_tensor_tt::eta(Param* par) const {
144 
145 
146  if (p_eta == 0x0) { // a new computation is necessary
147 
148 
149  // All this has a meaning only for spherical components:
150  assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ;
151 
152  // eta is computed from the divergence-free condition:
153 
154  int dzp = operator()(1,1).get_dzpuis() ;
155  int dzp_resu = ((dzp == 0) ? 0 : dzp-1) ;
156 
157  Scalar source_eta(*mp) ;
158 
159  if (p_khi == 0x0) { // eta is computed from h^rr
160  // -------------------------
161 
162  source_eta = - operator()(1,1).dsdr() ;
163 
164  // dhrr contains - dh^{rr}/dr in all domains but the CED,
165  // in the CED: - r^2 dh^{rr}/dr if dzp = 0 (1)
166  // - r^(dzp+1) dh^{rr}/dr if dzp > 0 (2)
167 
168 
169  // Multiplication by r of (-d h^{rr}/dr) (with the same dzpuis as h^{rr})
170  source_eta.mult_r_dzpuis( dzp ) ;
171 
172  // Substraction of the h^rr part and multiplication by r :
173  source_eta -= 3. * operator()(1,1) ;
174 
175  source_eta.mult_r_dzpuis(dzp_resu) ;
176  }
177  else { // eta is computed from khi
178  // ------------------------
179 
180  source_eta = - p_khi->dsdr() ;
181  int diff_dzp = source_eta.get_dzpuis() - dzp_resu ;
182  assert( diff_dzp >= 0 ) ;
183  source_eta.dec_dzpuis(diff_dzp) ;
184 
185  Scalar tmp(*p_khi) ;
186  tmp.div_r_dzpuis(dzp_resu) ;
187 
188  source_eta -= tmp ;
189 
190  }
191 
192 
193  // Resolution of the angular Poisson equation for eta
194  // --------------------------------------------------
195  if (dynamic_cast<const Map_af*>(mp) != 0x0) {
196  p_eta = new Scalar( source_eta.poisson_angu() ) ;
197  }
198  else {
199  Scalar resu (*mp) ;
200  resu = 0. ;
201  mp->poisson_angu(source_eta, *par, resu) ;
202  p_eta = new Scalar( resu ) ;
203  }
204 
205  }
206 
207  return *p_eta ;
208 
209 }
210 
211 
212 
213  //-------------------//
214  // set_rr_eta_mu //
215  //-------------------//
216 
217 
218 void Sym_tensor_tt::set_rr_eta_mu(const Scalar& hrr, const Scalar& eta_i,
219  const Scalar& mu_i) {
220 
221  // All this has a meaning only for spherical components:
222  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
223 
224  set(1,1) = hrr ; // h^{rr}
225  // calls del_deriv() and therefore delete previous
226  // p_eta and p_mu
227 
228  p_eta = new Scalar( eta_i ) ; // eta
229 
230  p_mu = new Scalar( mu_i ) ; // mu
231 
232  update( hrr.get_dzpuis() ) ; // all h^{ij}, except for h^{rr}
233 
234 }
235 
236  //---------------//
237  // set_rr_mu //
238  //---------------//
239 
240 
241 void Sym_tensor_tt::set_rr_mu(const Scalar& hrr, const Scalar& mu_i) {
242 
243  // All this has a meaning only for spherical components:
244  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
245 
246  set(1,1) = hrr ; // h^{rr}
247  // calls del_deriv() and therefore delete previous
248  // p_eta and p_mu
249 
250  p_mu = new Scalar( mu_i ) ; // mu
251 
252  eta() ; // computes eta form the divergence-free condition
253 
254  update( hrr.get_dzpuis() ) ; // all h^{ij}, except for h^{rr}
255 
256 }
257 
258  //-------------------//
259  // set_khi_eta_mu //
260  //-------------------//
261 
262 
263 void Sym_tensor_tt::set_khi_eta_mu(const Scalar& khi_i, const Scalar& eta_i,
264  const Scalar& mu_i) {
265 
266  // All this has a meaning only for spherical components:
267  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
268 
269  set(1,1) = khi_i ;
270  set(1,1).div_r() ;
271  set(1,1).div_r() ; // h^{rr}
272 
273  // calls del_deriv() and therefore delete previous
274  // p_khi, p_eta and p_mu
275 
276  p_khi = new Scalar( khi_i ) ; // khi
277 
278  p_eta = new Scalar( eta_i ) ; // eta
279 
280  p_mu = new Scalar( mu_i ) ; // mu
281 
282  update( khi_i.get_dzpuis() ) ; // all h^{ij}, except for h^{rr}
283 
284 }
285 
286  //---------------//
287  // set_khi_mu //
288  //---------------//
289 
290 
291 void Sym_tensor_tt::set_khi_mu(const Scalar& khi_i, const Scalar& mu_i,
292  int dzp, Param* par1, Param* par2, Param* par3) {
293 
294  // All this has a meaning only for spherical components:
295  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
296 
297  set(1,1) = khi_i ;
298  // calls del_deriv() and therefore delete previous
299  // p_eta and p_mu
300 
301  assert( khi_i.check_dzpuis(0) ) ;
302  if (dzp == 0) {
303  set(1,1).div_r() ;
304  set(1,1).div_r() ; // h^{rr}
305  }
306  else {
307  assert(dzp == 2) ; //## temporary: the other cases are not treated yet
308  set(1,1).div_r_dzpuis(1) ;
309  set(1,1).div_r_dzpuis(2) ;
310  }
311 
312  p_khi = new Scalar ( khi_i ) ; // khi
313 
314  p_mu = new Scalar( mu_i ) ; // mu
315 
316  if (dynamic_cast<const Map_af*>(mp) != 0x0) {
317  eta() ; // computes eta form the divergence-free condition
318  // dzp = 0 ==> eta.dzpuis = 0
319  // dzp = 2 ==> eta.dzpuis = 1
320 
321  update(dzp) ; // all h^{ij}, except for h^{rr}
322  }
323  else {
324  eta(par1) ; // computes eta form the divergence-free condition
325  // dzp = 0 ==> eta.dzpuis = 0
326  // dzp = 2 ==> eta.dzpuis = 1
327 
328  update(dzp, par2, par3) ; // all h^{ij}, except for h^{rr}
329  }
330 
331 }
332 
333 
334 
335  //-------------//
336  // update //
337  //-------------//
338 
339 
340 
341 void Sym_tensor_tt::update(int dzp, Param* par1, Param* par2) {
342 
343  // All this has a meaning only for spherical components:
344  assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ;
345 
346  assert( (p_eta != 0x0) && (p_mu != 0x0) ) ;
347 
348  Itbl idx(2) ;
349  idx.set(0) = 1 ; // r index
350 
351  // h^{r theta} :
352  // ------------
353  idx.set(1) = 2 ; // theta index
354  *cmp[position(idx)] = p_eta->srdsdt() - p_mu->srstdsdp() ;
355 
356  if (dzp == 0) {
357  assert( cmp[position(idx)]->check_dzpuis(2) ) ;
358  cmp[position(idx)]->dec_dzpuis(2) ;
359  }
360 
361  assert( cmp[position(idx)]->check_dzpuis(dzp) ) ;
362 
363  // h^{r phi} :
364  // ------------
365  idx.set(1) = 3 ; // phi index
366  *cmp[position(idx)] = p_eta->srstdsdp() + p_mu->srdsdt() ;
367 
368  if (dzp == 0) {
369  assert( cmp[position(idx)]->check_dzpuis(2) ) ;
370  cmp[position(idx)]->dec_dzpuis(2) ;
371  }
372 
373  assert( cmp[position(idx)]->check_dzpuis(dzp) ) ;
374 
375  // h^{theta phi} and h^{phi phi}
376  // -----------------------------
377 
378  //-------------- Computation of T^theta --> taut :
379 
380  Scalar tautst = operator()(1,2).dsdr() ;
381 
382  // dhrr contains dh^{rt}/dr in all domains but the CED,
383  // in the CED: r^2 dh^{rt}/dr if dzp = 0 (1)
384  // r^(dzp+1) dh^{rt}/dr if dzp > 0 (2)
385 
386  // Multiplication by r of dh^{rt}/dr (with the same dzpuis than h^{rt})
387  tautst.mult_r_dzpuis( operator()(1,2).get_dzpuis() ) ;
388 
389 
390  // Addition of the remaining parts :
391  tautst += 3 * operator()(1,2) - operator()(1,1).dsdt() ;
392  tautst.mult_sint() ;
393 
394  Scalar tmp = operator()(1,1) ;
395  tmp.mult_cost() ; // h^{rr} cos(th)
396 
397  tautst -= tmp ; // T^th / sin(th)
398 
399  Scalar taut = tautst ;
400  taut.mult_sint() ; // T^th
401 
402 
403  //----------- Computation of T^phi --> taup :
404 
405  Scalar taupst = - operator()(1,3).dsdr() ;
406 
407  // dhrr contains - dh^{rp}/dr in all domains but the CED,
408  // in the CED: - r^2 dh^{rp}/dr if dzp = 0 (3)
409  // - r^(dzp+1) dh^{rp}/dr if dzp > 0 (4)
410 
411  // Multiplication by r of -dh^{rp}/dr (with the same dzpuis than h^{rp})
412  taupst.mult_r_dzpuis( operator()(1,3).get_dzpuis() ) ;
413 
414 
415  // Addition of the remaining part :
416 
417  taupst -= 3 * operator()(1,3) ;
418  taupst.mult_sint() ; // T^ph / sin(th)
419 
420  Scalar taup = taupst ;
421  taup.mult_sint() ; // T^ph
422 
423 
424  //------------------- Computation of F and h^[ph ph}
425 
426  tmp = tautst ;
427  tmp.mult_cost() ; // T^th / tan(th)
428 
429  // dT^th/dth + T^th / tan(th) + 1/sin(th) dT^ph/dph :
430  tmp = taut.dsdt() + tmp + taup.stdsdp() ;
431 
432  Scalar tmp2 (*mp) ;
433  if (dynamic_cast<const Map_af*>(mp) != 0x0) {
434  tmp2 = tmp.poisson_angu() ; // F
435  }
436  else {
437  tmp2 = 0. ;
438  mp->poisson_angu(tmp, *par1, tmp2) ; // F
439  }
440 
441 
442  tmp2.div_sint() ;
443  tmp2.div_sint() ; // h^{ph ph}
444 
445  idx.set(0) = 3 ; // phi index
446  idx.set(1) = 3 ; // phi index
447  *cmp[position(idx)] = tmp2 ; // h^{ph ph} is updated
448 
449 
450  //------------------- Computation of G and h^[th ph}
451 
452  tmp = taupst ;
453  tmp.mult_cost() ; // T^ph / tan(th)
454 
455  // - 1/sin(th) dT^th/dph + dT^ph/dth + T^ph / tan(th) :
456  tmp = - taut.stdsdp() + taup.dsdt() + tmp ;
457 
458  if (dynamic_cast<const Map_af*>(mp) != 0x0) {
459  tmp2 = tmp.poisson_angu() ; // G
460  }
461  else {
462  tmp2 = 0. ;
463  mp->poisson_angu(tmp, *par2, tmp2) ; // G
464  }
465 
466  tmp2.div_sint() ;
467  tmp2.div_sint() ; // h^{th ph}
468 
469  idx.set(0) = 2 ; // theta index
470  idx.set(1) = 3 ; // phi index
471  *cmp[position(idx)] = tmp2 ; // h^{th ph} is updated
472 
473  // h^{th th} (from the trace-free condition)
474  // ---------
475  idx.set(1) = 2 ; // theta index
476  *cmp[position(idx)] = - operator()(1,1) - operator()(3,3) ;
477 
478 
479  Sym_tensor_trans::del_deriv() ; //## in order not to delete p_eta and p_mu
480 
481 
482 
483 }
484 
485 
486  //-----------------//
487  // set_A_tilde_B //
488  //-----------------//
489 
490 void Sym_tensor_tt::set_A_tildeB(const Scalar& a_in, const Scalar& tb_in,
491  Param* par_bc, Param* par_mat) {
492 
493  Scalar zero(*mp) ;
494  zero.set_etat_zero() ;
495  set_AtB_trace(a_in, tb_in, zero, par_bc, par_mat) ;
496  return ;
497 }
498 
499 
500 
501 
502 
503 
504 }
Scalar * p_mu
Field such that the components of the tensor are written (has only meaning with spherical component...
Definition: sym_tensor.h:277
int & set(int i)
Read/write of a particular element (index i ) (1D case)
Definition: itbl.h:247
void mult_r()
Multiplication by r everywhere; dzpuis is not changed.
Lorene prototypes.
Definition: app_hor.h:67
void set_rr_eta_mu(const Scalar &hrr, const Scalar &eta_i, const Scalar &mu_i)
Sets the component , as well as the angular potentials and (see members p_eta and p_mu )...
const Scalar & dsdt() const
Returns of *this .
Definition: scalar_deriv.C:208
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
void mult_sint()
Multiplication by .
Basic integer array class.
Definition: itbl.h:122
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition: tensor.h:309
Scalar poisson_angu(double lambda=0) const
Solves the (generalized) angular Poisson equation with *this as source.
Definition: scalar_pde.C:203
virtual void del_deriv() const
Deletes the derived quantities.
Scalar * p_eta
Field such that the components of the tensor are written (has only meaning with spherical component...
Definition: sym_tensor.h:263
void set_A_tildeB(const Scalar &a_in, const Scalar &tb_in, Param *par_bc=0x0, Param *par_mat=0x0)
Assigns the derived members A and .
void set_AtB_trace(const Scalar &a_in, const Scalar &tb_in, const Scalar &trace, Param *par_bc=0x0, Param *par_mat=0x0)
Assigns the derived members A , and the trace.
void set_khi_eta_mu(const Scalar &khi_i, const Scalar &eta_i, const Scalar &mu_i)
Sets the component , as well as the angular potentials and (see members p_khi , p_eta and p_mu )...
const Scalar & khi() const
Gives the field such that the component .
void set_rr_mu(const Scalar &hrr, const Scalar &mu_i)
Sets the component , as well as the angular potential (see member p_mu ).
int get_dzpuis() const
Returns dzpuis.
Definition: scalar.h:563
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.h:321
virtual const Scalar & eta(Param *par=0x0) const
Gives the field (see member p_eta ).
Parameter storage.
Definition: param.h:125
const Scalar & stdsdp() const
Returns of *this .
Definition: scalar_deriv.C:238
void mult_cost()
Multiplication by .
void set_khi_mu(const Scalar &khi_i, const Scalar &mu_i, int dzp=0, Param *par1=0x0, Param *par2=0x0, Param *par3=0x0)
Sets the component , as well as the angular potential (see member p_khi and p_mu )...
void update(int dzp, Param *par1=0x0, Param *par2=0x0)
Computes the components , , , and , from and the potentials and .
const Scalar & srdsdt() const
Returns of *this .
Definition: scalar_deriv.C:145
Scalar * p_khi
Field such that the component .
Definition: sym_tensor.h:941
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Definition: tensor_sym.C:248
const Scalar & dsdr() const
Returns of *this .
Definition: scalar_deriv.C:113
const Scalar & operator()(const Itbl &ind) const
Returns the value of a component (read-only version).
Definition: tensor.C:807
void div_sint()
Division by .
bool check_dzpuis(int dzi) const
Returns false if the last domain is compactified and *this is not zero in this domain and dzpuis is n...
Definition: scalar.C:879
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:301
void div_r_dzpuis(int ced_mult_r)
Division by r everywhere but with the output flag dzpuis set to ced_mult_r .
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values of the Scalar in the co...
virtual void poisson_angu(const Scalar &source, Param &par, Scalar &uu, double lambda=0) const =0
Computes the solution of the generalized angular Poisson equation.
void mult_r_dzpuis(int ced_mult_r)
Multiplication by r everywhere but with the output flag dzpuis set to ced_mult_r ...
const Scalar & srstdsdp() const
Returns of *this .
Definition: scalar_deriv.C:177