Debian Codegraph @

School05/Friday/wave_expl.C

raw
1 /*****************************************************************************
2
3 Explicit wave-equation solver in spherical symmetry
4
5 ******************************************************************************/
6
7 #include <cmath>
8
9 // Lorene headers
10 #include "tensor.h"
11 #include "utilitaires.h"
12 #include "graphique.h"
13
14 using namespace Lorene ;
15
16 int main() {
17
18 // Construction of a multi-grid (Mg3d)
19 // -----------------------------------
20
21 const int nz = 1 ; // Only a nucleus
22 int nr;
23 cout << "Enter nr: " << endl ;
24 cin >> nr ; // Number of collocation points in r
25 int nt = 1 ; // Number of collocation points in theta
26 int np = 1 ; // Number of collocation points in phi
27 int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane
28 int symmetry_phi = SYM ; // symmetry in phi
29
30 Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, false) ;
31
32 // Construction of an affine mapping (Map_af)
33 // ------------------------------------------
34
35 double Rlim = 2. ;
36
37 // Boundaries of each domains
38 double r_limits[] = {0., Rlim} ;
39
40 Map_af map(mgrid, r_limits) ;
41 const Coord& r = map.r ;
42
43 // Setup of initial profile
44 //-------------------------
45
46 Scalar phim1(map) ;
47 // Something should be done here...
48 Scalar phi = phim1 ;
49 double dt ;
50 cout << "Enter dt: " << endl ;
51 cin >> dt ;
52 int iter = 0 ;
53 int ndes = int(Rlim / dt) / 200 + 1; //Frequency for drawings
54
55 // Definition of the "homogeneous solution
56 //-----------------------------------------
57
58 //-----------------------------------------
59 // Main loop
60 //-----------------------------------------
61 for (double tps=0.; tps<4.*Rlim; tps += dt) {
62
63 Scalar phip1(map) ;
64 //Something should be done here...
65
66
67 // Drawing
68 //--------
69 if (iter%ndes == 0)
70 des_meridian(phip1, 0., Rlim, "\\gf", 1) ;
71
72 // Preparation for next step
73 //--------------------------
74 iter++ ;
75 phim1 = phi ;
76 phi = phip1 ;
77 }
78
79 return EXIT_SUCCESS ;
80 }