star_bin_upmetr.C

00001 /*
00002  * Methods of Star_bin::update_metric
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 char star_binupmetr_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_bin_upmetr.C,v 1.13 2005/09/13 19:38:31 f_limousin Exp $" ;
00030 
00031 /*
00032  * $Id: star_bin_upmetr.C,v 1.13 2005/09/13 19:38:31 f_limousin Exp $
00033  * $Log: star_bin_upmetr.C,v $
00034  * Revision 1.13  2005/09/13 19:38:31  f_limousin
00035  * Reintroduction of the resolution of the equations in cartesian coordinates.
00036  *
00037  * Revision 1.12  2005/02/24 16:05:14  f_limousin
00038  * Change the name of some variables (for instance dcov_logn --> dlogn).
00039  *
00040  * Revision 1.11  2005/02/18 13:14:18  j_novak
00041  * Changing of malloc/free to new/delete + suppression of some unused variables
00042  * (trying to avoid compilation warnings).
00043  *
00044  * Revision 1.10  2005/02/17 17:34:10  f_limousin
00045  * Change the name of some quantities to be consistent with other classes
00046  * (for instance nnn is changed to nn, shift to beta, beta to lnq...)
00047  *
00048  * Revision 1.9  2004/06/22 12:52:26  f_limousin
00049  * Change qq, qq_auto and qq_comp to beta, beta_auto and beta_comp.
00050  *
00051  * Revision 1.8  2004/06/07 16:23:52  f_limousin
00052  * New treatment for conformally flat metrics.
00053  *
00054  * Revision 1.7  2004/04/08 16:33:16  f_limousin
00055  * The new variable is ln(Q) instead of Q=psi^2*N. It improves the
00056  * convergence of the code.
00057  *
00058  * Revision 1.6  2004/03/23 09:58:55  f_limousin
00059  * Add function Star::update_decouple()
00060  *
00061  * Revision 1.5  2004/02/27 10:54:27  f_limousin
00062  * To avoid errors when merging versions of Lorene.
00063  *
00064  * Revision 1.4  2004/02/27 09:56:42  f_limousin
00065  * Many minor changes.
00066  *
00067  * Revision 1.3  2004/02/21 17:05:13  e_gourgoulhon
00068  * Method Scalar::point renamed Scalar::val_grid_point.
00069  * Method Scalar::set_point renamed Scalar::set_grid_point.
00070  *
00071  * Revision 1.2  2004/01/20 15:20:08  f_limousin
00072  * First version
00073  *
00074  *
00075  * $Header: /cvsroot/Lorene/C++/Source/Star/star_bin_upmetr.C,v 1.13 2005/09/13 19:38:31 f_limousin Exp $ *
00076  */
00077 
00078 
00079 // Headers Lorene
00080 #include "cmp.h"
00081 #include "star.h"
00082 #include "graphique.h"
00083 #include "utilitaires.h"
00084 
00085 //----------------------------------//
00086 //   Version without relaxation //
00087 //----------------------------------//
00088 
00089 void Star_bin::update_metric(const Star_bin& comp, double om) {
00090 
00091     // Computation of quantities coming from the companion
00092     // ---------------------------------------------------
00093 
00094     int nz = mp.get_mg()->get_nzone() ;
00095     int nr = mp.get_mg()->get_nr(0);
00096     int nt = mp.get_mg()->get_nt(0);
00097     int np = mp.get_mg()->get_np(0);
00098 
00099     const Map& mp_comp (comp.get_mp()) ;
00100   
00101     if ( (comp.logn_auto).get_etat() == ETATZERO ) {
00102     logn_comp.set_etat_zero() ;
00103     }
00104     else{
00105     logn_comp.set_etat_qcq() ;
00106     logn_comp.import( comp.logn_auto ) ;
00107     logn_comp.std_spectral_base() ;
00108     }
00109 
00110 
00111     beta_comp.set_etat_qcq() ; 
00112     beta_comp.set_triad(mp.get_bvect_cart()) ;
00113 
00114     Vector comp_beta(comp.beta_auto) ;
00115     comp_beta.change_triad(mp_comp.get_bvect_cart()) ;
00116     comp_beta.change_triad(mp.get_bvect_cart()) ;
00117 
00118     assert ( *(beta_comp.get_triad()) == *(comp_beta.get_triad())) ;
00119 
00120     (beta_comp.set(1)).import( comp_beta(1) ) ;  
00121     (beta_comp.set(2)).import( comp_beta(2) ) ;  
00122     (beta_comp.set(3)).import( comp_beta(3) ) ;  
00123 
00124     beta_comp.std_spectral_base() ;   
00125 
00126     if ( (comp.lnq_auto).get_etat()  == ETATZERO ) {
00127     lnq_comp.set_etat_zero() ;
00128     }
00129     else{
00130     lnq_comp.set_etat_qcq() ;  
00131     lnq_comp.import( comp.lnq_auto ) ;
00132     lnq_comp.std_spectral_base() ;
00133     }   
00134 
00135 
00136     hij_comp.set_triad(mp.get_bvect_cart()) ;
00137     Sym_tensor comp_hij(comp.hij_auto) ;
00138     comp_hij.change_triad(mp_comp.get_bvect_cart()) ;
00139     comp_hij.change_triad(mp.get_bvect_cart()) ;
00140 
00141     assert ( *(hij_comp.get_triad()) == *(comp_hij.get_triad())) ;
00142 
00143     for(int i=1; i<=3; i++) 
00144     for(int j=i; j<=3; j++) {
00145     
00146         hij_comp.set(i,j).set_etat_qcq() ;
00147         hij_comp.set(i,j).import( (comp_hij)(i,j) ) ;
00148     }
00149  
00150     hij_comp.std_spectral_base() ;   // set the bases for spectral expansions
00151    
00152 // Lapse function N
00153 // ----------------
00154 
00155     logn = logn_auto + logn_comp ; 
00156 
00157     nn = exp( logn ) ;
00158 
00159     nn.std_spectral_base() ;   // set the bases for spectral expansions
00160 
00161 // Quantity lnq = log(psi^2*N)
00162 // ----------------------
00163 
00164     lnq = lnq_auto + lnq_comp ;
00165     
00166     psi4 = exp(2*lnq) / (nn * nn) ;
00167     psi4.std_spectral_base() ;
00168 
00169 // Shift vector 
00170 // -------------
00171 
00172     beta = beta_auto + beta_comp ;
00173 
00174 // Coefficients of the 3-metric tilde
00175 // ----------------------------------
00176  
00177     Sym_tensor gtilde_con (mp, CON, mp.get_bvect_cart()) ; 
00178     
00179      for(int i=1; i<=3; i++) 
00180     for(int j=i; j<=3; j++) {
00181    
00182         hij.set(i,j) = hij_auto(i,j) + hij_comp(i,j) ;
00183         gtilde_con.set(i,j) = hij(i,j) + flat.con()(i,j) ;
00184     }
00185 
00186      gtilde = gtilde_con ;
00187 
00188      Sym_tensor tens_gamma = gtilde_con / psi4 ;
00189      gamma = tens_gamma ;
00190 
00191 
00192     // For conformally flat metrics
00193     // ----------------------------
00194 
00195     if (conf_flat) {
00196     hij_auto.set_etat_zero() ; 
00197     hij_comp.set_etat_zero() ; 
00198     hij.set_etat_zero() ; 
00199     gtilde = flat ;
00200     tens_gamma = flat.con() / psi4 ;
00201     gamma = tens_gamma ;
00202     }
00203 
00204 
00205     // Determinant of gtilde
00206 
00207     Scalar det_gtilde (gtilde.determinant()) ;
00208        
00209     double* max_det = new double[nz] ;
00210     double* min_det = new double[nz] ;
00211     double* moy_det = new double[nz] ;
00212       
00213     for (int i=0; i<nz; i++){
00214     min_det[i] = 2 ;
00215     moy_det[i] = 0 ;
00216     max_det[i] = 0 ;
00217     }
00218 
00219     for (int l=0; l<nz; l++)
00220     for (int k=0; k<np; k++)
00221         for (int j=0; j<nt; j++)
00222         for (int i=0; i<nr; i++){
00223           
00224             moy_det[l] = moy_det[l] + det_gtilde.val_grid_point(l,k,j,i) ;
00225             if (det_gtilde.val_grid_point(l,k,j,i) > max_det[l]){
00226             max_det[l] = det_gtilde.val_grid_point(l,k,j,i) ;
00227             }
00228             if (det_gtilde.val_grid_point(l,k,j,i) < min_det[l]){
00229             min_det[l] = det_gtilde.val_grid_point(l,k,j,i) ;
00230             }
00231         }
00232      
00233     cout << "average determinant of gtilde in each zone : " << endl ; 
00234     for (int l=0; l<nz; l++){
00235     cout << moy_det[l]/(nr*nt*np) << "  " ;
00236     }
00237     cout << endl ;
00238 
00239       
00240     cout << "maximum of the determinant of gtilde in each zone : " << endl ; 
00241     for (int l=0; l<nz; l++){
00242     cout << max_det[l] << "  " ;
00243     }
00244     cout << endl ;
00245 
00246     cout << "minimum of the determinant of gtilde in each zone : " << endl ; 
00247     for (int l=0; l<nz; l++){
00248     cout << min_det[l] << "  " ;
00249     }
00250     cout << endl ;
00251          
00252     // ... extrinsic curvature (tkij_auto and kcar_auto)
00253     extrinsic_curvature(om) ;
00254 
00255    
00256 // The derived quantities are obsolete
00257 // -----------------------------------
00258 
00259     del_deriv() ;
00260 
00261     delete max_det ;
00262     delete moy_det ;
00263     delete min_det ;
00264 }
00265 
00266 
00267 
00268 //----------------------------------//
00269 //    Version with relaxation   //
00270 //----------------------------------//
00271 
00272 void Star_bin::update_metric(const Star_bin& comp,
00273                  const Star_bin& star_jm1, 
00274                  double relax, double om) {
00275 
00276 
00277      // Computation of quantities coming from the companion
00278     // ---------------------------------------------------
00279 
00280     int nz = mp.get_mg()->get_nzone() ;
00281     int nr = mp.get_mg()->get_nr(0);
00282     int nt = mp.get_mg()->get_nt(0);
00283     int np = mp.get_mg()->get_np(0);
00284   
00285     const Map& mp_comp (comp.get_mp()) ;
00286 
00287     if ( (comp.logn_auto).get_etat() == ETATZERO ) {
00288     logn_comp.set_etat_zero() ;
00289     }
00290     else{
00291     logn_comp.set_etat_qcq() ;
00292     logn_comp.import( comp.logn_auto ) ;
00293     logn_comp.std_spectral_base() ;
00294     }
00295 
00296 
00297     beta_comp.set_etat_qcq() ; 
00298     beta_comp.set_triad(mp.get_bvect_cart()) ;
00299 
00300     Vector comp_beta(comp.beta_auto) ;
00301     comp_beta.change_triad(mp_comp.get_bvect_cart()) ;
00302     comp_beta.change_triad(mp.get_bvect_cart()) ;
00303 
00304     assert ( *(beta_comp.get_triad()) == *(comp_beta.get_triad())) ;
00305 
00306     (beta_comp.set(1)).import( comp_beta(1) ) ;  
00307     (beta_comp.set(2)).import( comp_beta(2) ) ;  
00308     (beta_comp.set(3)).import( comp_beta(3) ) ;  
00309 
00310     beta_comp.std_spectral_base() ;   
00311 
00312  
00313     if ( (comp.lnq_auto).get_etat()  == ETATZERO ) {
00314       lnq_comp.set_etat_zero() ;
00315     }
00316     else{
00317     lnq_comp.set_etat_qcq() ;
00318     lnq_comp.import( comp.lnq_auto ) ;
00319     lnq_comp.std_spectral_base() ;
00320    }    
00321 
00322     hij_comp.set_triad(mp.get_bvect_cart()) ;
00323 
00324     Sym_tensor comp_hij(comp.hij_auto) ;
00325     comp_hij.change_triad(mp_comp.get_bvect_cart()) ;
00326     comp_hij.change_triad(mp.get_bvect_cart()) ;
00327 
00328     assert ( *(hij_comp.get_triad()) == *(comp_hij.get_triad())) ;
00329 
00330 
00331     for(int i=1; i<=3; i++) 
00332     for(int j=i; j<=3; j++) {
00333     
00334         hij_comp.set(i,j).set_etat_qcq() ;
00335         hij_comp.set(i,j).import( (comp_hij)(i,j) ) ;
00336     }
00337  
00338     hij_comp.std_spectral_base() ;
00339   
00340 // Relaxation on logn_comp, beta_comp, lnq_comp, hij_comp
00341 // ---------------------------------------------------------------
00342     double relaxjm1 = 1. - relax ; 
00343     
00344     logn_comp = relax * logn_comp + relaxjm1 * (star_jm1.logn_comp) ; 
00345     
00346     beta_comp = relax * beta_comp + relaxjm1 
00347                                    * (star_jm1.beta_comp) ; 
00348 
00349     lnq_comp = relax * lnq_comp + relaxjm1 * (star_jm1.lnq_comp) ;
00350 
00351        
00352     for(int i=1; i<=3; i++) 
00353     for(int j=i; j<=3; j++) {
00354 
00355         hij_comp.set(i,j) = relax * hij_comp(i,j) 
00356         + relaxjm1 * (star_jm1.hij_comp)(i,j) ; 
00357     
00358     }
00359 
00360 // Lapse function N
00361 // ----------------
00362 
00363     logn = logn_auto + logn_comp ; 
00364 
00365     nn = exp( logn ) ;
00366 
00367     nn.std_spectral_base() ;   // set the bases for spectral expansions
00368 
00369 
00370 // Quantity lnq = log(psi^2 * N)
00371 // --------------------------
00372 
00373     lnq = lnq_auto + lnq_comp ;
00374     
00375     psi4 = exp(2*lnq) / (nn * nn) ;
00376     psi4.std_spectral_base() ;
00377 
00378 // Shift vector
00379 // ------------
00380 
00381     beta = beta_auto + beta_comp ;
00382 
00383 // Coefficients of the 3-metric tilde
00384 // ----------------------------------
00385      
00386     Sym_tensor gtilde_con(mp, CON, mp.get_bvect_cart()) ;
00387 
00388     for(int i=1; i<=3; i++) 
00389     for(int j=i; j<=3; j++) {
00390    
00391         hij.set(i,j) = hij_auto(i,j) + hij_comp(i,j) ;
00392         gtilde_con.set(i,j) = hij(i,j) + flat.con()(i,j) ;
00393     }
00394 
00395     
00396     gtilde = gtilde_con ;
00397     Sym_tensor tens_gamma(gtilde_con / psi4) ;
00398     gamma = tens_gamma ;
00399 
00400     // For conformally flat metrics
00401     // ----------------------------
00402 
00403     if (conf_flat) {
00404     hij_auto.set_etat_zero() ; 
00405     hij_comp.set_etat_zero() ; 
00406     hij.set_etat_zero() ; 
00407     gtilde = flat ;
00408     tens_gamma = flat.con() / psi4 ;
00409     gamma = tens_gamma ;
00410     }
00411 
00412 // Computation of det(gtilde)
00413 
00414     Scalar det_gtilde (gtilde.determinant()) ;
00415 
00416     double* max_det = new double[nz] ;
00417     double* min_det = new double[nz] ;
00418     double* moy_det = new double[nz] ;
00419       
00420     for (int i=0; i<nz; i++){
00421     min_det[i] = 2 ;
00422     moy_det[i] = 0 ;
00423     max_det[i] = 0 ;
00424     }
00425 
00426     for (int l=0; l<nz; l++)
00427     for (int k=0; k<np; k++)
00428         for (int j=0; j<nt; j++)
00429         for (int i=0; i<nr; i++){
00430           
00431             moy_det[l] = moy_det[l] + det_gtilde.val_grid_point(l,k,j,i) ;
00432             if (det_gtilde.val_grid_point(l,k,j,i) > max_det[l]){
00433             max_det[l] = det_gtilde.val_grid_point(l,k,j,i) ;
00434             }
00435             if (det_gtilde.val_grid_point(l,k,j,i) < min_det[l]){
00436             min_det[l] = det_gtilde.val_grid_point(l,k,j,i) ;
00437             }
00438         }
00439      
00440     cout << "average determinant of gtilde in each zone : " << endl ; 
00441     for (int l=0; l<nz; l++){
00442     cout << moy_det[l]/(nr*nt*np) << "  " ;
00443     }
00444     cout << endl ;
00445 
00446       
00447     cout << "maximum of the determinant of gtilde in each zone : " << endl ; 
00448     for (int l=0; l<nz; l++){
00449     cout << max_det[l] << "  " ;
00450     }
00451     cout << endl ;
00452 
00453     cout << "minimum of the determinant of gtilde in each zone : " << endl ; 
00454     for (int l=0; l<nz; l++){
00455     cout << min_det[l] << "  " ;
00456     }
00457     cout << endl ;
00458             
00459 
00460     // ... extrinsic curvature (tkij_auto and kcar_auto)
00461     extrinsic_curvature(om) ;
00462 
00463    
00464 // The derived quantities are obsolete
00465 // -----------------------------------
00466 
00467     del_deriv() ;
00468 
00469     delete max_det ;
00470     delete moy_det ;
00471     delete min_det ;
00472 
00473 }
00474 

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