28 char tslice_dirac_max_evolve_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_dirac_max_evolve.C,v 1.22 2015/08/10 15:32:27 j_novak Exp $" ;
111 #include "time_slice.h"
113 #include "graphique.h"
114 #include "utilitaires.h"
118 const Tbl& monitor_scalar(
const Scalar& uu, Tbl& resu) ;
121 int niter_elliptic,
double relax,
122 int check_mod,
int save_mod,
123 int method_poisson_vect,
int nopause,
124 const char* graph_device,
bool verbose,
137 int ngraph0_mon = 70 ;
139 int nz_bound = nz - 2 ;
149 for (
int lz=1; lz<nz; lz++) {
154 for (
int it=0; it<
depth; it++) {
169 for (
int i=1; i<=3; i++)
170 for (
int j=i; j<=3; j++)
171 if ( hijtt_old(i,j).get_etat() == ETATZERO )
173 hijtt_old.
annule(0, nz_bound) ;
179 for (
int i=1; i<=3; i++)
180 for (
int j=i; j<=3; j++)
181 if ( hatatt_old(i,j).get_etat() == ETATZERO )
183 hatatt_old.
annule(0, nz_bound) ;
203 double Rmax = map.
val_r(nz-2, 1., 0., 0.) ;
204 double ray_des = 1.25 * Rmax ;
208 double an = 23./12. ;
209 double anm1 = -4./3. ;
210 double anm2 = 5./12. ;
213 int i_minus_one = -1 ;
217 double *l_val_A =
new double(1./Rmax) ;
218 double *l_der_A =
new double(1.) ;
225 Tbl* tmp_Acc =
new Tbl(np2, nt) ;
226 Tbl& Acc = *tmp_Acc ;
232 double* l_val_B =
new double(1./Rmax) ;
233 double* l_der_B =
new double(1.) ;
236 par_B.
add_int(i_minus_one, 2) ;
240 Tbl* tmp_Bcc =
new Tbl(np2, nt) ;
241 Tbl& Bcc = *tmp_Bcc ;
249 Tbl xijm1_b(np2, nt) ;
256 Tbl xijm1_a(np2, nt) ;
266 Tbl* cf_b_hh =
new Tbl(10) ;
268 cf_b_hh->
set(0) = 11*Rmax + 12*pdt ;
269 cf_b_hh->
set(1) = 6*Rmax*pdt ;
270 cf_b_hh->
set(2) = 0 ;
271 cf_b_hh->
set(3) = 0 ;
272 cf_b_hh->
set(4) = 11*Rmax*Rmax + 18*Rmax*pdt ;
273 cf_b_hh->
set(5) = 6*Rmax*Rmax*pdt ;
274 cf_b_hh->
set(6) = 0 ;
275 cf_b_hh->
set(7) = 0 ;
276 cf_b_hh->
set(8) = 0 ;
277 cf_b_hh->
set(9) = 0 ;
279 Tbl* kib_hh =
new Tbl(np2, nt) ;
280 Tbl& khib_hh = *kib_hh ;
283 Tbl* mb_hh =
new Tbl(np2, nt) ;
284 Tbl& mub_hh = *mb_hh ;
290 Tbl xij_mu_hh(np2, nt) ;
292 initialize_outgoing_BC(nz_bound, mu_hh_evol[
jtime] , mu_a_evol[
jtime], xij_mu_hh) ;
293 Tbl xijm1_mu_hh(np2, nt) ;
295 initialize_outgoing_BC(nz_bound, mu_hh_evol[
jtime-1] , mu_a_evol[
jtime-1],
298 Tbl xij_ki_hh(np2, nt) ;
300 initialize_outgoing_BC(nz_bound, khi_hh_evol[
jtime] , khi_a_evol[
jtime], xij_ki_hh) ;
301 Tbl xijm1_ki_hh(np2, nt) ;
303 initialize_outgoing_BC(nz_bound, khi_hh_evol[
jtime-1] , khi_a_evol[
jtime-1],
307 par_bc_hata.
add_int(nz_bound) ;
308 Tbl* cf_b_hata =
new Tbl(10) ;
310 cf_b_hata->
set(0) = 11*Rmax + 12*pdt ;
311 cf_b_hata->
set(1) = 6*Rmax*pdt ;
312 cf_b_hata->
set(2) = 0 ;
313 cf_b_hata->
set(3) = 0 ;
314 cf_b_hata->
set(4) = 11*Rmax*Rmax + 18*Rmax*pdt ;
315 cf_b_hata->
set(5) = 6*Rmax*Rmax*pdt ;
316 cf_b_hata->
set(6) = 0 ;
317 cf_b_hata->
set(7) = 0 ;
318 cf_b_hata->
set(8) = 0 ;
319 cf_b_hata->
set(9) = 0 ;
321 Tbl* kib_hata =
new Tbl(np2, nt) ;
322 Tbl& khib_hata = *kib_hata ;
325 Tbl* mb_hata =
new Tbl(np2, nt) ;
326 Tbl& mub_hata = *mb_hata ;
332 Tbl xij_mu_a(np2, nt) ;
334 initialize_outgoing_BC(nz_bound, mu_a_evol[
jtime] ,
336 Tbl xijm1_mu_a(np2, nt) ;
338 tmp = ( mu_a_evol[
jtime] - mu_a_evol[
jtime-2] ) / (2.*pdt) ;
339 initialize_outgoing_BC(nz_bound, mu_a_evol[
jtime-1] , tmp, xijm1_mu_a) ;
341 Tbl xij_ki_a(np2, nt) ;
343 initialize_outgoing_BC(nz_bound, khi_a_evol[
jtime] ,
345 Tbl xijm1_ki_a(np2, nt) ;
347 tmp = ( khi_a_evol[
jtime] - khi_a_evol[
jtime-2] ) / (2.*pdt) ;
348 initialize_outgoing_BC(nz_bound, khi_a_evol[
jtime-1] , tmp, xijm1_ki_a) ;
355 Vector beta_new(map, CON, triad) ;
379 Tbl select_scalar(6) ;
384 const Vector& hat_S = ( mom_euler == 0x0 ? zero_vec : *mom_euler ) ;
392 for (
int jt = 0; jt < nb_time_steps; jt++) {
397 if (jt%check_mod == 0) {
399 "==============================================================\n"
402 <<
", Log of central lapse: " <<
log(
nn().val_grid_point(0,0,0,0)) << endl
403 <<
"==============================================================\n" ;
408 if (jt > 0)
des_evol(m_adm,
"ADM mass",
"Variation of ADM mass",
409 ngraph0_mon, graph_device) ;
412 nn_monitor.
update(monitor_scalar(
nn(), select_scalar),
415 psi_monitor.
update(monitor_scalar(
psi(), select_scalar),
418 A_h_monitor.
update(monitor_scalar(
A_hh(), select_scalar),
421 B_h_monitor.
update(monitor_scalar(
B_hh(), select_scalar),
424 trh_monitor.
update(monitor_scalar(
trh(), select_scalar),
443 int jt_graph = jt / check_mod ;
446 double max_error = tham(0,0) ;
447 for (
int l=1; l<nz-1; l++) {
448 double xx = fabs(tham(0,l)) ;
449 if (xx > max_error) max_error = xx ;
452 if (jt > 0)
des_evol(test_ham_constr,
"Absolute error",
453 "Check of Hamiltonian constraint",
454 ngraph0_mon+1, graph_device) ;
457 max_error = tmom(0,0) ;
458 for (
int l=1; l<nz-1; l++) {
459 double xx = fabs(tmom(0,l)) ;
460 if (xx > max_error) max_error = xx ;
463 if (jt > 0)
des_evol(test_mom_constr_r,
"Absolute error",
464 "Check of momentum constraint (r comp.)", ngraph0_mon+2,
467 max_error = tmom(1,0) ;
468 for (
int l=1; l<nz-1; l++) {
469 double xx = fabs(tmom(1,l)) ;
470 if (xx > max_error) max_error = xx ;
473 if (jt > 0)
des_evol(test_mom_constr_t,
"Absolute error",
474 "Check of momentum constraint (\\gh comp.)", ngraph0_mon+3,
477 max_error = tmom(2,0) ;
478 for (
int l=1; l<nz-1; l++) {
479 double xx = fabs(tmom(2,l)) ;
480 if (xx > max_error) max_error = xx ;
483 if (jt > 0)
des_evol(test_mom_constr_p,
"Absolute error",
484 "Check of momentum constraint (\\gf comp.)", ngraph0_mon+4,
490 for (
int i=1; i<=3; i++)
491 for(
int j=1; j<=i; j++) {
492 max_error = tevol(i, j, 0) ;
493 for (
int l=1; l<nz-1; l++) {
494 double xx = fabs(tevol(i,j,l)) ;
495 if (xx > max_error) max_error = xx ;
497 evol_check.
set(i) = max_error ;
503 if (jt%save_mod == 0) {
504 m_adm.
save(
"adm_mass.d") ;
505 nn_monitor.
save(
"nn_monitor.d") ;
506 psi_monitor.
save(
"psi_monitor.d") ;
507 A_h_monitor.
save(
"potA_monitor.d") ;
508 B_h_monitor.
save(
"potB_monitor.d") ;
509 trh_monitor.
save(
"trh_monitor.d") ;
510 beta_monitor_maxabs.
save(
"beta_monitor_maxabs.d") ;
511 hh_monitor_central.
save(
"hh_monitor_central.d") ;
512 hh_monitor_maxabs.
save(
"hh_monitor_maxabs.d") ;
513 hata_monitor_central.
save(
"hata_monitor_central.d") ;
514 hata_monitor_maxabs.
save(
"hata_monitor_maxabs.d") ;
515 test_ham_constr.
save(
"test_ham_constr.d") ;
516 test_mom_constr_r.
save(
"test_mom_constr_r.d") ;
517 test_mom_constr_t.
save(
"test_mom_constr_t.d") ;
518 test_mom_constr_p.
save(
"test_mom_constr_p.d") ;
519 check_evol.
save(
"evol_equations.d") ;
545 Scalar bc_A = -2.*A_hata_new ;
547 evolve_outgoing_BC(pdt, nz_bound,
A_hh_evol[
jtime], bc_A, xij_a, xijm1_a,
549 A_hh_new.match_tau(par_A, &par_mat_A_hh) ;
551 Scalar bc_B = -2.*B_hata_new ;
553 evolve_outgoing_BC(pdt, nz_bound,
B_hh_evol[
jtime], bc_B, xij_b, xijm1_b,
555 B_hh_new.match_tau(par_B, &par_mat_B_hh) ;
560 + 2*mu_hh_evol[
jtime-2]) / (6*pdt) ;
566 tmp = mu_hh_evol[
jtime] ;
572 evolve_outgoing_BC(pdt, nz_bound, tmp, sbcmu, xij_mu_hh, xijm1_mu_hh,
577 + 2*khi_hh_evol[
jtime-2]) / (6*pdt) ;
578 if (sbckhi.
get_etat() == ETATZERO) {
583 tmp = khi_hh_evol[
jtime] ;
589 evolve_outgoing_BC(pdt, nz_bound, tmp, sbckhi, xij_ki_hh, xijm1_ki_hh,
593 sbcmu = (18*mu_a_evol[
jtime] - 9*mu_a_evol[
jtime-1]
594 + 2*mu_a_evol[
jtime-2]) / (6*pdt) ;
600 tmp = mu_a_evol[
jtime] ;
606 evolve_outgoing_BC(pdt, nz_bound, tmp, sbcmu, xij_mu_a, xijm1_mu_a,
610 sbckhi = (18*khi_a_evol[
jtime] - 9*khi_a_evol[
jtime-1]
611 + 2*khi_a_evol[
jtime-2]) / (6*pdt) ;
612 if (sbckhi.
get_etat() == ETATZERO) {
617 tmp = khi_a_evol[
jtime] ;
623 evolve_outgoing_BC(pdt, nz_bound, tmp, sbckhi, xij_ki_a, xijm1_ki_a,
635 set_AB_hata(A_hata_new, B_hata_new) ;
638 hij_tt.
set_A_tildeB( A_hh_new, B_hh_new, &par_bc_hh, &par_mat_hh ) ;
639 for (
int i=1; i<=3; i++)
640 for (
int j=i; j<=3; j++)
641 for (
int l=nz_bound+1; l<nz; l++)
643 hata_tt.
set_A_tildeB( A_hata_new, B_hata_new, &par_bc_hata, &par_mat_hata ) ;
644 for (
int i=1; i<=3; i++)
645 for (
int j=i; j<=3; j++) {
646 for (
int l=nz_bound+1; l<nz; l++)
659 tmp = hij_tt( 1, 1 ) ;
663 tmp = hata_tt( 1, 1 ) ;
676 for (
int k = 0; k < niter_elliptic; k++) {
679 psi_new = relax * psi_new + (1.-relax) *
psi() ;
687 for (
int k = 0; k < niter_elliptic; k++) {
689 npsi_new =
solve_npsi( ener_euler, s_euler ) ;
690 npsi_new = relax * npsi_new + (1.-relax) *
npsi() ;
696 for (
int k = 0; k < niter_elliptic; k++) {
699 beta_new = relax * beta_new + (1.-relax) *
beta() ;
721 des_meridian(
hh()(2,3), 0., ray_des,
"h\\u\\gh\\gf\\d", ngraph0+13,
723 des_meridian(
hh()(3,3), 0., ray_des,
"h\\u\\gf\\gf\\d", ngraph0+14,
744 const Tbl& monitor_scalar(
const Scalar& uu,
Tbl& resu) {
759 int nr = mg.
get_nr(nzm1) ;
760 int nt = mg.
get_nt(nzm1) ;
761 int np = mg.
get_np(nzm1) ;
virtual void del_deriv() const
Deletes all the derived quantities.
Evolution_std< Sym_tensor > hh_evol
Values at successive time steps of the components .
virtual const Sym_tensor & k_dd() const
Extrinsic curvature tensor (covariant components ) at the current time step (jtime )
virtual void update(const TyT &new_value, int j, double time_j)
Sets a new value at a given time step.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Bases of the spectral expansions.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Time evolution with partial storage (*** under development ***).
int depth
Number of stored time slices.
Class intended to describe valence-2 symmetric tensors.
void save(const char *filename) const
Saves *this in a formatted file.
void mult_cost()
The basis is transformed as with a multiplication.
void set_spectral_base(const Base_val &)
Sets the spectral bases of the Valeur va
virtual const Scalar & npsi() const
Factor at the current time step (jtime ).
virtual const Scalar & nn() const
Lapse function N at the current time step (jtime )
virtual void set_psi_del_npsi(const Scalar &psi_in)
Sets the conformal factor relating the physical metric to the conformal one: .
Evolution_std< Scalar > source_B_hata_evol
The potential of the source of equation for .
void compute_X_from_momentum_constraint(const Vector &hat_S, const Sym_tensor_tt &hata_tt, int iter_max=200, double precis=1.e-12, double relax=0.8, int methode_poisson=6)
Computes the vector from the conformally-rescaled momentum , using the momentum constraint.
virtual const Sym_tensor & hata() const
Conformal representation of the traceless part of the extrinsic curvature: .
Evolution_std< Vector > beta_evol
Values at successive time steps of the shift vector .
void clean_all()
Deletes all the objects stored as modifiables, i.e.
void add_tbl_mod(Tbl &ti, int position=0)
Adds the address of a new modifiable Tbl to the list.
Cmp log(const Cmp &)
Neperian logarithm.
Transverse and traceless symmetric tensors of rank 2.
void set_A_tildeB(const Scalar &a_in, const Scalar &tb_in, Param *par_bc=0x0, Param *par_mat=0x0)
Assigns the derived members A and .
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Tbl check_hamiltonian_constraint(const Scalar *energy_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the hamiltonian constraint is verified.
void annule_hard()
Sets the Tbl to zero in a hard way.
virtual void set_etat_zero()
Sets the logical state of all components to ETATZERO (zero state).
virtual double adm_mass() const
Returns the ADM mass at (geometrical units) the current step.
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
virtual void annule(int l_min, int l_max)
Sets the Tensor to zero in several domains.
TyT time_derive(int j, int n=2) const
Computes the time derivative at time step j by means of a n-th order scheme, from the values at steps...
Evolution_std< Scalar > B_hata_evol
Potential associated with the symmetric tensor .
virtual const Vector & vec_X(int method_poisson=6) const
Vector representing the longitudinal part of .
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
void arrete(int a=0)
Setting a stop point in a code.
Evolution_std< Scalar > npsi_evol
Values at successive time steps of the factor .
int get_ndim() const
Gives the number of dimensions (ie dim.ndim)
Tensor field of valence 0 (or component of a tensorial field).
void add_double_mod(double &x, int position=0)
Adds the address of a new modifiable double to the list.
const Map & get_mp() const
Returns the mapping.
void save(const char *rootname) const
Saves in a binary file.
const Base_val & get_spectral_base() const
Returns the spectral bases of the Valeur va
virtual Scalar solve_npsi(const Scalar *ener_dens=0x0, const Scalar *trace_stress=0x0) const
Solves the elliptic equation for (maximal slicing condition + Hamiltonian constraint)
Valeur & set_spectral_va()
Returns va (read/write version)
Tbl check_momentum_constraint(const Vector *momentum_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the momentum constraints are verified.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Time evolution with full storage (*** under development ***).
Evolution_std< Scalar > source_B_hh_evol
The potential of the source of equation for .
void mult_r()
Multiplication by r everywhere; dzpuis is not changed.
void des_evol(const Evolution< double > &uu, const char *nomy, const char *title, int ngraph, const char *device, bool closeit, bool show_time, const char *nomx)
Plots the variation of some quantity against time.
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
virtual Scalar solve_psi(const Scalar *ener_dens=0x0) const
Solves the elliptic equation for the conformal factor $\Psi$ (Hamiltonian constraint).
virtual const Scalar & psi() const
Conformal factor relating the physical metric to the conformal one: .
Evolution_std< Scalar > source_A_hh_evol
The A potential of the source of equation for .
virtual void set_AB_hh(const Scalar &A_in, const Scalar &B_in)
Sets the potentials A and of the TT part of (see the documentation of Sym_tensor for details).
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Evolution_std< Scalar > source_A_hata_evol
The potential A of the source of equation for .
Evolution_std< Scalar > psi_evol
Values at successive time steps of the conformal factor relating the physical metric to the conform...
int get_nzone() const
Returns the number of domains.
void evolve(double pdt, int nb_time_steps, int niter_elliptic, double relax_elliptic, int check_mod, int save_mod, int method_poisson_vect=6, int nopause=1, const char *graph_device=0x0, bool verbose=true, const Scalar *ener_euler=0x0, const Vector *mom_euler=0x0, const Scalar *s_euler=0x0, const Sym_tensor *strain_euler=0x0)
Time evolution by resolution of Einstein equations.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Evolution_std< double > the_time
Time label of each slice.
virtual void set_npsi_del_n(const Scalar &npsi_in)
Sets the factor at the current time step (jtime ) and deletes the value of N.
void des_meridian(const Scalar &uu, double r_min, double r_max, const char *nomy, int ngraph, const char *device=0x0, bool closeit=false, bool draw_bound=true)
Draws 5 profiles of a scalar field along various radial axes in two meridional planes and .
void set_dzpuis(int)
Modifies the dzpuis flag.
Tensor field of valence 1.
Evolution_std< Scalar > A_hata_evol
Potential A associated with the symmetric tensor .
Tbl check_dynamical_equations(const Sym_tensor *strain_tensor=0x0, const Scalar *energy_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the dynamical equations are verified.
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
virtual const Scalar & B_hh() const
Returns the potential of .
void compute_sources(const Sym_tensor *strain_tensor=0x0) const
Computes the sources source_A_XXX_evol and source_B_XXX_evol , for the solution of the evolution equa...
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
const Scalar & mu(Param *par=0x0) const
Gives the field (see member p_mu ).
virtual void inc_dzpuis(int inc=1)
Increases by inc units the value of dzpuis and changes accordingly the values in the compactified ext...
Tbl & set_domain(int l)
Read/write of the value in a given domain.
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field.
virtual Vector solve_beta(int method=6) const
Solves the elliptic equation for the shift vector from (Eq.
int jtime
Time step index of the latest slice.
virtual const Scalar & trh() const
Computes the trace h, with respect to the flat metric ff , of .
void mult_x()
The basis is transformed as with a multiplication by .
void annule_hard()
Sets the Scalar to zero in a hard way.
Tbl maxabs_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maximum of the absolute value of each component of a tensor over all the domains.
virtual const Vector & beta() const
shift vector at the current time step (jtime )
Transverse symmetric tensors of rank 2.
int get_taille() const
Gives the total size (ie dim.taille)
void ylm()
Computes the coefficients of *this.
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
virtual void update(const TyT &new_value, int j, double time_j)
Sets a new value at a given time step.
Evolution_std< Scalar > B_hh_evol
The potential of .
Evolution_std< Scalar > A_hh_evol
The A potential of .
virtual const Sym_tensor & hh(Param *par_bc=0x0, Param *par_mat=0x0) const
Deviation of the conformal metric from the flat metric : .
virtual const Scalar & A_hh() const
Returns the potential A of .
Base class for coordinate mappings.
void hh_det_one(int j, Param *par_bc=0x0, Param *par_mat=0x0) const
Computes from the values of A and and using the condition , which fixes the trace of .
Evolution_std< Sym_tensor > hata_evol
Values at successive time steps of the components .
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
Vectorial bases (triads) with respect to which the tensorial components are defined.
Tbl central_value(const Tensor &aa, const char *comment=0x0, ostream &ost=cout)
Central value of each component of a tensor.
void ylm_i()
Inverse of ylm()