vector_divfree.C

00001 /*
00002  *  Methods of class Vector_divfree
00003  *
00004  *   (see file vector.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License as published by
00015  *   the Free Software Foundation; either version 2 of the License, or
00016  *   (at your option) any later version.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 
00030 char vector_divfree_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_divfree.C,v 1.6 2005/02/14 13:01:50 j_novak Exp $" ;
00031 
00032 /*
00033  * $Id: vector_divfree.C,v 1.6 2005/02/14 13:01:50 j_novak Exp $
00034  * $Log: vector_divfree.C,v $
00035  * Revision 1.6  2005/02/14 13:01:50  j_novak
00036  * p_eta and p_mu are members of the class Vector. Most of associated functions
00037  * have been moved from the class Vector_divfree to the class Vector.
00038  *
00039  * Revision 1.5  2003/11/03 22:32:36  e_gourgoulhon
00040  * Parameters of methods set_vr_eta_mu and set_vr_mu are now all references.
00041  *
00042  * Revision 1.4  2003/10/22 13:08:06  j_novak
00043  * Better handling of dzpuis flags
00044  *
00045  * Revision 1.3  2003/10/17 16:34:32  e_gourgoulhon
00046  * Added new methods set_vr_eta_mu and set_vr_mu.
00047  *
00048  * Revision 1.2  2003/10/15 13:52:57  j_novak
00049  * Initialization of met_div in the copy constructor
00050  *
00051  * Revision 1.1  2003/10/13 20:53:53  e_gourgoulhon
00052  * First version
00053  *
00054  *
00055  * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_divfree.C,v 1.6 2005/02/14 13:01:50 j_novak Exp $
00056  *
00057  */
00058 
00059 // Headers C
00060 #include <stdlib.h>
00061 #include <assert.h>
00062 
00063 // Headers Lorene
00064 #include "tensor.h"
00065 
00066             //--------------//
00067             // Constructors //
00068             //--------------//
00069 
00070 // Standard constructor 
00071 // --------------------
00072 Vector_divfree::Vector_divfree(const Map& map, const Base_vect& triad_i,
00073         const Metric& met) 
00074         : Vector(map, CON, triad_i),
00075             met_div(&met) {
00076         
00077   set_der_0x0() ;
00078 
00079 }
00080 
00081     
00082 // Copy constructor
00083 // ----------------
00084 Vector_divfree::Vector_divfree (const Vector_divfree& source) : 
00085     Vector(source), met_div(source.met_div) {
00086   
00087     set_der_0x0() ;
00088     if (source.p_eta != 0x0) p_eta = new Scalar(*(source.p_eta)) ;
00089     if (source.p_mu != 0x0) p_mu = new Scalar(*(source.p_mu)) ;
00090 
00091 }   
00092 
00093 
00094 // Constructor from a file
00095 // -----------------------
00096 Vector_divfree::Vector_divfree(const Map& mapping, const Base_vect& triad_i, 
00097     const Metric& met, FILE* fd) : Vector(mapping, triad_i, fd),
00098     met_div(&met) {
00099    
00100   set_der_0x0() ;
00101 
00102 }
00103 
00104 
00105             //--------------//
00106             //  Destructor  //
00107             //--------------//
00108 
00109 
00110 Vector_divfree::~Vector_divfree () {
00111 
00112   Vector_divfree::del_deriv() ;
00113 
00114 }
00115 
00116 
00117             //-------------------//
00118             // Memory managment  //
00119             //-------------------//
00120 
00121 void Vector_divfree::del_deriv() const {
00122 
00123   set_der_0x0() ;
00124   Vector::del_deriv() ;
00125 
00126 }
00127 
00128 void Vector_divfree::set_der_0x0() const {}
00129 
00130         //-------------------------//
00131         //  Mutators / assignment  //
00132         //-------------------------//
00133 
00134 void Vector_divfree::operator=(const Vector_divfree& source) {
00135     
00136     // Assignment of quantities common to all the derived classes of Vector
00137     Vector::operator=(source) ; 
00138 
00139     // Assignment of proper quantities of class Vector_divfree
00140     assert(met_div == source.met_div) ; 
00141     
00142     del_deriv() ;   
00143     
00144 }
00145 
00146 void Vector_divfree::operator=(const Vector& source) {
00147     
00148   // Assignment of quantities common to all the derived classes of Vector
00149   Vector::operator=(source) ; 
00150 
00151   //The metric which was set by the constructor is kept
00152 
00153   del_deriv() ;
00154 }
00155 
00156 void Vector_divfree::operator=(const Tensor& source) {
00157     
00158   // Assignment of quantities common to all the derived classes of Vector
00159   Vector::operator=(source) ; 
00160   
00161   //The metric which was set by the constructor is kept
00162 
00163   del_deriv() ;
00164 }
00165 
00166 
00167 void Vector_divfree::set_vr_mu(const Scalar& vr_i, const Scalar& mu_i) {
00168         
00169         // All this has a meaning only for spherical components:
00170         assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ; 
00171         
00172         del_deriv() ; // delete previous p_eta and p_mu, as well as 
00173                       //  derived quantities
00174         
00175         *cmp[0] = vr_i ;    // V^r
00176         
00177         p_mu = new Scalar( mu_i ) ;     // mu 
00178         
00179         eta() ; // computes eta form the divergence-free condition
00180 
00181         update_vtvp() ; // V^theta and V^phi        
00182 
00183 }
00184 
00185             
00186 const Scalar& Vector_divfree::eta() const {
00187 
00188 
00189     if (p_eta == 0x0) {   // a new computation is necessary
00190         
00191         // All this has a meaning only for spherical components:
00192         #ifndef NDEBUG 
00193         const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
00194         assert(bvs != 0x0) ; 
00195         #endif
00196 
00197         // eta is computed from the divergence-free condition:
00198         int dzp = cmp[0]->get_dzpuis() ;
00199         Scalar dvr = - cmp[0]->dsdr() ;  // - dV^r/dr  ( -r^2 dV^r/dr in the CED)
00200         dvr.mult_r_dzpuis(dzp) ;
00201 
00202         // Final result for the V^r source for eta:
00203         dvr -= 2. * (*cmp[0]) ; 
00204         
00205         // Resolution of the angular Poisson equation for eta
00206         // --------------------------------------------------
00207         p_eta = new Scalar( dvr.poisson_angu() ) ; 
00208     
00209     }
00210 
00211     return *p_eta ; 
00212 
00213 }
00214 
00215 

Generated on Tue Feb 7 01:35:21 2012 for LORENE by  doxygen 1.4.6