regularisation.C

00001 /*
00002  *   Copyright (c) 2005 Francois Limousin
00003  *                      Jose Luis Jaramillo
00004  *
00005  *   This file is part of LORENE.
00006  *
00007  *   LORENE is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation; either version 2 of the License, or
00010  *   (at your option) any later version.
00011  *
00012  *   LORENE is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with LORENE; if not, write to the Free Software
00019  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 
00024 char regularisation_C[] = "$Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.10 2008/08/19 06:42:00 j_novak Exp $" ;
00025 
00026 /*
00027  * $Id: regularisation.C,v 1.10 2008/08/19 06:42:00 j_novak Exp $
00028  * $Log: regularisation.C,v $
00029  * Revision 1.10  2008/08/19 06:42:00  j_novak
00030  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00031  * cast-type operations, and constant strings that must be defined as const char*
00032  *
00033  * Revision 1.9  2005/09/13 18:33:17  f_limousin
00034  * New function vv_bound_cart_bin(double) for computing binaries with
00035  * berlin condition for the shift vector.
00036  * Suppress all the symy and asymy in the importations.
00037  *
00038  * Revision 1.8  2005/09/12 12:33:54  f_limousin
00039  * Compilation Warning - Change of convention for the angular velocity
00040  * Add Berlin boundary condition in the case of binary horizons.
00041  *
00042  * Revision 1.7  2005/05/12 14:48:07  f_limousin
00043  * New boundary condition for the lapse : boundary_nn_lapl().
00044  *
00045  * Revision 1.6  2005/04/03 19:48:22  f_limousin
00046  * Implementation of set_psi(psi_in). And minor changes to avoid warnings.
00047  *
00048  * Revision 1.5  2005/03/24 16:50:28  f_limousin
00049  * Add parameters solve_shift and solve_psi in par_isol.d and in function
00050  * init_dat(...). Implement Isolhor::kerr_perturb().
00051  *
00052  * Revision 1.4  2005/03/22 13:25:36  f_limousin
00053  * Small changes. The angular velocity and A^{ij} are computed
00054  * with a differnet sign.
00055  *
00056  * Revision 1.3  2005/03/10 10:19:42  f_limousin
00057  * Add the regularisation of the shift in the case of a single black hole
00058  * and lapse zero on the horizon.
00059  *
00060  * Revision 1.2  2005/03/06 17:05:33  f_limousin
00061  * Change parameter omega to om, in order not to have warnings.
00062  *
00063  * Revision 1.1  2005/02/22 14:51:53  f_limousin
00064  * First version
00065  *
00066  *
00067  * $Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.10 2008/08/19 06:42:00 j_novak Exp $
00068  *
00069  */
00070 
00071 
00072 //Standard
00073 #include <stdlib.h>
00074 #include <math.h>
00075 
00076 //Lorene
00077 #include "isol_hor.h"
00078 #include "nbr_spx.h"
00079 #include "tensor.h"
00080 
00081 double Isol_hor::regularisation (const Vector& shift_auto_temp, 
00082                  const Vector& shift_comp_temp, double om) {
00083     
00084     Vector shift_auto(shift_auto_temp) ;
00085     shift_auto.change_triad(shift_auto.get_mp().get_bvect_cart()) ;
00086     Vector shift_comp(shift_comp_temp) ;
00087     shift_comp.change_triad(shift_comp.get_mp().get_bvect_cart()) ;
00088     Vector shift_old (shift_auto) ;
00089     
00090     double orientation = shift_auto.get_mp().get_rot_phi() ;
00091     assert ((orientation==0) || (orientation == M_PI)) ;
00092     double orientation_autre = shift_comp.get_mp().get_rot_phi() ;
00093     assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
00094     
00095     int alignes = (orientation == orientation_autre) ? 1 : -1 ;
00096     
00097     int np = shift_auto.get_mp().get_mg()->get_np(1) ;
00098     int nt = shift_auto.get_mp().get_mg()->get_nt(1) ;
00099     int nr = shift_auto.get_mp().get_mg()->get_nr(1) ;
00100     
00101     // Minimisation of the derivative of the shift on r
00102     Vector shift_tot (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00103     shift_tot.set(1).import(alignes*shift_comp(1)) ;
00104     shift_tot.set(2).import(alignes*shift_comp(2)) ;
00105     shift_tot.set(3).import(shift_comp(3)) ;
00106 
00107     shift_tot = shift_tot + shift_auto ;
00108  
00109     double indic = (orientation == 0) ? 1 : -1 ;
00110     
00111     Vector tbi (shift_tot) ;
00112     if (om != 0) {
00113     for (int i=1 ; i<=3 ; i++) {
00114         tbi.set(i).set_spectral_va().coef_i() ;
00115         tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00116         }
00117         
00118     tbi.set(1) = *shift_tot(1).get_spectral_va().c - indic *om * shift_tot.get_mp().ya ;
00119     tbi.set(2) = *shift_tot(2).get_spectral_va().c + indic *om * shift_tot.get_mp().xa ;
00120     tbi.std_spectral_base() ;
00121     tbi.set(1).annule_domain(nz-1) ;
00122     tbi.set(2).annule_domain(nz-1) ;
00123     }
00124       
00125     Vector derive_r (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00126     for (int i=1 ; i<=3 ; i++) 
00127     derive_r.set(i) = tbi(i).dsdr() ;
00128     
00129     
00130     // We substract a function in order that Kij is regular
00131     
00132     Valeur val_hor (shift_auto.get_mp().get_mg()) ;
00133     Valeur fonction_radiale (shift_auto.get_mp().get_mg()) ;
00134     Scalar enleve (shift_auto.get_mp()) ;
00135   
00136     double erreur = 0 ;
00137     for (int comp=1 ; comp<=3 ; comp++) {
00138         val_hor.annule_hard() ; 
00139         for (int k=0 ; k<np ; k++)
00140         for (int j=0 ; j<nt ; j++)
00141             for (int i=0 ; i<nr ; i++)
00142             val_hor.set(1, k, j, i) = derive_r(comp).
00143             val_grid_point(1, k, j, 0) ;
00144                  
00145         double r_0 = shift_auto.get_mp().val_r (1, -1, 0, 0) ;
00146         double r_1 = shift_auto.get_mp().val_r (1, 1, 0, 0) ;
00147         
00148         fonction_radiale = pow(r_1-shift_auto.get_mp().r, 3.)*
00149             (shift_auto.get_mp().r-r_0)/pow(r_1-r_0, 3.) ;
00150         fonction_radiale.annule(0) ;
00151         fonction_radiale.annule(2, nz-1) ;
00152           
00153         enleve = fonction_radiale * val_hor ;
00154         enleve.set_spectral_va().set_base (shift_auto(comp).
00155                            get_spectral_va().get_base()) ;
00156         
00157         if (norme(enleve)(1) != 0)
00158         shift_auto.set(comp) = shift_auto(comp) - enleve ;
00159         if (norme(shift_auto(comp))(1) > 1e-5) {
00160         Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
00161         if (erreur < diff(1))
00162             erreur = diff(1) ;
00163         }
00164     }
00165 
00166     shift_auto.change_triad(shift_auto.get_mp().get_bvect_spher()) ;
00167 
00168     double ttime = the_time[jtime] ;    
00169     beta_auto_evol.update(shift_auto, jtime, ttime) ; 
00170 
00171     return erreur ;
00172 }
00173 
00174 
00175 // Regularisation if only one black hole :
00176 double Isol_hor::regularise_one () {
00177 
00178     Vector shift (beta()) ;
00179     
00180     shift.change_triad(mp.get_bvect_cart()) ;
00181     // Vector B (without boost and rotation)
00182     Vector tbi (shift) ;
00183  
00184    for (int i=1 ; i<=3 ; i++) {
00185     tbi.set(i).set_spectral_va().coef_i() ;
00186     tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00187     }
00188     
00189     for (int i=1 ; i<=3 ; i++)
00190     shift(i).get_spectral_va().coef_i() ;
00191     
00192     tbi.set(1) = *shift(1).get_spectral_va().c - omega*mp.y - boost_x ;
00193     tbi.set(2) = *shift(2).get_spectral_va().c + omega*mp.x ;
00194     if (shift(3).get_etat() !=  ETATZERO)
00195     tbi.set(3) = *shift(3).get_spectral_va().c - boost_z ;
00196     else 
00197     tbi.set(3) = 0. ;
00198     tbi.std_spectral_base() ;
00199     
00200     // We only need values at the horizon
00201     tbi.set(1).annule_domain(mp.get_mg()->get_nzone()-1) ;
00202     tbi.set(2).annule_domain(mp.get_mg()->get_nzone()-1) ;
00203       
00204     Vector derive_r (mp, CON, mp.get_bvect_cart()) ;
00205     derive_r.set_etat_qcq() ;
00206     for (int i=1 ; i<=3 ; i++)
00207     derive_r.set(i) = tbi(i).dsdr() ;
00208     
00209     Valeur val_hor (mp.get_mg()) ;
00210     Valeur fonction_radiale (mp.get_mg()) ;
00211     Scalar enleve (mp) ;
00212     
00213     double erreur = 0 ;
00214     int np = mp.get_mg()->get_np(1) ;
00215     int nt = mp.get_mg()->get_nt(1) ;
00216     int nr = mp.get_mg()->get_nr(1) ;
00217     
00218     double r_0 = mp.val_r(1, -1, 0, 0) ;
00219     double r_1 = mp.val_r(1, 1, 0, 0) ;
00220     
00221     for (int comp=1 ; comp<=3 ; comp++) {
00222     val_hor.annule_hard() ;
00223     for (int k=0 ; k<np ; k++)
00224         for (int j=0 ; j<nt ; j++)
00225         for (int i=0 ; i<nr ; i++)
00226             val_hor.set(1, k, j, i) = derive_r(comp).val_grid_point(1, k, j, 0) ;
00227     
00228     fonction_radiale = pow(r_1-mp.r, 3.)* (mp.r-r_0)/pow(r_1-r_0, 3.) ;
00229     fonction_radiale.annule(0) ;
00230     fonction_radiale.annule(2, nz-1) ;
00231     
00232     enleve = fonction_radiale*val_hor ;
00233     enleve.set_spectral_va().base = shift(comp).get_spectral_va().base ;
00234     
00235     Scalar copie (shift(comp)) ;
00236     shift.set(comp) = shift(comp)-enleve ;
00237     shift.std_spectral_base() ;
00238 
00239     assert (shift(comp).check_dzpuis(0)) ;
00240     
00241     // Intensity of the correction (if nonzero)
00242         Tbl norm (norme(shift(comp))) ;
00243         if (norm(1) > 1e-5) {
00244         Tbl diff (diffrelmax (copie, shift(comp))) ;
00245         if (erreur<diff(1)) 
00246             erreur = diff(1) ;
00247         }
00248     }
00249     
00250     shift.change_triad(mp.get_bvect_spher()) ;
00251     beta_evol.update(shift, jtime, the_time[jtime]) ;
00252 
00253     return erreur ;
00254 }

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