regularise_shift.C

00001 /*
00002  *   Copyright (c) 2000-2001 Philippe Grandclement
00003  *
00004  *   This file is part of LORENE.
00005  *
00006  *   LORENE is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   LORENE is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with LORENE; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 char regularise_shift_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/regularise_shift.C,v 1.5 2006/04/27 09:12:32 p_grandclement Exp $" ;
00024 
00025 /*
00026  * $Id: regularise_shift.C,v 1.5 2006/04/27 09:12:32 p_grandclement Exp $
00027  * $Log: regularise_shift.C,v $
00028  * Revision 1.5  2006/04/27 09:12:32  p_grandclement
00029  * First try at irrotational black holes
00030  *
00031  * Revision 1.4  2005/08/29 15:10:14  p_grandclement
00032  * Addition of things needed :
00033  *   1) For BBH with different masses
00034  *   2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
00035  *   WORKING YET !!!
00036  *
00037  * Revision 1.3  2003/10/03 15:58:44  j_novak
00038  * Cleaning of some headers
00039  *
00040  * Revision 1.2  2003/02/13 16:40:25  p_grandclement
00041  * Addition of various things for the Bin_ns_bh project, non of them being
00042  * completely tested
00043  *
00044  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00045  * LORENE
00046  *
00047  * Revision 2.6  2001/05/07  09:11:48  phil
00048  * *** empty log message ***
00049  *
00050  * Revision 2.5  2001/01/29  14:30:48  phil
00051  * ajout type rotation
00052  *
00053  * Revision 2.4  2000/11/02  10:18:05  phil
00054  * modification du degre de l;a fonction\
00055  * de correction. On passe de 2 a 3
00056  *
00057  * Revision 2.3  2000/10/31  10:04:28  phil
00058  * correction importation
00059  *
00060  * Revision 2.2  2000/10/26  12:34:17  phil
00061  * *** empty log message ***
00062  *
00063  * Revision 2.1  2000/10/26  12:31:55  phil
00064  * correction orientation pour calcul du shift total
00065  *
00066  * Revision 2.0  2000/10/19  10:08:03  phil
00067  * *** empty log message ***
00068  *
00069  *
00070  * $Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/regularise_shift.C,v 1.5 2006/04/27 09:12:32 p_grandclement Exp $
00071  *
00072  */
00073 
00074 
00075 //Standard
00076 #include <stdlib.h>
00077 #include <math.h>
00078 
00079 //Lorene
00080 #include "nbr_spx.h"
00081 #include "tenseur.h"
00082 
00083 double regle (Tenseur& shift_auto, const Tenseur& shift_comp, double omega, double omega_local) {
00084     
00085     Tenseur shift_old (shift_auto) ;
00086     
00087     double orientation = shift_auto.get_mp()->get_rot_phi() ;
00088     assert ((orientation==0) || (orientation == M_PI)) ;
00089     double orientation_autre = shift_comp.get_mp()->get_rot_phi() ;
00090     assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
00091     
00092     int alignes = (orientation == orientation_autre) ? 1 : -1 ;
00093     
00094     // Cas triades identiques
00095     if (*shift_comp.get_triad() == *shift_auto.get_triad())
00096          alignes = 1 ;
00097     
00098     int nz = shift_auto.get_mp()->get_mg()->get_nzone() ;
00099     int np = shift_auto.get_mp()->get_mg()->get_np(1) ;
00100     int nt = shift_auto.get_mp()->get_mg()->get_nt(1) ;
00101     int nr = shift_auto.get_mp()->get_mg()->get_nr(1) ;
00102     
00103     // On minimise la valeur de la derivee de B sur R :
00104     Tenseur shift_tot (*shift_auto.get_mp(), 1, CON, *shift_auto.get_triad()) ;
00105     shift_tot.set_etat_qcq() ;
00106     shift_tot.set(0).import_asymy (alignes*shift_comp(0)) ;
00107     shift_tot.set(1).import_symy (alignes*shift_comp(1)) ;
00108     shift_tot.set(2).import_asymy (shift_comp(2)) ;
00109 
00110     shift_tot = shift_tot + shift_auto ;
00111  
00112     double indic = (orientation == 0) ? 1 : -1 ;
00113     
00114     Mtbl xa_mtbl (shift_tot.get_mp()->get_mg()) ;
00115     xa_mtbl = shift_tot.get_mp()->xa ;
00116     Mtbl ya_mtbl (shift_tot.get_mp()->get_mg()) ;
00117     ya_mtbl = shift_tot.get_mp()->ya ;
00118     
00119     Tenseur tbi (shift_tot) ;
00120     if (omega != 0) {
00121     for (int i=0 ; i<3 ; i++) {
00122         tbi.set(i).va.coef_i() ;
00123         tbi.set(i).va.set_etat_c_qcq() ;
00124         }
00125         
00126     tbi.set(0) = *shift_tot(0).va.c - indic *omega * ya_mtbl(0,0,0,0) - indic*omega_local* shift_tot.get_mp()->y ;
00127     tbi.set(1) = *shift_tot(1).va.c + indic *omega * xa_mtbl(0,0,0,0) + indic*omega_local* shift_tot.get_mp()->x ;
00128     tbi.set_std_base() ;
00129     tbi.set(0).annule(nz-1) ;
00130     tbi.set(1).annule(nz-1) ;
00131     }
00132      
00133     Tenseur derive_r (*shift_auto.get_mp(), 1, CON, *shift_auto.get_triad()) ;
00134     derive_r.set_etat_qcq() ;
00135     for (int i=0 ; i<3 ; i++) {
00136     if (tbi(i).get_etat() != ETATZERO)
00137         derive_r.set(i) = tbi(i).dsdr() ;
00138     else
00139         derive_r.set(i).set_etat_zero() ;
00140     }
00141     
00142     // On enleve un fonction pour rendre Kij regulier !
00143     
00144     Valeur val_hor (shift_auto.get_mp()->get_mg()) ;
00145     Valeur fonction_radiale (shift_auto.get_mp()->get_mg()) ;
00146     Cmp enleve (shift_auto.get_mp()) ;
00147   
00148     double erreur = 0 ;
00149     for (int comp=0 ; comp<3 ; comp++)
00150     {
00151         val_hor.annule_hard() ; // Pour initialiser les tableaux 
00152         for (int k=0 ; k<np ; k++)
00153         for (int j=0 ; j<nt ; j++)
00154             for (int i=0 ; i<nr ; i++)
00155             val_hor.set(1, k, j, i) = derive_r(comp) (1, k, j, 0) ;
00156                  
00157         double r_0 = shift_auto.get_mp()->val_r (1, -1, 0, 0) ;
00158         double r_1 = shift_auto.get_mp()->val_r (1, 1, 0, 0) ;
00159         
00160         fonction_radiale = pow(r_1-shift_auto.get_mp()->r, 3.)*
00161             (shift_auto.get_mp()->r-r_0)/pow(r_1-r_0, 3.) ;
00162         fonction_radiale.annule(0) ;
00163         fonction_radiale.annule(2, nz-1) ;
00164           
00165         enleve = fonction_radiale * val_hor ;
00166         enleve.va.base = shift_auto(comp).va.base ;
00167         
00168         if (norme(enleve)(1) != 0)
00169         shift_auto.set(comp) = shift_auto(comp) - enleve ;
00170         if (norme(shift_auto(comp))(1) > 1e-5) {
00171         Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
00172         if (erreur < diff(1))
00173             erreur = diff(1) ;
00174         }
00175     }
00176     return erreur ;
00177 }

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