// Lorene headers #include "metric.h" #include "cmp.h" #include "nbr_spx.h" #include "utilitaires.h" #include "graphique.h" using namespace Lorene ; int main() { // Construction of a multi-grid (Mg3d) // ----------------------------------- const int nz = 3 ; // Number of domains int nr =33 ; // Number of collocation points in r in each domain int nt = 5 ; // Number of collocation points in theta in each domain int np = 6 ; // Number of collocation points in phi in each domain int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane int symmetry_phi = NONSYM ; // no symmetry in phi int nbr[] = {nr, nr , nr}; int nbt[] = {nt, nt, nt} ; int nbp[] = {np, np, np} ; int tipe_r[] = {RARE, FIN, UNSURR} ; assert( nz == 3 ) ;// since the above arrays are described in only 3 domains int nzm1 = nz - 1 ; Mg3d mgrid(nz, nbr, tipe_r, nbt, symmetry_theta, nbp, symmetry_phi) ; // Construction of an affine mapping (Map_af) // ------------------------------------------ // Boundaries of each domains double r_limits[] = {0., 1., 2., __infinity} ; Map_af map(mgrid, r_limits) ; // Construction of flat metrics // ---------------------------- Metric_flat mets(map, map.get_bvect_spher()) ; // spherical representation Metric_flat metc(map, map.get_bvect_cart()) ; // Cartesian representation // Construction of a divergence free vector field // ---------------------------------------------- const Coord& r = map.r ; Scalar sint(map), cost(map) ; sint = map.sint ; cost = map.cost ; Scalar comp_l2 = 3*cost*cost - 1 ; comp_l2.std_spectral_base() ; Scalar num(map) ; num = 3 - r*r*r*r ; num.std_spectral_base() ; Base_val ma_base(nz) ; ma_base.set_base_r(0, R_CHEBPIM_I) ; for (int i=1; i> sd ; Scalar pot_source = source_s.potential(mets) ; cout << "Source potential: " << endl ; cout << "----------------- " << endl << endl ; pot_source.spectral_display(0x0, 1.e-13) ; cin >> sd ; Vector_divfree source_df = source_s.div_free(mets) ; cout << "Difference with the div_free part of the source : " << endl; cout << "------------------------------------------------- " << endl << endl ; Vector v_diff = source_df - source_s ; v_diff.dec_dzpuis(4) ; v_diff.spectral_display(0x0, 1.e-13) ; cout << endl ; cin >> sd ; Vector_divfree sol_df = source_df.poisson() ; Vector diff_df = sol_df - vvs1 ; cout << "Difference with analytic solution: " << endl ; cout << "---------------------------------- " << endl ; for (int i=1; i<4; i++) cout << max(abs(diff_df(i))) << endl ; cout << endl ; Vector sol = sol_df ; cout << "Divergence of the solution : " << endl ; cout << "---------------------------- " << endl ; Scalar dive = sol.divergence(mets) ; dive.dec_dzpuis(2) ; dive.spectral_display(0x0, 1.e-12) ; Scalar eta_theo = num*denom1*denom1*comp_l2 / 6 ; eta_theo.std_spectral_base() ; eta_theo.set_outer_boundary(nzm1,0) ; eta_theo.mult_r() ; Scalar eta = sol_df.eta() ; cout << "Difference in eta : " << endl ; cout << "------------------- " << endl ; cout << max(abs(eta- eta_theo)) << endl ; Scalar mu_theo(map) ; mu_theo = denom1 ; mu_theo.set_outer_boundary(nzm1,0) ; mu_theo.mult_r() ; mu_theo.mult_cost() ; Scalar mu = sol_df.mu() ; cout << "Diffrence in mu: " << endl ; cout << "------------------- " << endl ; cout << max(abs(mu - mu_theo)) << endl ; return EXIT_SUCCESS ; }