Serial example

  • Define you problem in the Kadath system of equations.

For example, here is a non linear Schwarzschild problem definition :

// 3D :
int dim = 3 ;

// Number of points
int nbr  = 5;//13 ;
Dim_array res (dim) ;
res.set(0) = nbr ; res.set(1) = 5 ; res.set(2) = 4 ;

// Center of the coordinates
Point center (dim) ;
for (int i=1 ; i<=dim ; i++)
     center.set(i) = 0 ;

// Number of domains and boundaries :
int ndom = 4 ;
Array<double> bounds (ndom-1) ;
// Radius of the BH !
double aa = 1.323 ;
bounds.set(0) = aa ; bounds.set(1) = 1.7557*aa ; bounds.set(2) = 2.9861*aa ;

// Chebyshev or Legendre :
int type_coloc = CHEB_TYPE ;

// Sherical space :
Space_spheric space(type_coloc, center, res, bounds) ;

// Initial guess for the conformal factor :
Scalar conf (space) ;
conf.annule_hard() ;
conf.std_base() ;

// Need flat metric :
Base_tensor basis (space, SPHERICAL_BASIS) ;
Metric_flat met (space, basis) ;

// Solve the equation in space outside the nucleus
System_of_eqs syst (space, 1, ndom-1) ;

// Set the metric
met.set_system (syst, "f") ;

// Only one unknown
syst.add_var ("P", conf) ;
// One user defined constant
syst.add_cst ("a", aa) ;

// Inner BC
space.add_inner_bc (syst, "dn(P) + 0.5 / a = 0") ;
// Equation
space.add_eq (syst, "D_i D^i (P) = - D_i P * D^i P", "P", "dn(P)") ;
// Outer BC
space.add_outer_bc (syst, "P=0") ;

// Calcul de l'erreur sur le systseme (H(u)) :
Array<double> HU (syst.sec_member()) ;
int size = HU.get_size(0) ; // On recupere la taille
cout << "size: "<< size << endl;