tslice_conf_init.C

00001 /*
00002  *  Method of class Time_slice_conf to compute valid initial data
00003  *
00004  *    (see file time_slice.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2004  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 version 2
00015  *   as published by the Free Software Foundation.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 char tslice_conf_init_C[] = "$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_conf_init.C,v 1.11 2010/10/20 07:58:09 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: tslice_conf_init.C,v 1.11 2010/10/20 07:58:09 j_novak Exp $
00032  * $Log: tslice_conf_init.C,v $
00033  * Revision 1.11  2010/10/20 07:58:09  j_novak
00034  * Better implementation of the explicit time-integration. Not fully-tested yet.
00035  *
00036  * Revision 1.10  2008/12/04 18:22:49  j_novak
00037  * Enhancement of the dzpuis treatment + various bug fixes.
00038  *
00039  * Revision 1.9  2008/12/02 15:02:22  j_novak
00040  * Implementation of the new constrained formalism, following Cordero et al. 2009
00041  * paper. The evolution eqs. are solved as a first-order system. Not tested yet!
00042  *
00043  * Revision 1.8  2004/05/17 19:53:13  e_gourgoulhon
00044  * Added arguments graph_device and  method_poisson_vect.
00045  *
00046  * Revision 1.7  2004/05/12 15:24:20  e_gourgoulhon
00047  * Reorganized the #include 's, taking into account that
00048  * time_slice.h contains now an #include "metric.h".
00049  *
00050  * Revision 1.6  2004/05/10 09:12:01  e_gourgoulhon
00051  * Added a call to del_deriv() at the end.
00052  *
00053  * Revision 1.5  2004/05/03 14:48:48  e_gourgoulhon
00054  * Treatment of special cases nn_jp1.etat = ETATUN and psi_jp1.etat = ETATUN.
00055  *
00056  * Revision 1.4  2004/04/29 17:10:36  e_gourgoulhon
00057  * Added argument pdt and update of depth slices at the end,
00058  * taking into account the known time derivatives.
00059  *
00060  * Revision 1.3  2004/04/08 16:45:11  e_gourgoulhon
00061  * Use of new methods set_*.
00062  *
00063  * Revision 1.2  2004/04/07 07:58:21  e_gourgoulhon
00064  * Constructor as Minkowski slice: added call to std_spectral_base()
00065  * after setting the lapse to 1.
00066  *
00067  * Revision 1.1  2004/04/05 21:25:37  e_gourgoulhon
00068  * First version.
00069  *
00070  *
00071  * $Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_conf_init.C,v 1.11 2010/10/20 07:58:09 j_novak Exp $
00072  *
00073  */
00074 
00075 // C headers
00076 #include <assert.h>
00077 
00078 // Lorene headers
00079 #include "time_slice.h"
00080 #include "unites.h"
00081 #include "graphique.h"
00082 #include "utilitaires.h"
00083 
00084 void Time_slice_conf::initial_data_cts(const Sym_tensor& uu, 
00085                 const Scalar& trk_in, const Scalar& trk_point, 
00086                 double pdt, double precis, int method_poisson_vect,
00087                 const char* graph_device, const Scalar* p_ener_dens, 
00088                 const Vector* p_mom_dens, const Scalar* p_trace_stress) {
00089 
00090     using namespace Unites ;
00091 
00092     // Verifications
00093     // -------------
00094     double tr_uu = max(maxabs(uu.trace(tgam()), "trace tgam_{ij} u^{ij}")) ; 
00095     if (tr_uu > 1.e-7) {
00096         cerr << 
00097         "Time_slice_conf::initial_data_cts : the trace of u^{ij} with respect\n"
00098         << "  to the conformal metric tgam_{ij} is not zero !\n" 
00099         << "  error = " << tr_uu << endl ; 
00100         abort() ; 
00101     }
00102 
00103     assert(trk_in.check_dzpuis(2)) ; 
00104     assert(trk_point.check_dzpuis(4)) ; 
00105 
00106     // Initialisations
00107     // ---------------
00108     double ttime = the_time[jtime] ; 
00109          
00110     trk_evol.update(trk_in, jtime, ttime) ; 
00111 
00112     // Reset of quantities depending on K:
00113     k_dd_evol.downdate(jtime) ; 
00114     k_uu_evol.downdate(jtime) ; 
00115    
00116     set_hata(psi4()*psi()*psi()* uu / (2.* nn()) ) ; 
00117 
00118     const Map& map = uu.get_mp() ; 
00119     const Base_vect& triad = *(uu.get_triad()) ;
00120     
00121     // For graphical outputs:
00122     int ngraph0 = 10 ;  // index of the first graphic device to be used
00123     int nz = map.get_mg()->get_nzone() ; 
00124     double ray_des = 1.25 * map.val_r(nz-2, 1., 0., 0.) ; // outermost radius
00125                                                           // for plots
00126 
00127     Scalar ener_dens(map) ; 
00128     if (p_ener_dens != 0x0) ener_dens = *(p_ener_dens) ; 
00129     else ener_dens.set_etat_zero() ; 
00130     
00131     Vector mom_dens(map, CON, triad) ; 
00132     if (p_mom_dens != 0x0) mom_dens = *(p_mom_dens) ; 
00133     else mom_dens.set_etat_zero() ; 
00134     
00135     Scalar trace_stress(map) ; 
00136     if (p_trace_stress != 0x0) trace_stress = *(p_trace_stress) ; 
00137     else trace_stress.set_etat_zero() ; 
00138     
00139     Scalar tmp(map) ; 
00140     Scalar source_psi(map) ; 
00141     Scalar source_nn(map) ; 
00142     Vector source_beta(map, CON, triad) ; 
00143     
00144     // Iteration
00145     // ---------
00146     int imax = 100 ; 
00147     for (int i=0; i<imax; i++) {
00148     
00149         //===============================================
00150         //  Computations of sources 
00151         //===============================================
00152     
00153         const Vector& dpsi = psi().derive_cov(ff) ;       // D_i Psi
00154         const Vector& dln_psi = ln_psi().derive_cov(ff) ; // D_i ln(Psi)
00155         const Vector& dnn = nn().derive_cov(ff) ;         // D_i N
00156         
00157         Sym_tensor taa = aa().up_down(tgam()) ;         
00158         Scalar aa_quad = contract(taa, 0, 1, aa(), 0, 1) ; 
00159 
00160         // Source for Psi 
00161         // --------------
00162         tmp = 0.125* psi() * tgam().ricci_scal() 
00163                 - contract(hh(), 0, 1, dpsi.derive_cov(ff), 0, 1 ) ;
00164         tmp.inc_dzpuis() ; // dzpuis : 3 -> 4
00165 
00166         tmp -= contract(hdirac(), 0, dpsi, 0) ;  
00167                 
00168         source_psi = tmp - psi()*psi4()* ( 0.5*qpig* ener_dens 
00169                         + 0.125* aa_quad 
00170                        - 8.33333333333333e-2* trk()*trk() ) ;  
00171                                
00172         // Source for N 
00173         // ------------
00174         
00175         source_nn = psi4()*( nn()*( qpig* (ener_dens + trace_stress) + aa_quad
00176                                     - 0.3333333333333333* trk()*trk() )
00177                              - trk_point ) 
00178                     - 2.* contract(dln_psi, 0, nn().derive_con(tgam()), 0)  
00179                     - contract(hdirac(), 0, dnn, 0) ; 
00180         
00181         tmp = psi4()* contract(beta(), 0, trk().derive_cov(ff), 0)
00182                 - contract( hh(), 0, 1, dnn.derive_cov(ff), 0, 1 ) ;
00183         
00184         tmp.inc_dzpuis() ; // dzpuis: 3 -> 4
00185         
00186         source_nn += tmp ;
00187 
00188 
00189         // Source for beta 
00190         // ---------------
00191 
00192         source_beta = 2.* contract(aa(), 1, 
00193                                    dnn - 6.*nn() * dln_psi, 0) ;
00194                 
00195         source_beta += 2.* nn() * ( 2.*qpig* psi4() * mom_dens 
00196             + 0.66666666666666666* trk().derive_con(tgam()) 
00197             - contract(tgam().connect().get_delta(), 1, 2, 
00198                                   aa(), 0, 1) ) ;
00199             
00200         Vector vtmp = contract(hh(), 0, 1, 
00201                            beta().derive_cov(ff).derive_cov(ff), 1, 2)
00202                 + 0.3333333333333333*
00203                   contract(hh(), 1, beta().divergence(ff).derive_cov(ff), 0) 
00204                 - hdirac().derive_lie(beta()) 
00205                 + uu.divergence(ff) ; 
00206         vtmp.inc_dzpuis() ; // dzpuis: 3 -> 4
00207                     
00208         source_beta -= vtmp ; 
00209         
00210         source_beta += 0.66666666666666666* beta().divergence(ff) * hdirac() ;
00211         
00212 
00213         //=============================================
00214         // Resolution of elliptic equations
00215         //=============================================
00216         
00217         // Resolution of the Poisson equation for Psi
00218         // ------------------------------------------
00219         
00220         Scalar psi_jp1 = source_psi.poisson() + 1. ; 
00221 
00222         if (psi_jp1.get_etat() == ETATUN) psi_jp1.std_spectral_base() ; 
00223 
00224         // Test:
00225         maxabs(psi_jp1.laplacian() - source_psi,
00226                 "Absolute error in the resolution of the equation for Psi") ;  
00227 
00228         des_meridian(psi_jp1, 0., ray_des, "Psi", ngraph0, graph_device) ; 
00229 
00230         // Resolution of the Poisson equation for the lapse
00231         // ------------------------------------------------
00232         
00233         Scalar nn_jp1 = source_nn.poisson() + 1. ; 
00234 
00235         if (nn_jp1.get_etat() == ETATUN) nn_jp1.std_spectral_base() ; 
00236 
00237         // Test:
00238         maxabs(nn_jp1.laplacian() - source_nn,
00239                 "Absolute error in the resolution of the equation for N") ;  
00240 
00241         des_meridian(nn_jp1, 0., ray_des, "N", ngraph0+1, graph_device) ; 
00242         
00243         // Resolution of the vector Poisson equation for the shift
00244         //---------------------------------------------------------
00245         
00246         Vector beta_jp1 = source_beta.poisson(0.3333333333333333, ff, 
00247                                               method_poisson_vect) ; 
00248         
00249         des_meridian(beta_jp1(1), 0., ray_des, "\\gb\\ur\\d", ngraph0+2, 
00250                      graph_device) ; 
00251         des_meridian(beta_jp1(2), 0., ray_des, "\\gb\\u\\gh\\d", ngraph0+3, 
00252                      graph_device) ; 
00253         des_meridian(beta_jp1(3), 0., ray_des, "\\gb\\u\\gf\\d", ngraph0+4, 
00254                      graph_device) ; 
00255         
00256         // Test:
00257         Vector test_beta = (beta_jp1.derive_con(ff)).divergence(ff)
00258             +  0.3333333333333333 * (beta_jp1.divergence(ff)).derive_con(ff) ;
00259         test_beta.inc_dzpuis() ;  
00260         maxabs(test_beta - source_beta,
00261                 "Absolute error in the resolution for beta") ; 
00262 
00263         //===========================================
00264         //      Convergence control
00265         //===========================================
00266     
00267         double diff_psi = max( diffrel(psi(), psi_jp1) ) ; 
00268         double diff_nn = max( diffrel(nn(), nn_jp1) ) ; 
00269         double diff_beta = max( diffrel(beta(), beta_jp1) ) ; 
00270         
00271         cout << "step = " << i << " :  diff_psi = " << diff_psi 
00272              << "  diff_nn = " << diff_nn
00273              << "  diff_beta = " << diff_beta << endl ; 
00274         if ( (diff_psi < precis) && (diff_nn < precis) && (diff_beta < precis) )
00275             break ; 
00276 
00277         //=============================================
00278         //      Updates for next step 
00279         //=============================================
00280 
00281         set_psi_del_npsi(psi_jp1) ; 
00282      
00283         n_evol.update(nn_jp1, jtime, ttime) ; 
00284 
00285         beta_evol.update(beta_jp1, jtime, ttime) ; 
00286 
00287         // New value of A^{ij}:
00288         Sym_tensor aa_jp1 = ( beta().ope_killing_conf(tgam()) + uu ) 
00289                                 / (2.* nn()) ; 
00290         
00291         set_hata( aa_jp1 / (psi4()*psi()*psi()) ) ; 
00292 
00293     }
00294     
00295     //==================================================================
00296     // End of iteration 
00297     //===================================================================
00298 
00299     npsi_evol.update( n_evol[jtime]*psi_evol[jtime], jtime, ttime ) ;
00300     A_hata() ;
00301     B_hata() ;
00302 
00303     // Push forward in time to enable the computation of time derivatives
00304     // ------------------------------------------------------------------
00305     
00306     double ttime1 = ttime ; 
00307     int jtime1 = jtime ; 
00308     for (int j=1; j < depth; j++) {
00309         jtime1++ ; 
00310         ttime1 += pdt ; 
00311         psi_evol.update(psi_evol[jtime], jtime1, ttime1) ;  
00312         npsi_evol.update(npsi_evol[jtime], jtime1, ttime1) ;  
00313         n_evol.update(n_evol[jtime], jtime1, ttime1) ;  
00314         beta_evol.update(beta_evol[jtime], jtime1, ttime1) ;  
00315         hh_evol.update(hh_evol[jtime], jtime1, ttime1) ;
00316         hata_evol.update(hata_evol[jtime], jtime1, ttime1) ;
00317     A_hata_evol.update(A_hata_evol[jtime], jtime1, ttime1) ;
00318     B_hata_evol.update(B_hata_evol[jtime], jtime1, ttime1) ;
00319         trk_evol.update(trk_evol[jtime], jtime1, ttime1) ;
00320         the_time.update(ttime1, jtime1, ttime1) ;         
00321     } 
00322     jtime += depth - 1 ; 
00323     
00324     // Taking into account the time derivative of h^{ij} and K : 
00325     // ---------------------------------------------------------
00326     Sym_tensor uu0 = uu ; 
00327     uu0.dec_dzpuis(2) ; // dzpuis: 2 --> 0
00328     
00329     for (int j=1; j < depth; j++) {
00330         hh_evol.update(hh_evol[jtime] - j*pdt* uu0, 
00331                        jtime-j, the_time[jtime-j]) ;
00332                        
00333         trk_evol.update(trk_evol[jtime] - j*pdt* trk_point, 
00334                        jtime-j, the_time[jtime-j]) ;
00335                        
00336     } 
00337     
00338     // Reset of derived quantities (at the new time step jtime)
00339     // ---------------------------
00340     del_deriv() ; 
00341     
00342 } 

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