Debian Codegraph @

C++/Source/Tensor/vector_divfree.C

raw
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 // ----------------
91 Vector_divfree::Vector_divfree (const Vector_divfree& source) :
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
117 Vector_divfree::~Vector_divfree () {
118
119 Vector_divfree::del_deriv() ;
120
121 }
122
123
124 //-------------------//
125 // Memory managment //
126 //-------------------//
127
128 void Vector_divfree::del_deriv() const {
129
130 set_der_0x0() ;
131 Vector::del_deriv() ;
132
133 }
134
135 void Vector_divfree::set_der_0x0() const {}
136
137 //-------------------------//
138 // Mutators / assignment //
139 //-------------------------//
140
141 void Vector_divfree::operator=(const Vector_divfree& source) {
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 }