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