/***************************************************************************** Implicit wave-equation solver in #D with Sommerfeld boundary conditions ******************************************************************************/ #include // Lorene headers #include "metric.h" #include "proto.h" #include "graphique.h" #include "diff.h" using namespace Lorene ; int main() { // Construction of a multi-grid (Mg3d) // ----------------------------------- const int nz = 1 ; // Only a nucleus int nr; cout << "Enter nr: " << endl ; cin >> nr ; // Number of collocation points in r int nt = 5 ; // Number of collocation points in theta int np = 6 ; // Number of collocation points in phi int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane int symmetry_phi = SYM ; // symmetry in phi Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, false) ; // Construction of an affine mapping (Map_af) // ------------------------------------------ double Rlim = 2. ; // Boundaries of each domains double r_limits[] = {0., Rlim} ; Map_af map(mgrid, r_limits) ; double alpha = map.get_alpha()[0] ; // Coordinate fields const Coord& r = map.r ; const Coord& x = map.x ; const Coord& y = map.y ; // Flat metric in spherical components //------------------------------------ const Metric_flat& mets = map.flat_met_spher() ; // Initial data //------------- double sigma = 4; Scalar phim1(map) ; phim1 = x*y*(exp(-sigma*r*r) - exp(-sigma*Rlim*Rlim)) ; phim1.std_spectral_base() ; Scalar phi = phim1 ; // Time-step & boundary conditions //-------------------------------- double dt ; cout << "Enter dt: " << endl ; cin >> dt ; int iter = 0 ; int ndes = int(Rlim / dt) / 200 + 1; double a_bound = 3./(2.*dt) + 1./Rlim ; double b_bound = 1. ; double c_bound = 0. ; // Some initializations //--------------------- int l_q, m_q, base_r ; double emax = -1.e33 ; double emin = 1.e33 ; phi.set_spectral_va().ylm() ; const Base_val& base = phi.get_spectral_base() ; //---------------------------- // Main loop //---------------------------- for (double tps=0.; tps<3.*Rlim; tps += dt) { // Crank-Nicholson 2nd-order scheme //--------------------------------- Scalar source = 2*phi - phim1 + 0.5*dt*dt*phim1.laplacian(0) ; source.set_spectral_va().ylm() ; phi.set_spectral_va().ylm() ; phim1.set_spectral_va().ylm() ; Mtbl_cf resu(mgrid, base) ; resu.annule_hard() ; //Initialized to zero // Loop on theta, phi //------------------- for (int k=0; k 1)&&(base_r==R_CHEBP)) { int pari = 1 ; for (int col=0; col 1)&&(base_r==R_CHEBI)) { int pari = 1 ; for (int col=0; col emax) ? ener : emax ; emin = (ener < emin) ? ener : emin ; cout << "Energy inside the grid: " << ener << endl ; // Drawing //-------- if (iter%ndes == 0) { des_meridian(phip1, 0., Rlim, "\\gf", 1) ; } // Preparation for next step //-------------------------- iter++ ; phim1 = phi ; phi = phip1 ; } cout << "Emin, Emax: " << emin << ", " << emax << endl ; cout << "Difference: " << (emax - emin) / emax << endl ; return EXIT_SUCCESS ; }