tslice_dirac_max_evolve.C

00001 /*
00002  *  Method of class Tslice_dirac_max for time evolution 
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_dirac_max_evolve_C[] = "$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_dirac_max_evolve.C,v 1.19 2012/02/06 12:59:07 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: tslice_dirac_max_evolve.C,v 1.19 2012/02/06 12:59:07 j_novak Exp $
00032  * $Log: tslice_dirac_max_evolve.C,v $
00033  * Revision 1.19  2012/02/06 12:59:07  j_novak
00034  * Correction of some errors.
00035  *
00036  * Revision 1.18  2011/07/22 13:21:02  j_novak
00037  * Corrected an error on BC treatment.
00038  *
00039  * Revision 1.17  2010/10/20 07:58:10  j_novak
00040  * Better implementation of the explicit time-integration. Not fully-tested yet.
00041  *
00042  * Revision 1.16  2008/12/04 18:22:49  j_novak
00043  * Enhancement of the dzpuis treatment + various bug fixes.
00044  *
00045  * Revision 1.15  2008/12/02 15:02:22  j_novak
00046  * Implementation of the new constrained formalism, following Cordero et al. 2009
00047  * paper. The evolution eqs. are solved as a first-order system. Not tested yet!
00048  *
00049  * Revision 1.13  2004/06/14 20:51:37  e_gourgoulhon
00050  * Method solve_hij has now argument method_poisson.
00051  * Its value is set **provisory** to 1 (instead of method_poisson_vect !).
00052  *
00053  * Revision 1.12  2004/05/31 09:09:59  e_gourgoulhon
00054  * Added monitoring of khi and mu.
00055  * Added writing of whole configuration in file (via Time_slice::save).
00056  *
00057  * Revision 1.11  2004/05/24 20:58:05  e_gourgoulhon
00058  * Added graphical output of khi, mu and trh.
00059  *
00060  * Revision 1.10  2004/05/20 20:32:01  e_gourgoulhon
00061  * Added arguments check_mod and save_mod.
00062  * Argument graph_device passed to des_evol.
00063  *
00064  * Revision 1.9  2004/05/17 19:55:10  e_gourgoulhon
00065  * Added arguments method_poisson_vect, nopause and graph_device
00066  *
00067  * Revision 1.8  2004/05/13 21:35:30  e_gourgoulhon
00068  * Added monitoring of various quantities (as Evolution_full<Tbl>).
00069  * Added function monitor_scalar.
00070  *
00071  * Revision 1.7  2004/05/12 15:24:20  e_gourgoulhon
00072  * Reorganized the #include 's, taking into account that
00073  * time_slice.h contains now an #include "metric.h".
00074  *
00075  * Revision 1.6  2004/05/11 20:15:10  e_gourgoulhon
00076  * Added Evolution_full's for ADM mass and checks of the constraint,
00077  * as well as the corresponding plots and write to files.
00078  *
00079  * Revision 1.5  2004/05/10 09:19:27  e_gourgoulhon
00080  * Added a call to del_deriv() after set_khi_mu.
00081  *
00082  * Revision 1.4  2004/05/09 20:59:06  e_gourgoulhon
00083  * Change of the time scheme: first solve d'Alembert equations,
00084  * then psuh forward in time and solve the elliptic equation
00085  * on the new slice.
00086  *
00087  * Revision 1.3  2004/05/06 15:26:29  e_gourgoulhon
00088  * No longer necessary to initialize khi and mu.
00089  *
00090  * Revision 1.2  2004/05/05 14:39:32  e_gourgoulhon
00091  * Added graphical outputs.
00092  *
00093  * Revision 1.1  2004/05/03 14:49:10  e_gourgoulhon
00094  * First version
00095  *
00096  *
00097  * $Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_dirac_max_evolve.C,v 1.19 2012/02/06 12:59:07 j_novak Exp $
00098  *
00099  */
00100 
00101 // Lorene headers
00102 #include "time_slice.h"
00103 #include "param.h"
00104 #include "graphique.h"
00105 #include "utilitaires.h"
00106 #include "proto.h"
00107 
00108 const Tbl& monitor_scalar(const Scalar& uu, Tbl& resu) ;
00109 
00110 void Tslice_dirac_max::evolve(double pdt, int nb_time_steps,
00111                               int niter_elliptic, double relax, 
00112                               int check_mod, int save_mod,
00113                               int method_poisson_vect, int nopause,  
00114                               const char* graph_device, bool verbose,
00115                   const Scalar* ener_euler,
00116                   const Vector* mom_euler, const Scalar* s_euler,
00117                   const Sym_tensor* strain_euler) {
00118 
00119     // Intermediate quantities
00120     // -----------------------
00121     const Map& map = nn().get_mp() ; 
00122     const Base_vect& triad = *(beta().get_triad()) ;
00123     assert( triad == map.get_bvect_spher() ) ;
00124 
00125     // For graphical outputs:
00126     int ngraph0 = 20 ;  // index of the first graphic device to be used
00127     int ngraph0_mon = 70 ;  // for monitoring global quantities
00128     int nz = map.get_mg()->get_nzone() ; 
00129     int nz_bound = nz - 2 ;
00130     int nt = map.get_mg()->get_nt(0) ;
00131     int np = map.get_mg()->get_np(0) ;
00132     int np2 = np+2 ;
00133     Scalar tmp(map) ; tmp.std_spectral_base() ;
00134     Base_val base_ref = tmp.get_spectral_base() ;
00135     Base_val base_pseudo = base_ref ;
00136     base_pseudo.mult_cost() ;
00137     base_pseudo.mult_x() ;
00138 #ifndef NDEBUG
00139     for (int lz=1; lz<nz; lz++) {
00140     assert( map.get_mg()->get_np(lz) == np ) ;
00141     assert( map.get_mg()->get_nt(lz) == nt ) ;
00142     }
00143     assert (depth > 2) ; //## for the moment, a more flexible test should be put
00144     for (int it=0; it<depth; it++) {
00145     assert ( hh_evol.is_known( jtime - it ) ) ;
00146     assert ( hata_evol.is_known( jtime - it ) ) ;
00147     assert ( A_hata_evol.is_known( jtime - it ) ) ;
00148     assert ( B_hata_evol.is_known( jtime - it ) ) ;
00149     assert ( A_hh_evol.is_known( jtime - it ) ) ;
00150     assert ( B_hh_evol.is_known( jtime - it ) ) ;
00151     }   
00152 #endif
00153     
00154     // Initialization of the TT fields
00155     //--------------------------------
00156     Sym_tensor_tt hij_tt( map, triad, ff ) ;
00157     hij_tt.set_A_tildeB( A_hh_evol[jtime], B_hh_evol[jtime] ) ;
00158     Sym_tensor_tt hijtt_old = hij_tt ;
00159     for (int i=1; i<=3; i++)
00160     for (int j=i; j<=3; j++)
00161         if ( hijtt_old(i,j).get_etat() == ETATZERO )
00162         hijtt_old.set( i, j ).annule_hard() ;
00163     hijtt_old.annule(0, nz_bound) ;
00164 
00165     Sym_tensor_tt hata_tt( map, triad, ff ) ;
00166     hata_tt.set_A_tildeB( A_hata_evol[jtime], B_hata_evol[jtime] ) ;
00167     hata_tt.inc_dzpuis(2) ;
00168     Sym_tensor_tt hatatt_old = hata_tt ;
00169     for (int i=1; i<=3; i++)
00170     for (int j=i; j<=3; j++)
00171         if ( hatatt_old(i,j).get_etat() == ETATZERO )
00172         hatatt_old.set( i, j ).annule_hard() ;
00173     hatatt_old.annule(0, nz_bound) ;
00174 
00175     // Declaration / initialization of mu and khi for hh and hata
00176     //-----------------------------------------------------------
00177     Evolution_std<Scalar> khi_hh_evol(depth) ;
00178     Evolution_std<Scalar> mu_hh_evol(depth) ;
00179     Evolution_std<Scalar> khi_a_evol(depth) ;
00180     Evolution_std<Scalar> mu_a_evol(depth) ;
00181     Sym_tensor_trans Tij(map, map.get_bvect_spher(), ff) ;
00182     for (int j=jtime-depth+1; j<=jtime; j++) {
00183     tmp = hij_tt(1,1) ;
00184     tmp.mult_r() ; tmp.mult_r() ;
00185     khi_hh_evol.update( tmp, j, the_time[j] ) ;
00186     mu_hh_evol.update( hij_tt.mu(), j, the_time[j] ) ;
00187     tmp = hata_tt(1,1) ;
00188     tmp.mult_r() ; tmp.mult_r() ;
00189     khi_a_evol.update( tmp, j, the_time[j] ) ;
00190     mu_a_evol.update( hata_tt.mu(), j, the_time[j] ) ;
00191     }
00192 
00193     double Rmax = map.val_r(nz-2, 1., 0., 0.) ; // outermost radius
00194     double ray_des = 1.25 * Rmax ; // for plots
00195 
00196     // Parameters for the evolution equations
00197     //---------------------------------------
00198     double an = 23./12. ; 
00199     double anm1 = -4./3. ; 
00200     double anm2 = 5./12. ; 
00201 
00202     Param par_A ;
00203     double l_val_A = 1./Rmax ;
00204     double l_der_A = 1. ;
00205     par_A.add_int(nz_bound, 0) ;
00206     par_A.add_int(2, 1) ; //matching of function and derivative
00207     par_A.add_int(0, 2) ;// no shift in l 
00208     par_A.add_int(2, 3) ; // only for l>=2
00209     par_A.add_double_mod(l_val_A, 0) ;
00210     par_A.add_double_mod(l_der_A, 1) ;
00211     Tbl* tmp_Acc = new Tbl(np2, nt) ;
00212     Tbl& Acc = *tmp_Acc ;
00213     Acc.annule_hard() ;
00214     par_A.add_tbl_mod(Acc) ;
00215     Param par_mat_A_hh ;
00216 
00217     Param par_B ;
00218     double l_val_B = 1./Rmax ;
00219     double l_der_B = 1. ; 
00220     par_B.add_int(nz_bound, 0) ;
00221     par_B.add_int(2, 1) ; //matching of function and derivative
00222     par_B.add_int(-1, 2) ;// shift in l for tilde{B}
00223     par_B.add_int(2, 3) ; // only for l>=2
00224     par_B.add_double_mod(l_val_B, 0) ;
00225     par_B.add_double_mod(l_der_B, 1) ;
00226     Tbl* tmp_Bcc = new Tbl(np2, nt) ;
00227     Tbl& Bcc = *tmp_Bcc ;
00228     Bcc.annule_hard() ;
00229     par_B.add_tbl_mod(Bcc) ;
00230     Param par_mat_B_hh ;
00231 
00232     Tbl xij_b(np2, nt) ;
00233     xij_b.set_etat_qcq() ;
00234     initialize_outgoing_BC(nz_bound, B_hh_evol[jtime] , B_hata_evol[jtime], xij_b) ;
00235     Tbl xijm1_b(np2, nt) ;
00236     xijm1_b.set_etat_qcq() ;
00237     initialize_outgoing_BC(nz_bound, B_hh_evol[jtime-1] , 
00238                B_hata_evol[jtime-1], xijm1_b) ;
00239     Tbl xij_a(np2, nt) ;
00240     xij_a.set_etat_qcq() ;
00241     initialize_outgoing_BC(nz_bound, A_hh_evol[jtime] , A_hata_evol[jtime], xij_a) ;
00242     Tbl xijm1_a(np2, nt) ;
00243     xijm1_a.set_etat_qcq() ;
00244     initialize_outgoing_BC(nz_bound, A_hh_evol[jtime-1] , 
00245                A_hata_evol[jtime-1], xijm1_a) ;
00246 
00247     // Parameters for the Dirac systems
00248     //---------------------------------
00249 
00250     Param par_bc_hh ;
00251     par_bc_hh.add_int(nz_bound) ;
00252     Tbl* cf_b_hh = new Tbl(10) ;
00253     cf_b_hh->annule_hard() ;
00254     cf_b_hh->set(0) = 11*Rmax + 12*pdt ; // mu
00255     cf_b_hh->set(1) = 6*Rmax*pdt ; // d mu / dr
00256     cf_b_hh->set(2) = 0 ; // X
00257     cf_b_hh->set(3) = 0 ; // d X / dr
00258     cf_b_hh->set(4) = 11*Rmax*Rmax + 18*Rmax*pdt ; // h^rr
00259     cf_b_hh->set(5) = 6*Rmax*Rmax*pdt ;  // d h^rr / dr
00260     cf_b_hh->set(6) = 0 ; //eta
00261     cf_b_hh->set(7) = 0 ; //d eta / dr
00262     cf_b_hh->set(8) = 0 ; //W
00263     cf_b_hh->set(9) = 0 ; //d W / dr
00264     par_bc_hh.add_tbl_mod(*cf_b_hh, 0) ;
00265     Tbl* kib_hh = new Tbl(np2, nt) ;
00266     Tbl& khib_hh = *kib_hh ;
00267     khib_hh.annule_hard() ;
00268     par_bc_hh.add_tbl_mod(khib_hh,1) ;
00269     Tbl* mb_hh = new Tbl(np2, nt) ;
00270     Tbl& mub_hh = *mb_hh ;
00271     mub_hh.annule_hard() ;
00272     par_bc_hh.add_tbl_mod(mub_hh, 2) ;
00273 
00274     Param par_mat_hh ;
00275 
00276     Tbl xij_mu_hh(np2, nt) ;
00277     xij_mu_hh.set_etat_qcq() ;
00278     initialize_outgoing_BC(nz_bound, mu_hh_evol[jtime] , mu_a_evol[jtime], xij_mu_hh) ;
00279     Tbl xijm1_mu_hh(np2, nt) ;
00280     xijm1_mu_hh.set_etat_qcq() ;
00281     initialize_outgoing_BC(nz_bound, mu_hh_evol[jtime-1] , mu_a_evol[jtime-1], 
00282                xijm1_mu_hh) ;
00283 
00284     Tbl xij_ki_hh(np2, nt) ;
00285     xij_ki_hh.set_etat_qcq() ;
00286     initialize_outgoing_BC(nz_bound, khi_hh_evol[jtime] , khi_a_evol[jtime], xij_ki_hh) ;
00287     Tbl xijm1_ki_hh(np2, nt) ;
00288     xijm1_ki_hh.set_etat_qcq() ;
00289     initialize_outgoing_BC(nz_bound, khi_hh_evol[jtime-1] , khi_a_evol[jtime-1], 
00290                xijm1_ki_hh) ;
00291 
00292     Param par_bc_hata ;
00293     par_bc_hata.add_int(nz_bound) ;
00294     Tbl* cf_b_hata = new Tbl(10) ;
00295     cf_b_hata->annule_hard() ;
00296     cf_b_hata->set(0) = 11*Rmax + 12*pdt ; // mu
00297     cf_b_hata->set(1) = 6*Rmax*pdt ; // d mu / dr
00298     cf_b_hata->set(2) = 0 ; // X
00299     cf_b_hata->set(3) = 0 ; // d X / dr
00300     cf_b_hata->set(4) = 11*Rmax*Rmax + 18*Rmax*pdt ; // h^rr
00301     cf_b_hata->set(5) =  6*Rmax*Rmax*pdt ;  // d h^rr / dr
00302     cf_b_hata->set(6) = 0 ; //eta
00303     cf_b_hata->set(7) = 0 ; //d eta / dr
00304     cf_b_hata->set(8) = 0 ; //W
00305     cf_b_hata->set(9) = 0 ; //d W / dr
00306     par_bc_hata.add_tbl_mod(*cf_b_hata, 0) ;
00307     Tbl* kib_hata = new Tbl(np2, nt) ;
00308     Tbl& khib_hata = *kib_hata ;
00309     khib_hata.annule_hard() ;
00310     par_bc_hata.add_tbl_mod(khib_hata,1) ;
00311     Tbl* mb_hata = new Tbl(np2, nt) ;
00312     Tbl& mub_hata = *mb_hata ;
00313     mub_hata.annule_hard() ;
00314     par_bc_hata.add_tbl_mod(mub_hata, 2) ;
00315 
00316     Param par_mat_hata ;
00317 
00318     Tbl xij_mu_a(np2, nt) ;
00319     xij_mu_a.set_etat_qcq() ;
00320     initialize_outgoing_BC(nz_bound, mu_a_evol[jtime] , 
00321                mu_a_evol.time_derive(jtime, 2), xij_mu_a) ;
00322     Tbl xijm1_mu_a(np2, nt) ;
00323     xijm1_mu_a.set_etat_qcq() ;
00324     tmp = ( mu_a_evol[jtime] - mu_a_evol[jtime-2] ) / (2.*pdt) ;
00325     initialize_outgoing_BC(nz_bound, mu_a_evol[jtime-1] , tmp, xijm1_mu_a) ;
00326 
00327     Tbl xij_ki_a(np2, nt) ;
00328     xij_ki_a.set_etat_qcq() ;
00329     initialize_outgoing_BC(nz_bound, khi_a_evol[jtime] , 
00330                khi_a_evol.time_derive(jtime, 2), xij_ki_a) ;
00331     Tbl xijm1_ki_a(np2, nt) ;
00332     xijm1_ki_a.set_etat_qcq() ;
00333     tmp = ( khi_a_evol[jtime] - khi_a_evol[jtime-2] ) / (2.*pdt) ;
00334     initialize_outgoing_BC(nz_bound, khi_a_evol[jtime-1] , tmp, xijm1_ki_a) ;
00335 
00336     // Quantities at new time-step
00337     //----------------------------
00338     Scalar n_new(map) ; 
00339     Scalar psi_new(map) ; 
00340     Scalar npsi_new(map) ; 
00341     Vector beta_new(map, CON, triad) ; 
00342     Scalar A_hh_new(map) ; 
00343     Scalar B_hh_new(map) ; 
00344     Scalar A_hata_new(map) ; 
00345     Scalar B_hata_new(map) ; 
00346     
00347     // Successive values of various quantities:
00348     // ---------------------------------------
00349     Evolution_full<double> m_adm(adm_mass(), jtime, the_time[jtime]) ; 
00350     Evolution_full<double> test_ham_constr ; 
00351     Evolution_full<double> test_mom_constr_r ; 
00352     Evolution_full<double> test_mom_constr_t ; 
00353     Evolution_full<double> test_mom_constr_p ; 
00354     Evolution_full<Tbl> nn_monitor ;
00355     Evolution_full<Tbl> psi_monitor ;
00356     Evolution_full<Tbl> A_h_monitor ;
00357     Evolution_full<Tbl> B_h_monitor ;
00358     Evolution_full<Tbl> trh_monitor ;
00359     Evolution_full<Tbl> beta_monitor_maxabs ;
00360     Evolution_full<Tbl> hh_monitor_central ;
00361     Evolution_full<Tbl> hh_monitor_maxabs ;
00362     Evolution_full<Tbl> hata_monitor_central ;
00363     Evolution_full<Tbl> hata_monitor_maxabs ;
00364     Evolution_full<Tbl> check_evol ;
00365     Tbl select_scalar(6) ; 
00366     Tbl select_tens(6) ;
00367 
00368     Vector zero_vec( map, CON, map.get_bvect_spher() ) ;
00369     zero_vec.set_etat_zero() ;
00370     const Vector& hat_S = ( mom_euler == 0x0 ? zero_vec : *mom_euler ) ;
00371     Scalar lapB(map) ;
00372     Scalar lapBm1 = source_B_hata_evol[jtime-1] ;
00373     Scalar lapBm2 = source_B_hata_evol[jtime-2] ;
00374 
00375     // Evolution loop
00376     // --------------
00377 
00378     for (int jt = 0; jt < nb_time_steps; jt++) {
00379     
00380         double ttime = the_time[jtime] ; 
00381     k_dd() ;
00382             
00383         if (jt%check_mod == 0) {
00384       cout << 
00385         "==============================================================\n"
00386            << "  step: " << jtime << "   time = " << the_time[jtime] << endl  
00387            << " ADM mass : " << adm_mass() 
00388            << ", Log of central lapse: " << log(nn().val_grid_point(0,0,0,0)) << endl 
00389            << "==============================================================\n" ;
00390       
00391       // Monitoring
00392       // ---------- 
00393       m_adm.update(adm_mass(), jtime, the_time[jtime]) ;
00394       if (jt > 0) des_evol(m_adm, "ADM mass", "Variation of ADM mass", 
00395                    ngraph0_mon, graph_device) ;          
00396       
00397       
00398       nn_monitor.update(monitor_scalar(nn(), select_scalar), 
00399                             jtime, the_time[jtime]) ; 
00400       
00401       psi_monitor.update(monitor_scalar(psi(), select_scalar), 
00402                  jtime, the_time[jtime]) ; 
00403       
00404       A_h_monitor.update(monitor_scalar(A_hh(), select_scalar), 
00405                  jtime, the_time[jtime]) ; 
00406       
00407       B_h_monitor.update(monitor_scalar(B_hh(), select_scalar), 
00408                  jtime, the_time[jtime]) ; 
00409         
00410       trh_monitor.update(monitor_scalar(trh(), select_scalar), 
00411                  jtime, the_time[jtime]) ; 
00412       
00413       beta_monitor_maxabs.update(maxabs_all_domains(beta(), -1, 0x0, cout, verbose), 
00414                      jtime, the_time[jtime]) ; 
00415         
00416       hh_monitor_central.update(central_value(hh()), 
00417                                     jtime, the_time[jtime]) ; 
00418         
00419       hh_monitor_maxabs.update(maxabs_all_domains(hh(), -1, 0x0, cout, verbose), 
00420                    jtime, the_time[jtime]) ; 
00421         
00422       hata_monitor_central.update(central_value(hata()), 
00423                       jtime, the_time[jtime]) ; 
00424         
00425       hata_monitor_maxabs.update(maxabs_all_domains(hata(), -1, 0x0, cout, verbose), 
00426                      jtime, the_time[jtime]) ; 
00427         
00428 
00429       int jt_graph = jt / check_mod ; 
00430             
00431       Tbl tham = check_hamiltonian_constraint(0x0, cout, verbose) ; 
00432       double max_error = tham(0,0) ; 
00433       for (int l=1; l<nz-1; l++) {    // all domains but the last one
00434         double xx = fabs(tham(0,l)) ;  
00435         if (xx > max_error) max_error = xx ; 
00436       }
00437       test_ham_constr.update(max_error, jt_graph, the_time[jtime]) ; 
00438       if (jt > 0) des_evol(test_ham_constr, "Absolute error", 
00439                    "Check of Hamiltonian constraint", 
00440                    ngraph0_mon+1, graph_device) ; 
00441       
00442       Tbl tmom = check_momentum_constraint(0x0, cout, verbose) ; 
00443             max_error = tmom(0,0) ;
00444             for (int l=1; l<nz-1; l++) {    // all domains but the last one
00445                 double xx = fabs(tmom(0,l)) ;  
00446                 if (xx > max_error) max_error = xx ; 
00447             }
00448             test_mom_constr_r.update(max_error, jt_graph, the_time[jtime]) ; 
00449             if (jt > 0) des_evol(test_mom_constr_r, "Absolute error", 
00450                 "Check of momentum constraint (r comp.)", ngraph0_mon+2, 
00451                 graph_device) ; 
00452 
00453             max_error = tmom(1,0) ;
00454             for (int l=1; l<nz-1; l++) {    // all domains but the last one
00455                 double xx = fabs(tmom(1,l)) ;  
00456                 if (xx > max_error) max_error = xx ; 
00457             }
00458             test_mom_constr_t.update(max_error, jt_graph, the_time[jtime]) ; 
00459             if (jt > 0) des_evol(test_mom_constr_t, "Absolute error", 
00460                 "Check of momentum constraint (\\gh comp.)", ngraph0_mon+3,
00461                  graph_device) ; 
00462 
00463             max_error = tmom(2,0) ;
00464             for (int l=1; l<nz-1; l++) {    // all domains but the last one
00465                 double xx = fabs(tmom(2,l)) ;  
00466                 if (xx > max_error) max_error = xx ; 
00467             }
00468             test_mom_constr_p.update(max_error, jt_graph, the_time[jtime]) ; 
00469             if (jt > 0) des_evol(test_mom_constr_p, "Absolute error", 
00470                 "Check of momentum constraint (\\gf comp.)", ngraph0_mon+4, 
00471                 graph_device) ; 
00472                
00473         if (jt>2) {
00474           Tbl tevol = check_dynamical_equations(0x0, 0x0, cout, verbose) ;
00475         Tbl evol_check(6) ; evol_check.set_etat_qcq() ;
00476         for (int i=1; i<=3; i++) 
00477         for(int j=1; j<=i; j++) {
00478             max_error = tevol(i, j, 0) ;
00479             for (int l=1; l<nz-1; l++) {
00480             double xx = fabs(tevol(i,j,l)) ;
00481             if (xx > max_error) max_error = xx ;
00482             }
00483             evol_check.set(i) = max_error ;
00484         }
00485         check_evol.update(evol_check,  jtime, the_time[jtime]) ;
00486         }
00487         }
00488 
00489         if (jt%save_mod == 0) { 
00490             m_adm.save("adm_mass.d") ; 
00491             nn_monitor.save("nn_monitor.d") ;
00492             psi_monitor.save("psi_monitor.d") ;
00493             A_h_monitor.save("potA_monitor.d") ;
00494             B_h_monitor.save("potB_monitor.d") ;
00495             trh_monitor.save("trh_monitor.d") ;
00496             beta_monitor_maxabs.save("beta_monitor_maxabs.d") ; 
00497             hh_monitor_central.save("hh_monitor_central.d") ; 
00498             hh_monitor_maxabs.save("hh_monitor_maxabs.d") ; 
00499             hata_monitor_central.save("hata_monitor_central.d") ; 
00500             hata_monitor_maxabs.save("hata_monitor_maxabs.d") ; 
00501             test_ham_constr.save("test_ham_constr.d") ; 
00502             test_mom_constr_r.save("test_mom_constr_r.d") ; 
00503             test_mom_constr_t.save("test_mom_constr_t.d") ; 
00504             test_mom_constr_p.save("test_mom_constr_p.d") ; 
00505         check_evol.save("evol_equations.d") ;
00506             
00507             save("sigma") ;
00508             
00509         }
00510 
00511 
00512         // Resolution of hyperbolic equations
00513         // ----------------------------------
00514     compute_sources(strain_euler) ;
00515 
00516     A_hata_new = A_hata_evol[jtime] 
00517       + pdt*( an*source_A_hata_evol[jtime] + anm1*source_A_hata_evol[jtime-1]
00518           + anm2*source_A_hata_evol[jtime-2] ) ;
00519     B_hata_new = B_hata_evol[jtime] 
00520       + pdt*( an*source_B_hata_evol[jtime] + anm1*source_B_hata_evol[jtime-1]
00521           + anm2*source_B_hata_evol[jtime-2] ) ;
00522 
00523     A_hh_new = A_hh_evol[jtime] 
00524       + pdt*( an*source_A_hh_evol[jtime] + anm1*source_A_hh_evol[jtime-1]
00525           + anm2*source_A_hh_evol[jtime-2] ) ;
00526 
00527     B_hh_new = B_hh_evol[jtime] 
00528       + pdt*( an*source_B_hh_evol[jtime] + anm1*source_B_hh_evol[jtime-1]
00529           + anm2*source_B_hh_evol[jtime-2] ) ;
00530     
00531     Scalar bc_A = -2.*A_hata_new ;
00532     bc_A.set_spectral_va().ylm() ;
00533     evolve_outgoing_BC(pdt, nz_bound, A_hh_evol[jtime], bc_A, xij_a, xijm1_a, 
00534                Acc, 0) ;
00535     A_hh_new.match_tau(par_A, &par_mat_A_hh) ;
00536         
00537     Scalar bc_B = -2.*B_hata_new ;
00538     bc_B.set_spectral_va().ylm() ;
00539     evolve_outgoing_BC(pdt, nz_bound, B_hh_evol[jtime], bc_B, xij_b, xijm1_b, 
00540                Bcc, -1) ;
00541     B_hh_new.match_tau(par_B, &par_mat_B_hh) ;
00542     
00543         // Boundary conditions for hh and hata
00544     //------------------------------------
00545     Scalar sbcmu = (18*mu_hh_evol[jtime] - 9*mu_hh_evol[jtime-1] 
00546             + 2*mu_hh_evol[jtime-2]) / (6*pdt) ;
00547     if (sbcmu.get_etat() == ETATZERO) {
00548         sbcmu.annule_hard() ;
00549         sbcmu.set_spectral_base(base_pseudo) ;
00550     }
00551     sbcmu.set_spectral_va().ylm() ;
00552     tmp = mu_hh_evol[jtime] ;
00553     if (tmp.get_etat() == ETATZERO) {
00554         tmp.annule_hard() ;
00555         tmp.set_spectral_base(base_pseudo) ;
00556     }
00557     tmp.set_spectral_va().ylm() ;
00558     evolve_outgoing_BC(pdt, nz_bound, tmp, sbcmu, xij_mu_hh, xijm1_mu_hh, 
00559                mub_hh, 0) ;
00560     mub_hh *= 6*pdt ;
00561 
00562     Scalar sbckhi = (18*khi_hh_evol[jtime] - 9*khi_hh_evol[jtime-1] 
00563              + 2*khi_hh_evol[jtime-2]) / (6*pdt) ;
00564     if (sbckhi.get_etat() == ETATZERO) {
00565         sbckhi.annule_hard() ;
00566         sbckhi.set_spectral_base(base_ref) ;
00567     }
00568     sbckhi.set_spectral_va().ylm() ;
00569     tmp = khi_hh_evol[jtime] ;
00570     if (tmp.get_etat() == ETATZERO) {
00571         tmp.annule_hard() ;
00572         tmp.set_spectral_base(base_ref) ;
00573     }
00574     tmp.set_spectral_va().ylm() ;
00575     evolve_outgoing_BC(pdt, nz_bound, tmp, sbckhi, xij_ki_hh, xijm1_ki_hh, 
00576                khib_hh, 0) ;
00577     khib_hh *= 6*pdt ;
00578 
00579     sbcmu = (18*mu_a_evol[jtime] - 9*mu_a_evol[jtime-1] 
00580             + 2*mu_a_evol[jtime-2]) / (6*pdt) ;
00581     if (sbcmu.get_etat() == ETATZERO) {
00582         sbcmu.annule_hard() ;
00583         sbcmu.set_spectral_base(base_pseudo) ;
00584     }
00585         sbcmu.set_spectral_va().ylm() ;
00586     tmp = mu_a_evol[jtime] ;
00587     if (tmp.get_etat() == ETATZERO) {
00588         tmp.annule_hard() ;
00589         tmp.set_spectral_base(base_pseudo) ;
00590     }
00591     tmp.set_spectral_va().ylm() ;
00592     evolve_outgoing_BC(pdt, nz_bound, tmp, sbcmu, xij_mu_a, xijm1_mu_a, 
00593                mub_hata, 0) ;
00594     mub_hata *= 6*pdt ;
00595 
00596     sbckhi = (18*khi_a_evol[jtime] - 9*khi_a_evol[jtime-1] 
00597              + 2*khi_a_evol[jtime-2]) / (6*pdt) ;
00598     if (sbckhi.get_etat() == ETATZERO) {
00599         sbckhi.annule_hard() ;
00600         sbckhi.set_spectral_base(base_ref) ;
00601     }
00602     sbckhi.set_spectral_va().ylm() ;
00603     tmp = khi_a_evol[jtime] ;
00604     if (tmp.get_etat() == ETATZERO) {
00605         tmp.annule_hard() ;
00606         tmp.set_spectral_base(base_ref) ;
00607     }
00608     tmp.set_spectral_va().ylm() ;
00609     evolve_outgoing_BC(pdt, nz_bound, tmp, sbckhi, xij_ki_a, xijm1_ki_a, 
00610                khib_hata, 0) ;
00611     khib_hata *= 6*pdt ;
00612 
00613         // Advance in time
00614         // ---------------
00615         
00616         jtime++ ; 
00617         ttime += pdt ; 
00618         the_time.update(ttime, jtime, ttime) ; 
00619 
00620     // Setting As and Bs for h^{ij} and \hat{A}^{ij}
00621         set_AB_hata(A_hata_new, B_hata_new) ;
00622         set_AB_hh(A_hh_new, B_hh_new) ;
00623 
00624     hij_tt.set_A_tildeB( A_hh_new, B_hh_new, &par_bc_hh, &par_mat_hh ) ;
00625     for (int i=1; i<=3; i++)
00626         for (int j=i; j<=3; j++) 
00627         for (int l=nz_bound+1; l<nz; l++)
00628             hij_tt.set(i,j).set_domain(l) = hijtt_old(i,j).domain(l) ;
00629     hata_tt.set_A_tildeB( A_hata_new, B_hata_new, &par_bc_hata, &par_mat_hata ) ;
00630     for (int i=1; i<=3; i++)
00631         for (int j=i; j<=3; j++) {
00632         for (int l=nz_bound+1; l<nz; l++)
00633             hata_tt.set(i,j).set_domain(l) = hatatt_old(i,j).domain(l) ;
00634         hata_tt.set(i,j).set_dzpuis(2) ;
00635         }
00636 
00637     // Computation of h^{ij} at new time-step
00638     hh_det_one(hij_tt, &par_mat_hh) ;
00639 
00640         // Reset of derived quantities
00641         del_deriv() ;        
00642 
00643     // Update of khi's and mu's
00644     //-------------------------
00645     tmp = hij_tt( 1, 1 ) ;
00646     tmp.mult_r() ; tmp.mult_r() ;
00647     khi_hh_evol.update( tmp, jtime, the_time[jtime] ) ;
00648     mu_hh_evol.update( hij_tt.mu(), jtime, the_time[jtime] ) ;
00649     tmp = hata_tt( 1, 1 ) ;
00650     tmp.mult_r() ; tmp.mult_r() ;
00651     khi_a_evol.update( tmp, jtime, the_time[jtime] ) ;
00652     mu_a_evol.update( hata_tt.mu(), jtime, the_time[jtime] ) ;
00653     
00654         // Resolution of elliptic equations
00655         // --------------------------------
00656         psi_evol.update(psi_evol[jtime-1], jtime, ttime) ; 
00657         
00658     // \hat{A}^{ij} is computed at the new time-step
00659     compute_X_from_momentum_constraint(hat_S, hata_tt, niter_elliptic) ;
00660     
00661     // Iteration on the conformal factor
00662         for (int k = 0; k < niter_elliptic; k++) {
00663     
00664             psi_new = solve_psi(ener_euler) ; 
00665             psi_new = relax * psi_new + (1.-relax) * psi() ; 
00666         set_psi_del_npsi(psi_new) ;   
00667         }
00668 
00669         set_npsi_del_n(npsi_evol[jtime-1]) ; 
00670 
00671     // Iteration on N*Psi  ## play with the number of iterations...
00672         npsi_evol.update(psi_evol[jtime-1], jtime, ttime) ; 
00673     for (int k = 0; k < niter_elliptic; k++) {
00674 
00675             npsi_new = solve_npsi( ener_euler, s_euler ) ; 
00676             npsi_new = relax * npsi_new + (1.-relax) * npsi() ; 
00677         set_npsi_del_n(npsi_new) ; 
00678     }
00679 
00680     // Iteration on beta ## play with the number of iterations...
00681         beta_evol.update(beta_evol[jtime-1], jtime, ttime) ;             
00682     for (int k = 0; k < niter_elliptic; k++) {
00683 
00684             beta_new = solve_beta(method_poisson_vect) ; 
00685             beta_new = relax * beta_new + (1.-relax) * beta() ;
00686         beta_evol.update(beta_new, jtime, ttime) ;             
00687     }    
00688                 
00689         des_meridian(vec_X()(1), 0., ray_des, "\\gb\\ur\\d", ngraph0+6,
00690                      graph_device) ; 
00691         des_meridian(vec_X()(2), 0., ray_des, "\\gb\\u\\gh\\d", ngraph0+7,
00692                      graph_device) ; 
00693         des_meridian(vec_X()(3), 0., ray_des, "\\gb\\u\\gf\\d", ngraph0+8,
00694                      graph_device) ; 
00695     tmp = A_hh() ;
00696     tmp.set_spectral_va().ylm_i() ;
00697         des_meridian(tmp, 0., ray_des, "A\\dh", ngraph0+9,
00698                      graph_device) ; 
00699     tmp = B_hh_new;
00700     tmp.set_spectral_va().ylm_i() ;
00701         des_meridian(tmp, 0., ray_des, "B\\dh", ngraph0+10,
00702                      graph_device) ;
00703         des_meridian(trh(), 0., ray_des, "tr h", ngraph0+11,
00704                      graph_device) ; 
00705         des_meridian(hh()(1,1), 0., ray_des, "h\\urr\\d", ngraph0+12,
00706                      graph_device) ; 
00707         des_meridian(hh()(2,3), 0., ray_des, "h\\u\\gh\\gf\\d", ngraph0+13,
00708                      graph_device) ; 
00709         des_meridian(hh()(3,3), 0., ray_des, "h\\u\\gf\\gf\\d", ngraph0+14,
00710                      graph_device) ; 
00711                 
00712         arrete(nopause) ; 
00713     }
00714 
00715     par_A.clean_all() ;
00716     par_B.clean_all() ;
00717     par_mat_A_hh.clean_all() ;
00718     par_mat_B_hh.clean_all() ;
00719 
00720     par_bc_hh.clean_all() ;
00721     par_mat_hh.clean_all() ;
00722 
00723     par_bc_hata.clean_all() ;
00724     par_mat_hata.clean_all() ;
00725 } 
00726 
00727 
00728 //***************************************************************************
00729 
00730 const Tbl& monitor_scalar(const Scalar& uu, Tbl& resu) {
00731 
00732     assert( resu.get_ndim() == 1) ; 
00733     assert( resu.get_taille() >= 6) ;
00734     
00735     resu.set_etat_qcq() ; 
00736     
00737     resu.set(0) = uu.val_grid_point(0,0,0,0) ; 
00738     resu.set(1) = max(max(uu)) ; 
00739     resu.set(2) = min(min(uu)) ; 
00740     
00741     const Mg3d& mg = *(uu.get_mp().get_mg()) ; 
00742     
00743     int nz = mg.get_nzone() ;
00744     int nzm1 = nz - 1 ;  
00745     int nr = mg.get_nr(nzm1) ; 
00746     int nt = mg.get_nt(nzm1) ; 
00747     int np = mg.get_np(nzm1) ; 
00748     
00749     resu.set(3) = uu.val_grid_point(nzm1, 0, 0, nr-1) ; 
00750     resu.set(4) = uu.val_grid_point(nzm1, 0, nt-1, nr-1) ; 
00751     resu.set(5) = uu.val_grid_point(nzm1, np/2, nt-1, nr-1) ; 
00752     
00753     return resu ;      
00754 }

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