00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char bhole_with_ns_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bhole/bhole_with_ns.C,v 1.10 2007/04/24 20:14:04 f_limousin Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #include <stdlib.h>
00070 #include <math.h>
00071
00072
00073 #include "tenseur.h"
00074 #include "bhole.h"
00075 #include "proto.h"
00076 #include "utilitaires.h"
00077 #include "et_bin_nsbh.h"
00078 #include "graphique.h"
00079 #include "scalar.h"
00080
00081
00082 void Bhole::solve_lapse_with_ns (double relax, int bound_nn, double lim_nn) {
00083
00084 assert ((relax>0) && (relax<=1)) ;
00085
00086 cout << "Resolution LAPSE" << endl ;
00087
00088
00089 Cmp lapse_old (n_auto()) ;
00090 Tenseur auxi (flat_scalar_prod(tkij_tot, tkij_auto)) ;
00091 Tenseur kk (mp) ;
00092 kk = 0 ;
00093 Tenseur work(mp) ;
00094 work.set_etat_qcq() ;
00095 for (int i=0 ; i<3 ; i++) {
00096 work.set() = auxi(i, i) ;
00097 kk = kk + work ;
00098 }
00099
00100
00101 Cmp psiq (pow(psi_tot(), 4.)) ;
00102 psiq.std_base_scal() ;
00103 Cmp source
00104 (-2*flat_scalar_prod(psi_auto.gradient(), grad_n_tot)()/psi_tot()
00105 +psiq*n_tot()*kk()) ;
00106 source.std_base_scal() ;
00107
00108 Cmp soluce(n_auto()) ;
00109
00110 if (bound_nn == 0){
00111
00112 Valeur limite (mp.get_mg()->get_angu()) ;
00113 limite = -0.5 + lim_nn ;
00114 int np = mp.get_mg()->get_np(1) ;
00115 int nt = mp.get_mg()->get_nt(1) ;
00116 for (int k=0 ; k<np ; k++)
00117 for (int j=0 ; j<nt ; j++)
00118 limite.set(0,k,j,0) -= n_comp() (1, k, j, 0) ;
00119 limite.std_base_scal() ;
00120
00121 soluce = source.poisson_dirichlet(limite, 0) ;
00122 }
00123 else {
00124 assert(bound_nn == 1);
00125
00126 Valeur limite (mp.get_mg()->get_angu()) ;
00127 limite.annule_hard() ;
00128 int np = mp.get_mg()->get_np(1) ;
00129 int nt = mp.get_mg()->get_nt(1) ;
00130 for (int k=0 ; k<np ; k++)
00131 for (int j=0 ; j<nt ; j++)
00132 limite.set(0,k,j,0) -= n_tot()(1, k, j, 0)/psi_tot()(1,k,j,0)*
00133 psi_tot().dsdr()(1,k,j,0) ;
00134 limite.std_base_scal() ;
00135
00136 soluce = source.poisson_neumann(limite, 0) ;
00137 }
00138
00139 soluce = soluce + 0.5 ;
00140
00141 n_auto.set() = relax*soluce + (1-relax)*lapse_old ;
00142 n_auto.set().raccord(3) ;
00143 }
00144
00145
00146 void Bhole::solve_psi_with_ns (double relax) {
00147
00148 assert ((relax>0) && (relax<=1)) ;
00149
00150 cout << "Resolution PSI" << endl ;
00151
00152 Cmp psi_old (psi_auto()) ;
00153 Tenseur auxi (flat_scalar_prod(tkij_auto, tkij_tot)) ;
00154 Tenseur kk (mp) ;
00155 kk = 0 ;
00156 Tenseur work(mp) ;
00157 work.set_etat_qcq() ;
00158 for (int i=0 ; i<3 ; i++) {
00159 work.set() = auxi(i, i) ;
00160 kk = kk + work ;
00161 }
00162 Cmp psic (pow(psi_tot(), 5.)) ;
00163 psic.std_base_scal() ;
00164
00165
00166 Cmp source (-psic*kk()/8.) ;
00167 source.std_base_scal() ;
00168
00169
00170 Valeur limite (mp.get_mg()->get_angu()) ;
00171 limite = 1 ;
00172
00173
00174 int np = mp.get_mg()->get_np(1) ;
00175 int nt = mp.get_mg()->get_nt(1) ;
00176
00177 double* vec_s = new double[3] ;
00178 Mtbl tet_mtbl (mp.get_mg()) ;
00179 tet_mtbl = mp.tet ;
00180 Mtbl phi_mtbl (mp.get_mg()) ;
00181 phi_mtbl = mp.phi ;
00182
00183 for (int k=0 ; k<np ; k++)
00184 for (int j=0 ; j<nt ; j++) {
00185
00186 double tet = tet_mtbl(1,k,j,0) ;
00187 double phi = phi_mtbl(1,k,j,0) ;
00188 vec_s[0] = cos(phi)*sin(tet) ;
00189 vec_s[1] = sin(phi)*sin(tet) ;
00190 vec_s[2] = cos(tet) ;
00191 double part_ss = 0 ;
00192 if (tkij_tot.get_etat()==ETATQCQ)
00193 for (int m=0 ; m<3 ; m++)
00194 for (int n=0 ; n<3 ; n++)
00195 part_ss += vec_s[m]*vec_s[n]*tkij_tot(m,n)(1,k,j,0) ;
00196 part_ss *= pow(psi_tot()(1,k,j,0),3.)/4. ;
00197
00198
00199 limite.set(0, k, j, 0) = -0.5/rayon*psi_tot()(1, k, j, 0) -
00200 psi_comp().dsdr()(1, k, j, 0) - part_ss ;
00201 }
00202
00203
00204 limite.std_base_scal() ;
00205
00206 Cmp soluce (source.poisson_neumann(limite, 0)) ;
00207 soluce = soluce + 1./2. ;
00208
00209 psi_auto.set() = relax*soluce + (1-relax)*psi_old ;
00210 psi_auto.set().raccord(3) ;
00211
00212 }
00213
00214
00215 void Bhole::solve_shift_with_ns (const Et_bin_nsbh& ns,
00216 double precision, double relax,
00217 int bound_nn, double lim_nn) {
00218
00219 assert (precision > 0) ;
00220 assert ((relax>0) && (relax<=1)) ;
00221
00222 cout << "resolution SHIFT" << endl ;
00223
00224 Tenseur shift_old (shift_auto) ;
00225
00226 Tenseur source (-6*flat_scalar_prod(taij_tot, psi_auto.gradient())/psi_tot
00227 + 2*flat_scalar_prod(tkij_tot, n_auto.gradient())) ;
00228 source.set_std_base() ;
00229
00230
00231 if (source.get_etat() == ETATQCQ) {
00232 int indic = 0 ;
00233 for (int i=0 ; i<3 ; i++)
00234 if (source(i).get_etat() == ETATQCQ)
00235 indic = 1 ;
00236 if (indic ==0)
00237 for (int i=0 ; i<3 ; i++)
00238 source.set_etat_zero() ;
00239 }
00240
00241
00242
00243 if (source.get_etat() == ETATQCQ)
00244 for (int i=0 ; i<3 ; i++)
00245 source.set(i).filtre(4) ;
00246
00247
00248
00249 int np = mp.get_mg()->get_np(1) ;
00250 int nt = mp.get_mg()->get_nt(1) ;
00251
00252 Mtbl x_mtbl (mp.get_mg()) ;
00253 x_mtbl.set_etat_qcq() ;
00254 Mtbl y_mtbl (mp.get_mg()) ;
00255 y_mtbl.set_etat_qcq() ;
00256 x_mtbl = mp.x ;
00257 y_mtbl = mp.y ;
00258
00259 double air, theta, phi, xabs, yabs, zabs ;
00260 Mtbl Xabs (mp.get_mg()) ;
00261 Xabs = mp.xa ;
00262 Mtbl Yabs (mp.get_mg()) ;
00263 Yabs = mp.ya ;
00264 Mtbl Zabs (mp.get_mg()) ;
00265 Zabs = mp.za ;
00266
00267 Mtbl tet_mtbl (mp.get_mg()) ;
00268 tet_mtbl = mp.tet ;
00269 Mtbl phi_mtbl (mp.get_mg()) ;
00270 phi_mtbl = mp.phi ;
00271
00272
00273 Base_val** bases = mp.get_mg()->std_base_vect_cart() ;
00274
00275 Valeur lim_x (mp.get_mg()->get_angu()) ;
00276 lim_x = 1 ;
00277 Valeur lim_y (mp.get_mg()->get_angu()) ;
00278 lim_y = 1 ;
00279 Valeur lim_z (mp.get_mg()->get_angu()) ;
00280 lim_z = 1 ;
00281
00282 for (int k=0 ; k<np ; k++)
00283 for (int j=0 ; j<nt ; j++) {
00284
00285 double tet = tet_mtbl(1,k,j,0) ;
00286 double phy = phi_mtbl(1,k,j,0) ;
00287
00288 xabs = Xabs (1, k, j, 0) ;
00289 yabs = Yabs (1, k, j, 0) ;
00290 zabs = Zabs (1, k, j, 0) ;
00291
00292 ns.get_mp().convert_absolute (xabs, yabs, zabs, air, theta, phi) ;
00293
00294 lim_x.set(0, k, j, 0) = omega*Yabs(0, 0, 0, 0) +
00295 omega_local*y_mtbl(1,k,j,0) -
00296 ns.get_shift_auto()(0).val_point(air, theta, phi) +
00297 n_tot()(1,k,j,0)/psi_tot()(1,k,j,0)/psi_tot()(1,k,j,0)*
00298 cos(phy)*sin(tet) ;
00299 lim_x.base = *bases[0] ;
00300
00301
00302 lim_y.set(0, k, j, 0) = -omega*Xabs(0, 0, 0, 0) -
00303 omega_local*x_mtbl(1,k,j,0) -
00304 ns.get_shift_auto()(1).val_point(air, theta, phi) +
00305 n_tot()(1,k,j,0)/psi_tot()(1,k,j,0)/psi_tot()(1,k,j,0)*
00306 sin(phy)*sin(tet) ;
00307
00308 lim_z.set(0, k, j, 0) = -
00309 ns.get_shift_auto()(2).val_point(air, theta, phi) +
00310 n_tot()(1,k,j,0)/psi_tot()(1,k,j,0)/psi_tot()(1,k,j,0)*cos(tet) ;
00311 }
00312
00313 lim_x.base = *bases[0] ;
00314 lim_y.base = *bases[1] ;
00315 lim_z.base = *bases[2] ;
00316
00317
00318 for (int i=0 ; i<3 ; i++)
00319 delete bases[i] ;
00320 delete [] bases ;
00321
00322
00323 poisson_vect_frontiere(1./3., source, shift_auto, lim_x, lim_y,
00324 lim_z, 0, precision, 20) ;
00325
00326 shift_auto = relax*shift_auto + (1-relax)*shift_old ;
00327
00328 for (int i=0; i<3; i++)
00329 shift_auto.set(i).raccord(3) ;
00330
00331
00332
00333
00334 if (bound_nn == 0 && lim_nn == 0)
00335 regul = regle (shift_auto, ns.get_shift_auto(), omega, omega_local) ;
00336 else
00337 regul = 0. ;
00338
00339 }
00340
00341
00342 void Bhole::equilibrium (const Et_bin_nsbh& comp,
00343 double precision, double relax,
00344 int bound_nn, double lim_nn) {
00345
00346
00347 solve_lapse_with_ns (relax, bound_nn, lim_nn) ;
00348
00349
00350 solve_psi_with_ns (relax) ;
00351
00352 if (omega != 0)
00353
00354 solve_shift_with_ns (comp, precision, relax, bound_nn, lim_nn) ;
00355
00356 }
00357
00358
00359 void Bhole::update_metric (const Et_bin_nsbh& comp) {
00360
00361 fait_n_comp(comp) ;
00362 fait_psi_comp(comp) ;
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 }
00378
00379