4 #include "utilitaires.h" 9 #include "param_elliptic.h" 18 Sym_tensor boundfree_tensBC ( Sym_tensor source, Vector Beta, Scalar Psi, Scalar Nn, Sym_tensor hij_guess,
double precision,
int loopmax) {
19 cout <<
"================================================================" << endl;
20 cout <<
"STARTING THE SUBITERATION FOR THE CONFORMAL METRIC" << endl;
21 cout <<
" iteration parameters are the following: " << endl;
22 cout <<
" convergence precision required:" << precision << endl;
23 cout <<
" max number of global steps :" << loopmax << endl;
24 cout <<
"================================================================" << endl;
28 const int nz = (*source.get_mp().get_mg()).get_nzone();
29 int nr = (*source.get_mp().get_mg()).get_nr(1);
30 const Coord& rr = source.
get_mp().
r;
31 Scalar rrr (source.get_mp()) ;
33 rrr.std_spectral_base();
35 const Metric_flat& mets = (source.get_mp()).flat_met_spher() ;
39 Sym_tensor hij = hij_guess;
40 Sym_tensor hij_new = hij;
42 Scalar n2sp4 = (Nn/(Psi*Psi))*(Nn/(Psi*Psi)) ;
43 n2sp4.std_spectral_base();
46 Scalar khi = hij(1,1);
47 if (khi.get_etat() == ETATZERO) {
50 khi.std_spectral_base() ;
52 khi.set_spectral_va().ylm();
55 Scalar mmu = hij.mu();
56 if (mmu.get_etat() == ETATZERO) {
58 mmu.std_spectral_base() ;
60 mmu.set_spectral_va().ylm();
61 Scalar etta = hij.eta();
62 if (etta.get_etat() == ETATZERO) {
64 etta.std_spectral_base() ;
66 etta.set_spectral_va().ylm();
67 Scalar Aa = hij.compute_A();
68 if (Aa.get_etat() == ETATZERO) {
70 Aa.std_spectral_base() ;
72 Aa.set_spectral_va().ylm();
73 Scalar Bt = hij.compute_tilde_B();
74 if (Bt.get_etat() == ETATZERO) {
76 Bt.std_spectral_base() ;
78 Bt.set_spectral_va().ylm();
79 Scalar hh = hij.trace(mets);
80 if (hh.get_etat() == ETATZERO) {
82 hh.std_spectral_base() ;
86 Scalar fit1(source.get_mp()); fit1.set_etat_qcq();
89 Scalar Aanew (source.get_mp()); Aanew.annule_hard(); Aanew.std_spectral_base();
90 Scalar Btnew (source.get_mp()); Btnew.annule_hard(); Btnew.std_spectral_base();
95 Sym_tensor LbLbhij = (hij.derive_lie(Beta)).derive_lie(Beta);
97 LbLbhij.annule_domain(0);
98 LbLbhij.inc_dzpuis(1);
100 Sym_tensor source_hij = source/n2sp4;
101 Scalar sourcetrace = source_hij.trace(mets);
102 Scalar Bttrace = source_hij.compute_tilde_B();
104 Sym_tensor source_hij2 = LbLbhij/n2sp4;
106 Scalar Btsource2 = source_hij2.compute_tilde_B();
108 Scalar source_Bt2 = Bttrace + Btsource2;
110 source_hij = source_hij + source_hij2;
112 Scalar r2LbLbrr = LbLbhij(1,1);
115 Scalar LbLbmu = LbLbhij.mu();
117 Scalar source_khi2 = source_hij(1,1);
118 source_khi2.mult_r();
119 source_khi2.mult_r();
121 Scalar source_mu2 = source_hij.mu();
122 Scalar source_eta2 = source_hij.eta();
124 Scalar source_A2 = source_hij.compute_A();
127 source_khi2.annule_domain(0);
128 source_mu2.annule_domain(0);
129 source_A2.annule_domain(0);
130 source_Bt2.annule_domain(0);
131 source_eta2.annule_domain(0);
139 Scalar Betacarre = (Beta(1)*Beta(1))/n2sp4 ;
141 double fitd1 = (Betacarre.val_grid_point(1,0,0,nr-1) - Betacarre.val_grid_point(1,0,0,0))/(rrr.val_grid_point(1,0,0,nr-1) - rrr.val_grid_point(1,0,0,0)) ;
147 int nrint = (nr-1)/2 ;
148 double ampl_r = (rrr.val_grid_point(1,0,0, nr -1) - rrr.val_grid_point(1,0,0 ,0))/2.;
150 Scalar approx(source.get_mp());
151 approx.annule_hard();
152 approx.std_spectral_base();
156 fit1 = fitd1*(rrr-1.) +1.;
158 approx.set_domain(1)= fit1.set_domain(1);
163 Scalar firststep = Betacarre - approx;
165 double ampli = firststep.val_grid_point(1,0,0,nrint);
166 double fit2d1 = - ampli/(ampl_r* ampl_r);
170 approx.set_domain(1) += (fit2d1*(rrr - 1.)*(rrr - rrr.val_grid_point(1,0,0,nr-1))).set_domain(1);
173 double fit0d2 = approx.val_grid_point(1,0,0,nr -1);
174 double fit1d2 = (Betacarre.val_grid_point(2,0,0,nr-1) - fit0d2)/(rrr.val_grid_point(2,0,0,nr-1)- rrr.val_grid_point(2,0,0,0));
175 double fit0d3 = Betacarre.val_grid_point(3,0,0,0);
176 double fit1d3 = ( - fit0d3)/(rrr.val_grid_point(3,0,0,nr-1)- rrr.val_grid_point(3,0,0,0));
178 approx.set_domain(2) = (fit0d2 + fit1d2*(rrr - rrr.val_grid_point(2,0,0,0))).set_domain(2);
179 approx.set_domain(3) = (fit0d3 + fit1d3*(rrr - rrr.val_grid_point(3,0,0,0))).set_domain(3);
183 for(
int ii=1; ii<=3; ii++){
185 source_khi2.set_domain(ii) += (-approx*(khi.dsdr().dsdr())).set_domain(ii);
187 source_mu2.set_domain(ii) += (-approx*(mmu.dsdr().dsdr())).set_domain(ii);
189 source_eta2.set_domain(ii) += (-approx*(etta.dsdr().dsdr())).set_domain(ii);
191 source_A2.set_domain(ii) += (-approx*(Aa.dsdr().dsdr())).set_domain(ii);
193 source_Bt2.set_domain(ii) += (-approx*(Bt.dsdr().dsdr())).set_domain(ii);
200 Scalar Aa_old(source.get_mp());
201 Scalar Bt_old(source.get_mp());
205 cout <<
"==================================================================================" << endl;
206 cout <<
"amplitude for the tensor equation source (used as scaling for convergence marker)" << endl;
207 cout <<
"==================================================================================" << endl;
209 double diff_ent = 0.15 ;
216 for (
int mer = 0; (diff_ent>precision) && (mer< loopmax) ; mer++) {
220 tensorelliptic (source_A2, Aanew , fitd1, fit2d1, fit0d2, fit1d2, fit0d3, fit1d3);
221 tensorellipticBt (source_Bt2, Btnew, fitd1, fit2d1, fit0d2, fit1d2, fit0d3, fit1d3);
230 Scalar essaiA = Aanew.laplacian() - approx*(Aanew.dsdr().dsdr());
231 essaiA.annule_domain(0);
232 Scalar bobofA = essaiA -source_A2 ;
233 bobofA.set_spectral_va().ylm() ;
236 bobofA.set_spectral_va().ylm_i();
248 Scalar mmuAsr = mmuA; mmuAsr.div_r();
249 Scalar xxA(source.get_mp()); xxA.annule_hard(); xxA.std_spectral_base();
251 const Scalar AA = Aa;
253 Sym_tensor_trans hijt(source.get_mp(), source.get_mp().get_bvect_spher(), mets);
255 hijt.sol_Dirac_A2 ( AA , mmuAsr, xxA, source_mu2, par_bc);
259 Scalar musrsr = mmuAsr; musrsr.div_r_dzpuis(2);
260 Aanew = xxA.dsdr() - musrsr;
261 Scalar xxsr = xxA; xxsr.div_r_dzpuis(2);
267 Scalar hrrBC (source.get_mp()); hrrBC.annule_hard();
268 Scalar wwBC(source.get_mp()); wwBC.annule_hard();
269 Scalar tilde_etaBC(source.get_mp()); tilde_etaBC.annule_hard();
271 Scalar source_khi3 = source_khi2;
272 source_khi3.annule_domain(nz-1);
274 source_khi3.set_spectral_va().ylm();
276 hijt.sol_Dirac_BC3( Bt, hh, hrrBC , tilde_etaBC , wwBC , source_khi3, source_eta2, par_bc, par_bc) ;
279 hij_new.set_auxiliary(hrrBC, tilde_etaBC, mmuAsr, wwBC, xxA, hh -hrrBC);
281 hij= relax*hij_new + (1 - relax)*hij ;
284 hh = (1 + hij(1,1))*( hij(2,3)*hij(2,3) - hij(2,2)*hij(3,3) )
285 + hij(1,2)*hij(1,2)*(1 + hij(3,3))
286 + hij(1,3)*hij(1,3)*(1 + hij(2,2))
287 - hij(1,1)*(hij(2,2) + hij(3,3)) - 2*hij(1,2)*hij(1,3)*hij(2,3) ;
291 khi.mult_r_dzpuis(0);
295 Aa = hij.compute_A();
296 Bt = hij.compute_tilde_B();
299 Aa.set_spectral_va().ylm();
300 Bt.set_spectral_va().ylm();
301 Aa_old.set_spectral_va().ylm();
302 Bt_old.set_spectral_va().ylm();
304 diff_ent =
max(
maxabs (Bt - Bt_old))/scale;
311 LbLbhij = (hij.derive_lie(Beta)).derive_lie(Beta);
312 LbLbhij.inc_dzpuis(1);
313 r2LbLbrr = LbLbhij(1,1);
316 LbLbmu = LbLbhij.mu();
319 source_hij = source/n2sp4;
321 Bttrace = source_hij.compute_tilde_B();
323 source_hij2 = LbLbhij/n2sp4;
325 Btsource2 = source_hij2.compute_tilde_B();
327 source_Bt2 = Bttrace + Btsource2;
329 source_hij = source_hij + source_hij2;
331 source_khi2 = source_hij(1,1);
332 source_khi2.mult_r();
333 source_khi2.mult_r();
334 source_mu2 = source_hij.mu();
335 source_eta2 = source_hij.eta();
336 source_A2= source_hij.compute_A();
339 source_A2.set_spectral_va().set_base( Aa.set_spectral_va().get_base());
340 source_Bt2.set_spectral_va().set_base( Bt.set_spectral_va().get_base());
342 for(
int ii=1; ii<=3; ii++){
343 source_khi2.set_domain(ii) += (-approx*(khi.dsdr().dsdr())).set_domain(ii);
344 source_mu2.set_domain(ii) += (-approx*(mmu.dsdr().dsdr())).set_domain(ii);
345 source_eta2.set_domain(ii) += (-approx*(etta.dsdr().dsdr())).set_domain(ii);
346 source_A2.set_domain(ii) += (-approx*(Aa.dsdr().dsdr())).set_domain(ii);
347 source_Bt2.set_domain(ii) += (-approx*(Bt.dsdr().dsdr())).set_domain(ii);
349 source_khi2.annule_domain(0);
350 source_mu2.annule_domain(0);
351 source_eta2.annule_domain(0);
352 source_A2.annule_domain(0);
353 source_Bt2.annule_domain(0);
375 cout <<
"diff_ent" << diff_ent << endl;
Tbl maxabs(const Tensor &aa, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maxima in each domain of the absolute values of the tensor components.
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
const Map & get_mp() const
Returns the mapping.
Coord r
r coordinate centered on the grid