LORENE
vector_divfree.C
1 /*
2  * Methods of class Vector_divfree
3  *
4  * (see file vector.h for documentation)
5  *
6  */
7 
8 /*
9  * Copyright (c) 2003 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 char vector_divfree_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_divfree.C,v 1.8 2014/10/13 08:53:44 j_novak Exp $" ;
31 
32 /*
33  * $Id: vector_divfree.C,v 1.8 2014/10/13 08:53:44 j_novak Exp $
34  * $Log: vector_divfree.C,v $
35  * Revision 1.8 2014/10/13 08:53:44 j_novak
36  * Lorene classes and functions now belong to the namespace Lorene.
37  *
38  * Revision 1.7 2014/10/06 15:13:21 j_novak
39  * Modified #include directives to use c++ syntax.
40  *
41  * Revision 1.6 2005/02/14 13:01:50 j_novak
42  * p_eta and p_mu are members of the class Vector. Most of associated functions
43  * have been moved from the class Vector_divfree to the class Vector.
44  *
45  * Revision 1.5 2003/11/03 22:32:36 e_gourgoulhon
46  * Parameters of methods set_vr_eta_mu and set_vr_mu are now all references.
47  *
48  * Revision 1.4 2003/10/22 13:08:06 j_novak
49  * Better handling of dzpuis flags
50  *
51  * Revision 1.3 2003/10/17 16:34:32 e_gourgoulhon
52  * Added new methods set_vr_eta_mu and set_vr_mu.
53  *
54  * Revision 1.2 2003/10/15 13:52:57 j_novak
55  * Initialization of met_div in the copy constructor
56  *
57  * Revision 1.1 2003/10/13 20:53:53 e_gourgoulhon
58  * First version
59  *
60  *
61  * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_divfree.C,v 1.8 2014/10/13 08:53:44 j_novak Exp $
62  *
63  */
64 
65 // Headers C
66 #include <cstdlib>
67 #include <cassert>
68 
69 // Headers Lorene
70 #include "tensor.h"
71 
72  //--------------//
73  // Constructors //
74  //--------------//
75 
76 // Standard constructor
77 // --------------------
78 namespace Lorene {
79 Vector_divfree::Vector_divfree(const Map& map, const Base_vect& triad_i,
80  const Metric& met)
81  : Vector(map, CON, triad_i),
82  met_div(&met) {
83 
84  set_der_0x0() ;
85 
86 }
87 
88 
89 // Copy constructor
90 // ----------------
92  Vector(source), met_div(source.met_div) {
93 
94  set_der_0x0() ;
95  if (source.p_eta != 0x0) p_eta = new Scalar(*(source.p_eta)) ;
96  if (source.p_mu != 0x0) p_mu = new Scalar(*(source.p_mu)) ;
97 
98 }
99 
100 
101 // Constructor from a file
102 // -----------------------
103 Vector_divfree::Vector_divfree(const Map& mapping, const Base_vect& triad_i,
104  const Metric& met, FILE* fd) : Vector(mapping, triad_i, fd),
105  met_div(&met) {
106 
107  set_der_0x0() ;
108 
109 }
110 
111 
112  //--------------//
113  // Destructor //
114  //--------------//
115 
116 
118 
120 
121 }
122 
123 
124  //-------------------//
125  // Memory managment //
126  //-------------------//
127 
129 
130  set_der_0x0() ;
132 
133 }
134 
136 
137  //-------------------------//
138  // Mutators / assignment //
139  //-------------------------//
140 
142 
143  // Assignment of quantities common to all the derived classes of Vector
144  Vector::operator=(source) ;
145 
146  // Assignment of proper quantities of class Vector_divfree
147  assert(met_div == source.met_div) ;
148 
149  del_deriv() ;
150 
151 }
152 
153 void Vector_divfree::operator=(const Vector& source) {
154 
155  // Assignment of quantities common to all the derived classes of Vector
156  Vector::operator=(source) ;
157 
158  //The metric which was set by the constructor is kept
159 
160  del_deriv() ;
161 }
162 
163 void Vector_divfree::operator=(const Tensor& source) {
164 
165  // Assignment of quantities common to all the derived classes of Vector
166  Vector::operator=(source) ;
167 
168  //The metric which was set by the constructor is kept
169 
170  del_deriv() ;
171 }
172 
173 
174 void Vector_divfree::set_vr_mu(const Scalar& vr_i, const Scalar& mu_i) {
175 
176  // All this has a meaning only for spherical components:
177  assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
178 
179  del_deriv() ; // delete previous p_eta and p_mu, as well as
180  // derived quantities
181 
182  *cmp[0] = vr_i ; // V^r
183 
184  p_mu = new Scalar( mu_i ) ; // mu
185 
186  eta() ; // computes eta form the divergence-free condition
187 
188  update_vtvp() ; // V^theta and V^phi
189 
190 }
191 
192 
193 const Scalar& Vector_divfree::eta() const {
194 
195 
196  if (p_eta == 0x0) { // a new computation is necessary
197 
198  // All this has a meaning only for spherical components:
199  #ifndef NDEBUG
200  const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
201  assert(bvs != 0x0) ;
202  #endif
203 
204  // eta is computed from the divergence-free condition:
205  int dzp = cmp[0]->get_dzpuis() ;
206  Scalar dvr = - cmp[0]->dsdr() ; // - dV^r/dr ( -r^2 dV^r/dr in the CED)
207  dvr.mult_r_dzpuis(dzp) ;
208 
209  // Final result for the V^r source for eta:
210  dvr -= 2. * (*cmp[0]) ;
211 
212  // Resolution of the angular Poisson equation for eta
213  // --------------------------------------------------
214  p_eta = new Scalar( dvr.poisson_angu() ) ;
215 
216  }
217 
218  return *p_eta ;
219 
220 }
221 
222 
223 }
Metric for tensor calculation.
Definition: metric.h:90
virtual void del_deriv() const
Deletes the derived quantities.
Lorene prototypes.
Definition: app_hor.h:64
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
Base class for coordinate mappings.
Definition: map.h:670
const Metric *const met_div
Metric with respect to which the divergence is defined.
Definition: vector.h:730
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition: tensor.h:303
void operator=(const Vector_divfree &a)
Assignment from another Vector_divfree.
void update_vtvp()
Computes the components and from the potential and , according to: .
Definition: vector_etamu.C:167
Tensor field of valence 1.
Definition: vector.h:188
Scalar poisson_angu(double lambda=0) const
Solves the (generalized) angular Poisson equation with *this as source.
Definition: scalar_pde.C:200
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition: base_vect.h:105
void set_der_0x0() const
Sets the pointers on derived quantities to 0x0.
virtual void del_deriv() const
Deletes the derived quantities.
Definition: vector.C:219
int get_dzpuis() const
Returns dzpuis.
Definition: scalar.h:557
virtual ~Vector_divfree()
Destructor.
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.h:315
Scalar * p_mu
Field such that the angular components of the vector are written: .
Definition: vector.h:233
Tensor handling.
Definition: tensor.h:288
virtual const Scalar & eta() const
Gives the field such that the angular components of the vector are written: .
Spherical orthonormal vectorial bases (triads).
Definition: base_vect.h:308
virtual void operator=(const Vector &a)
Assignment from a Vector.
Definition: vector.C:267
Vector_divfree(const Map &map, const Base_vect &triad_i, const Metric &met)
Standard constructor.
void set_vr_mu(const Scalar &vr_i, const Scalar &mu_i)
Sets the angular potentials (see member p_mu ), and the component of the vector.
const Scalar & dsdr() const
Returns of *this .
Definition: scalar_deriv.C:113
Scalar * p_eta
Field such that the angular components of the vector are written: .
Definition: vector.h:219
Divergence-free vectors.
Definition: vector.h:724
void mult_r_dzpuis(int ced_mult_r)
Multiplication by r everywhere but with the output flag dzpuis set to ced_mult_r .