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.6 2024/01/26 17:44:25 g_servignat Exp $
34  * $Log: vector_etamu.C,v $
35  * Revision 1.6 2024/01/26 17:44:25 g_servignat
36  * Updated the Pseudopolytrope_1D class to be consistent with the paper (i.e. with a GPP in the middle)
37  *
38  * Revision 1.5 2016/12/05 16:18:18 j_novak
39  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
40  *
41  * Revision 1.4 2014/10/13 08:53:45 j_novak
42  * Lorene classes and functions now belong to the namespace Lorene.
43  *
44  * Revision 1.3 2014/10/06 15:13:21 j_novak
45  * Modified #include directives to use c++ syntax.
46  *
47  * Revision 1.2 2008/08/27 08:52:23 jl_cornou
48  * Added fonctions for angular potential A
49  *
50  * Revision 1.1 2005/02/14 13:01:50 j_novak
51  * p_eta and p_mu are members of the class Vector. Most of associated functions
52  * have been moved from the class Vector_divfree to the class Vector.
53  *
54  *
55  * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_etamu.C,v 1.6 2024/01/26 17:44:25 g_servignat Exp $
56  *
57  */
58 
59 // Headers C
60 #include <cstdlib>
61 #include <cassert>
62 
63 // Headers Lorene
64 #include "tensor.h"
65 
66  //--------------//
67  // eta //
68  //--------------//
69 
70 
71 namespace Lorene {
72 const Scalar& Vector::eta() const {
73 
74 
75  if (p_eta == 0x0) { // a new computation is necessary
76 
77  // All this has a meaning only for spherical components:
78 #ifndef NDEBUG
79  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
80  assert(bvs != 0x0) ;
81 #endif
82 
83  // eta is computed from its definition:
84  Scalar sou_eta = *cmp[1] ; //V^th
85  sou_eta.div_tant() ;
86  sou_eta += cmp[1]->dsdt() + cmp[2]->stdsdp();
87  // cout << "sou_eta: " << *sou_eta.get_spectral_va().c << endl;
88  // sou_eta.set_spectral_va().ylm() ;
89  // sou_eta.spectral_display(" ", 1e-10) ;
90  // abort() ;
91  // Resolution of the angular Poisson equation for eta
92  // --------------------------------------------------
93  p_eta = new Scalar( sou_eta.poisson_angu() ) ;
94 
95  }
96 
97  return *p_eta ;
98 
99 }
100 
101 
102  //--------------//
103  // mu //
104  //--------------//
105 
106 
107 const Scalar& Vector::mu() const {
108 
109 
110  if (p_mu == 0x0) { // a new computation is necessary
111 
112  // All this has a meaning only for spherical components:
113 #ifndef NDEBUG
114  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
115  assert(bvs != 0x0) ;
116 #endif
117 
118  Scalar tmp = *cmp[2] ; // V^ph
119  tmp.div_tant() ; // V^ph / tan(th)
120 
121  // dV^ph/dth + V^ph/tan(th) - 1/sin(th) dV^th/dphi
122  tmp += cmp[2]->dsdt() - cmp[1]->stdsdp() ;
123 
124  // Resolution of the angular Poisson equation for mu
125  // --------------------------------------------------
126  p_mu = new Scalar( tmp.poisson_angu() ) ;
127 
128  }
129 
130  return *p_mu ;
131 
132 }
133 
134  //-----------//
135  // A //
136  //-----------//
137 
138 const Scalar& Vector::A() const {
139 
140 
141  if (p_A == 0x0) { // A new computation is necessary
142 
143  // All this has a meaning only for spherical components :
144 #ifndef NDEBUG
145  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
146  assert(bvs != 0x0) ;
147 #endif
148 
149  // p_eta doit ĂȘtre calculĂ©
150  if (p_eta == 0x0) { Scalar etatmp = this->eta(); }
151 
152  Scalar tmp = -*cmp[0] ; // -V^r
153  tmp.div_r_dzpuis(2); // -V^r/r
154 
155  Scalar eta_tilde = *p_eta ;
156  Scalar etad = eta_tilde.dsdr() ;
157  eta_tilde.div_r_dzpuis(2);
158  etad.set_dzpuis(2);
159  tmp += etad + eta_tilde ; // d eta / dr + eta/r
160 
161  p_A = new Scalar (tmp) ;
162  }
163 
164  return *p_A ;
165 }
166 
167 
168 
169 
170 
171  //----------------//
172  // update_vtvp //
173  //----------------//
174 
175 
177 
178  assert( (p_eta != 0x0) && (p_mu != 0x0) ) ;
179 
180  // V^theta :
181  *cmp[1] = p_eta->dsdt() - p_mu->stdsdp() ;
182 
183  // V^phi :
184  *cmp[2] = p_eta->stdsdp() + p_mu->dsdt() ;
185 
186  Scalar* p_eta_tmp = p_eta ; //## in order not to delete p_eta and p_mu
187  p_eta = 0x0 ;
188  Scalar* p_mu_tmp = p_mu ;
189  p_mu = 0x0 ;
191 
192  p_eta = p_eta_tmp ;
193  p_mu = p_mu_tmp ;
194 
195 }
196 
197 
198 void Vector::set_vr_eta_mu(const Scalar& vr_i, const Scalar& eta_i,
199  const Scalar& mu_i) {
200 
201  // All this has a meaning only for spherical components:
202  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
203  assert(&vr_i.get_mp() == &eta_i.get_mp()) ;
204 
205  del_deriv() ;
206 
207  // V^r
208  *cmp[0] = vr_i ;
209 
210  p_eta = new Scalar( eta_i ) ; // eta
211 
212  p_mu = new Scalar( mu_i ) ; // mu
213 
214  update_vtvp() ;
215 
216  return ;
217 }
218 
219 
220 
221 
222 
223 }
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:176
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:72
virtual void del_deriv() const
Deletes the derived quantities.
Definition: vector.C:225
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:198
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:138
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:107
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 .