star_bin_upmetr_der.C

00001 /*
00002  * Methods Star_bin::update_metric_der_comp
00003  *
00004  * (see file star.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2004 Francois Limousin
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 star_bin_upmetr_der_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_bin_upmetr_der.C,v 1.15 2006/05/24 16:52:50 f_limousin Exp $" ;
00031 
00032 /*
00033  * $Id: star_bin_upmetr_der.C,v 1.15 2006/05/24 16:52:50 f_limousin Exp $
00034  * $Log: star_bin_upmetr_der.C,v $
00035  * Revision 1.15  2006/05/24 16:52:50  f_limousin
00036  * New computation of tkij_comp
00037  *
00038  * Revision 1.14  2005/09/13 19:38:31  f_limousin
00039  * Reintroduction of the resolution of the equations in cartesian coordinates.
00040  *
00041  * Revision 1.13  2005/02/24 16:26:46  f_limousin
00042  * Add the name of the variable for the companion which is now used
00043  * to compute dlogn_comp, dlnq_comp...
00044  *
00045  * Revision 1.12  2005/02/24 16:07:23  f_limousin
00046  * Improve the computation of dlogn, dlnq and dlnpsi. We import the part
00047  * coming from the companion and add the auto part.
00048  *
00049  * Revision 1.11  2005/02/18 13:14:18  j_novak
00050  * Changing of malloc/free to new/delete + suppression of some unused variables
00051  * (trying to avoid compilation warnings).
00052  *
00053  * Revision 1.10  2005/02/17 17:34:28  f_limousin
00054  * Change the name of some quantities to be consistent with other classes
00055  * (for instance nnn is changed to nn, shift to beta, beta to lnq...)
00056  *
00057  * Revision 1.9  2004/06/22 12:52:47  f_limousin
00058  * Change qq, qq_auto and qq_comp to beta, beta_auto and beta_comp.
00059  *
00060  * Revision 1.8  2004/06/07 16:25:14  f_limousin
00061  * Minor modif.
00062  *
00063  * Revision 1.7  2004/04/08 16:33:32  f_limousin
00064  * The new variable is ln(Q) instead of Q=psi^2*N. It improves the
00065  * convergence of the code.
00066  *
00067  * Revision 1.6  2004/03/23 10:00:09  f_limousin
00068  * We now make the derivation with respect to the metric tilde
00069  * instead of the flat metric for the computation of dshift_comp.
00070  *
00071  * Revision 1.5  2004/02/27 09:53:14  f_limousin
00072  * Correction of an error on the computation of kcar_comp.
00073  *
00074  * Revision 1.4  2004/02/18 18:47:01  e_gourgoulhon
00075  * divshift_comp now computed via Tensor::divergence, the
00076  * method Tensor::scontract having disappeared.
00077  *
00078  * Revision 1.3  2004/01/20 15:20:23  f_limousin
00079  * First version
00080  *
00081  *
00082  * $Header: /cvsroot/Lorene/C++/Source/Star/star_bin_upmetr_der.C,v 1.15 2006/05/24 16:52:50 f_limousin Exp $
00083  *
00084  */
00085 
00086 // C headers
00087 #include <math.h>
00088 
00089 // Headers Lorene
00090 #include "star.h"
00091 #include "utilitaires.h"
00092 #include "graphique.h"
00093 
00094 void Star_bin::update_metric_der_comp(const Star_bin& comp, double om) {
00095   
00096   // Derivatives of metric coefficients
00097   // ----------------------------------
00098   
00099     // dcov_logn 
00100     Vector temp ((comp.logn_auto).derive_cov(comp.get_flat())) ;
00101     temp.dec_dzpuis(2) ;
00102     temp.change_triad(temp.get_mp().get_bvect_cart()) ;
00103     temp.change_triad(mp.get_bvect_cart()) ;
00104     Base_val sauve_base1 (temp(1).get_spectral_va().get_base()) ;
00105     Base_val sauve_base2 (temp(2).get_spectral_va().get_base()) ;
00106     Base_val sauve_base3 (temp(3).get_spectral_va().get_base()) ;
00107     assert ( *(temp.get_triad()) == *(dcov_logn.get_triad())) ;
00108     
00109     dcov_logn.set(1).import(temp(1)) ;
00110     dcov_logn.set(2).import(temp(2)) ;
00111     dcov_logn.set(3).import(temp(3)) ;
00112 
00113     dcov_logn.set(1).set_spectral_va().set_base(sauve_base1) ;
00114     dcov_logn.set(2).set_spectral_va().set_base(sauve_base2) ;
00115     dcov_logn.set(3).set_spectral_va().set_base(sauve_base3) ;
00116     dcov_logn.inc_dzpuis(2) ;
00117 
00118     dcov_logn = dcov_logn + logn_auto.derive_cov(flat) ;
00119 
00120     // dcon_logn 
00121     Vector temp_con((comp.logn_auto).derive_con(comp.get_flat())) ;
00122     temp_con.dec_dzpuis(2) ;
00123     temp_con.change_triad(temp_con.get_mp().get_bvect_cart()) ;
00124     temp_con.change_triad(mp.get_bvect_cart()) ;
00125     sauve_base1 = temp_con(1).get_spectral_va().get_base() ;
00126     sauve_base2 = temp_con(2).get_spectral_va().get_base() ;
00127     sauve_base3 = temp_con(3).get_spectral_va().get_base() ;
00128     assert ( *(temp_con.get_triad()) == *(dcon_logn.get_triad())) ;
00129     
00130     dcon_logn.set(1).import(temp_con(1)) ;
00131     dcon_logn.set(2).import(temp_con(2)) ;
00132     dcon_logn.set(3).import(temp_con(3)) ;
00133 
00134     dcon_logn.set(1).set_spectral_va().set_base(sauve_base1) ;
00135     dcon_logn.set(2).set_spectral_va().set_base(sauve_base2) ;
00136     dcon_logn.set(3).set_spectral_va().set_base(sauve_base3) ;
00137     dcon_logn.inc_dzpuis(2) ;
00138 
00139     dcon_logn = dcon_logn + logn_auto.derive_con(flat) ;
00140 
00141     // dcov_phi 
00142     temp = (0.5*(comp.lnq_auto-comp.logn_auto)).derive_cov(comp.get_flat()) ;
00143     temp.dec_dzpuis(2) ;
00144     temp.change_triad(temp.get_mp().get_bvect_cart()) ;
00145     temp.change_triad(mp.get_bvect_cart()) ;
00146     sauve_base1 = temp(1).get_spectral_va().get_base() ;
00147     sauve_base2 = temp(2).get_spectral_va().get_base() ;
00148     sauve_base3 = temp(3).get_spectral_va().get_base() ;
00149     assert ( *(temp.get_triad()) == *(dcov_phi.get_triad())) ;
00150     
00151     dcov_phi.set(1).import(temp(1)) ;
00152     dcov_phi.set(2).import(temp(2)) ;
00153     dcov_phi.set(3).import(temp(3)) ;
00154 
00155     dcov_phi.set(1).set_spectral_va().set_base(sauve_base1) ;
00156     dcov_phi.set(2).set_spectral_va().set_base(sauve_base2) ;
00157     dcov_phi.set(3).set_spectral_va().set_base(sauve_base3) ;
00158     dcov_phi.inc_dzpuis(2) ;
00159 
00160     dcov_phi = dcov_phi + 0.5*(lnq_auto - logn_auto).derive_cov(flat) ;
00161 
00162     // dcon_phi 
00163     temp_con = (0.5*(comp.lnq_auto-comp.logn_auto))
00164     .derive_con(comp.get_flat()) ;
00165     temp_con.dec_dzpuis(2) ;
00166     temp_con.change_triad(temp_con.get_mp().get_bvect_cart()) ;
00167     temp_con.change_triad(mp.get_bvect_cart()) ;
00168     sauve_base1 = temp_con(1).get_spectral_va().get_base() ;
00169     sauve_base2 = temp_con(2).get_spectral_va().get_base() ;
00170     sauve_base3 = temp_con(3).get_spectral_va().get_base() ;
00171     assert ( *(temp_con.get_triad()) == *(dcon_phi.get_triad())) ;
00172     
00173     dcon_phi.set(1).import(temp_con(1)) ;
00174     dcon_phi.set(2).import(temp_con(2)) ;
00175     dcon_phi.set(3).import(temp_con(3)) ;
00176 
00177     dcon_phi.set(1).set_spectral_va().set_base(sauve_base1) ;
00178     dcon_phi.set(2).set_spectral_va().set_base(sauve_base2) ;
00179     dcon_phi.set(3).set_spectral_va().set_base(sauve_base3) ;
00180     dcon_phi.inc_dzpuis(2) ;
00181 
00182     dcon_phi = dcon_phi + 0.5*(lnq_auto - logn_auto).derive_con(flat) ;
00183 
00184     
00185   // Construction of Omega d/dphi
00186   // ----------------------------
00187   
00188   const Mg3d* mg = mp.get_mg() ; 
00189   int nz = mg->get_nzone() ;        // total number of domains
00190   Vector omdsdp (mp, CON, mp.get_bvect_cart()) ;
00191   Scalar yya (mp) ;
00192   yya = mp.ya ;
00193   Scalar xxa (mp) ;
00194   xxa = mp.xa ;
00195   
00196   if (fabs(mp.get_rot_phi()) < 1e-10){ 
00197     omdsdp.set(1) = - om * yya ;
00198     omdsdp.set(2) = om * xxa ;
00199     omdsdp.set(3).annule_hard() ;
00200   }
00201   else{
00202     omdsdp.set(1) = om * yya ;
00203     omdsdp.set(2) = - om * xxa ;
00204     omdsdp.set(3).annule_hard() ;
00205   }
00206   
00207   omdsdp.set(1).set_spectral_va()
00208     .set_base(*(mp.get_mg()->std_base_vect_cart()[0])) ;
00209   omdsdp.set(2).set_spectral_va()
00210     .set_base(*(mp.get_mg()->std_base_vect_cart()[1])) ;
00211   omdsdp.set(3).set_spectral_va()
00212     .set_base(*(mp.get_mg()->std_base_vect_cart()[2])) ;
00213   
00214   omdsdp.annule_domain(nz-1) ;
00215   
00216   // Computation of tkij_comp
00217   // ------------------------
00218   
00219   // Gradient tilde (partial derivatives with respect to
00220   //           the cartesian coordinates of the mapping)
00221   // D~^j beta^i
00222     
00223   const Tensor& dbeta_comp = beta_comp.derive_con(gtilde) ;
00224                         
00225   // Trace of D~_j beta^i  :
00226   Scalar divbeta_comp = beta_comp.divergence(gtilde) ;
00227           
00228   // Computation of K^{ij}
00229   // -------------------------
00230   
00231   for (int i=1; i<=3; i++) 
00232     for (int j=i; j<=3; j++) {
00233       
00234       tkij_comp.set(i, j) = dbeta_comp(i, j) + dbeta_comp(j, i) - 
00235     double(2) /double(3) * divbeta_comp * (gtilde.con())(i,j) ; 
00236     }
00237   
00238   // Addition (or not !) of u^{ij}
00239   tkij_comp = tkij_comp - 0*hij_comp.derive_lie(omdsdp) ;
00240 
00241   tkij_comp = 0.5 * tkij_comp / nn ;
00242   
00243   /*
00244   Sym_tensor aa_comp (mp, CON, mp.get_bvect_cart()) ;
00245   aa_comp.set_etat_qcq() ;
00246   Sym_tensor comp_aa (comp.get_tkij_auto()) ; 
00247   comp_aa.dec_dzpuis(2) ;
00248   comp_aa.change_triad(mp.get_bvect_cart()) ;
00249  
00250   
00251   assert(*(aa_comp.get_triad()) == *(comp_aa.get_triad())) ;
00252   // importations :
00253   for (int i=1 ; i<=3 ; i++)
00254     for (int j=i ; j<=3 ; j++) {
00255       aa_comp.set(i, j).import(comp_aa(i, j)) ;
00256       aa_comp.set(i, j).set_spectral_va().set_base(comp_aa(i, j).
00257                       get_spectral_va().get_base()) ;
00258     }
00259   aa_comp.inc_dzpuis(2) ;
00260 
00261   for (int i=1 ; i<=3 ; i++)
00262     for (int j=i ; j<=3 ; j++)
00263       for (int l=0 ; l<=nz-2 ; l++) 
00264     tkij_comp.set(i,j).set_domain(l) = aa_comp(i,j).domain(l) ;
00265   */
00266 
00267 
00268   // Computation of kcar_comp
00269   // ------------------------
00270   
00271   Sym_tensor tkij_auto_cov = tkij_auto.up_down(gtilde) ;
00272   
00273   kcar_comp = contract(tkij_auto_cov, 0, 1, tkij_comp, 0, 1,true) ; 
00274   
00275   // The derived quantities are obsolete
00276   // -----------------------------------
00277   
00278   del_deriv() ;
00279   
00280 }      
00281 

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