LORENE
vector_etamu.C
1 /*
2  * Methods of class Vector related to eta and mu
3  *
4  * (see file vector.h for documentation)
5  *
6  */
7 
8 /*
9  * Copyright (c) 2005 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: vector_etamu.C,v 1.5 2016/12/05 16:18:18 j_novak Exp $
34  * $Log: vector_etamu.C,v $
35  * Revision 1.5 2016/12/05 16:18:18 j_novak
36  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37  *
38  * Revision 1.4 2014/10/13 08:53:45 j_novak
39  * Lorene classes and functions now belong to the namespace Lorene.
40  *
41  * Revision 1.3 2014/10/06 15:13:21 j_novak
42  * Modified #include directives to use c++ syntax.
43  *
44  * Revision 1.2 2008/08/27 08:52:23 jl_cornou
45  * Added fonctions for angular potential A
46  *
47  * Revision 1.1 2005/02/14 13:01:50 j_novak
48  * p_eta and p_mu are members of the class Vector. Most of associated functions
49  * have been moved from the class Vector_divfree to the class Vector.
50  *
51  *
52  * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_etamu.C,v 1.5 2016/12/05 16:18:18 j_novak Exp $
53  *
54  */
55 
56 // Headers C
57 #include <cstdlib>
58 #include <cassert>
59 
60 // Headers Lorene
61 #include "tensor.h"
62 
63  //--------------//
64  // eta //
65  //--------------//
66 
67 
68 namespace Lorene {
69 const Scalar& Vector::eta() const {
70 
71 
72  if (p_eta == 0x0) { // a new computation is necessary
73 
74  // All this has a meaning only for spherical components:
75 #ifndef NDEBUG
76  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
77  assert(bvs != 0x0) ;
78 #endif
79 
80  // eta is computed from its definition:
81  Scalar sou_eta = *cmp[1] ; //V^th
82  sou_eta.div_tant() ;
83  sou_eta += cmp[1]->dsdt() + cmp[2]->stdsdp();
84 
85  // Resolution of the angular Poisson equation for eta
86  // --------------------------------------------------
87  p_eta = new Scalar( sou_eta.poisson_angu() ) ;
88 
89  }
90 
91  return *p_eta ;
92 
93 }
94 
95 
96  //--------------//
97  // mu //
98  //--------------//
99 
100 
101 const Scalar& Vector::mu() const {
102 
103 
104  if (p_mu == 0x0) { // a new computation is necessary
105 
106  // All this has a meaning only for spherical components:
107 #ifndef NDEBUG
108  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
109  assert(bvs != 0x0) ;
110 #endif
111 
112  Scalar tmp = *cmp[2] ; // V^ph
113  tmp.div_tant() ; // V^ph / tan(th)
114 
115  // dV^ph/dth + V^ph/tan(th) - 1/sin(th) dV^th/dphi
116  tmp += cmp[2]->dsdt() - cmp[1]->stdsdp() ;
117 
118  // Resolution of the angular Poisson equation for mu
119  // --------------------------------------------------
120  p_mu = new Scalar( tmp.poisson_angu() ) ;
121 
122  }
123 
124  return *p_mu ;
125 
126 }
127 
128  //-----------//
129  // A //
130  //-----------//
131 
132 const Scalar& Vector::A() const {
133 
134 
135  if (p_A == 0x0) { // A new computation is necessary
136 
137  // All this has a meaning only for spherical components :
138 #ifndef NDEBUG
139  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
140  assert(bvs != 0x0) ;
141 #endif
142 
143  // p_eta doit ĂȘtre calculĂ©
144  if (p_eta == 0x0) { Scalar etatmp = this->eta(); }
145 
146  Scalar tmp = -*cmp[0] ; // -V^r
147  tmp.div_r_dzpuis(2); // -V^r/r
148 
149  Scalar eta_tilde = *p_eta ;
150  Scalar etad = eta_tilde.dsdr() ;
151  eta_tilde.div_r_dzpuis(2);
152  etad.set_dzpuis(2);
153  tmp += etad + eta_tilde ; // d eta / dr + eta/r
154 
155  p_A = new Scalar (tmp) ;
156  }
157 
158  return *p_A ;
159 }
160 
161 
162 
163 
164 
165  //----------------//
166  // update_vtvp //
167  //----------------//
168 
169 
171 
172  assert( (p_eta != 0x0) && (p_mu != 0x0) ) ;
173 
174  // V^theta :
175  *cmp[1] = p_eta->dsdt() - p_mu->stdsdp() ;
176 
177  // V^phi :
178  *cmp[2] = p_eta->stdsdp() + p_mu->dsdt() ;
179 
180  Scalar* p_eta_tmp = p_eta ; //## in order not to delete p_eta and p_mu
181  p_eta = 0x0 ;
182  Scalar* p_mu_tmp = p_mu ;
183  p_mu = 0x0 ;
185 
186  p_eta = p_eta_tmp ;
187  p_mu = p_mu_tmp ;
188 
189 }
190 
191 
192 void Vector::set_vr_eta_mu(const Scalar& vr_i, const Scalar& eta_i,
193  const Scalar& mu_i) {
194 
195  // All this has a meaning only for spherical components:
196  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
197  assert(&vr_i.get_mp() == &eta_i.get_mp()) ;
198 
199  del_deriv() ;
200 
201  // V^r
202  *cmp[0] = vr_i ;
203 
204  p_eta = new Scalar( eta_i ) ; // eta
205 
206  p_mu = new Scalar( mu_i ) ; // mu
207 
208  update_vtvp() ;
209 
210  return ;
211 }
212 
213 
214 
215 
216 
217 }
Lorene prototypes.
Definition: app_hor.h:67
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
Scalar * p_A
Field defined by Insensitive to the longitudinal part of the vector, related to the curl...
Definition: vector.h:241
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition: tensor.h:309
void update_vtvp()
Computes the components and from the potential and , according to: .
Definition: vector_etamu.C:170
Scalar poisson_angu(double lambda=0) const
Solves the (generalized) angular Poisson equation with *this as source.
Definition: scalar_pde.C:203
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition: scalar.C:814
virtual const Scalar & eta() const
Gives the field such that the angular components of the vector are written: .
Definition: vector_etamu.C:69
virtual void del_deriv() const
Deletes the derived quantities.
Definition: vector.C:222
void set_vr_eta_mu(const Scalar &vr_i, const Scalar &eta_i, const Scalar &mu_i)
Defines the components through potentials and (see members p_eta and p_mu ), as well as the compon...
Definition: vector_etamu.C:192
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.h:321
const Scalar & stdsdp() const
Returns of *this .
Definition: scalar_deriv.C:238
Scalar * p_mu
Field such that the angular components of the vector are written: .
Definition: vector.h:233
virtual const Scalar & A() const
Gives the field defined by Related to the curl, A is insensitive to the longitudinal part of the ve...
Definition: vector_etamu.C:132
Spherical orthonormal vectorial bases (triads).
Definition: base_vect.h:308
const Scalar & dsdr() const
Returns of *this .
Definition: scalar_deriv.C:113
virtual const Scalar & mu() const
Gives the field such that the angular components of the vector are written: .
Definition: vector_etamu.C:101
Scalar * p_eta
Field such that the angular components of the vector are written: .
Definition: vector.h:219
void div_r_dzpuis(int ced_mult_r)
Division by r everywhere but with the output flag dzpuis set to ced_mult_r .
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:874
void div_tant()
Division by .