44
55// Default constructor
66
7-
7+ real Rstart;
88// Initialisation routine. Can be used to allocate
99// Arrays or variables which are used later on
1010Setup::Setup (Input &input, Grid &grid, DataBlock &data, Output &output) {
11-
11+ Rstart = input. Get <real>( " Setup " , " Rstart " , 0 );
1212}
1313
1414// This routine initialize the flow
@@ -19,26 +19,44 @@ void Setup::InitFlow(DataBlock &data) {
1919 // Create a host copy
2020 DataBlockHost d (data);
2121
22+ real V = 0 ;
23+ for (int k = 0 ; k < d.np_int [KDIR] ; k++) {
24+ for (int j = 0 ; j < d.np_int [JDIR] ; j++) {
25+ for (int i = 0 ; i < d.np_int [IDIR] ; i++) {
26+ real x = d.x [IDIR](i);
27+ real y = d.x [JDIR](j);
28+ real z = d.x [KDIR](k);
29+ real r=sqrt (x*x+y*y+z*z);
30+
31+ if (r<Rstart) {
32+ V += d.dV (k,j,i);
33+ }
34+ }}}
35+
36+ #ifdef WITH_MPI
37+ MPI_Allreduce (MPI_IN_PLACE, &V, 1 , realMPI, MPI_SUM, MPI_COMM_WORLD);
38+ #endif
2239
40+ real gamma = data.hydro .GetGamma ();
2341 for (int k = 0 ; k < d.np_tot [KDIR] ; k++) {
2442 for (int j = 0 ; j < d.np_tot [JDIR] ; j++) {
2543 for (int i = 0 ; i < d.np_tot [IDIR] ; i++) {
2644 real x = d.x [IDIR](i);
2745 real y = d.x [JDIR](j);
2846 real z = d.x [KDIR](k);
2947
30- // Sedov Blast Wave Following Stone+2018, 3.4.4
31- d.Vc (RHO,k,j,i) = 1.0 ;
32- d.Vc (VX1,k,j,i) = 0.0 ;
33- d.Vc (VX2,k,j,i) = 0.0 ;
34- d.Vc (VX3,k,j,i) = 0.0 ;
48+ // Sedov Blast Wave Following Stone+2018, 3.4.4
49+ d.Vc (RHO,k,j,i) = 1.0 ;
50+ d.Vc (VX1,k,j,i) = 0.0 ;
51+ d.Vc (VX2,k,j,i) = 0.0 ;
52+ d.Vc (VX3,k,j,i) = 0.0 ;
3553
36- d.Vc (PRS,k,j,i) = 0.01 ;
54+ d.Vc (PRS,k,j,i) = 0.01 ;
3755
38- real r=sqrt (x*x+y*y+z*z);
39- if (r<0.01 ) {
40- d.Vc (PRS,k,j,i) = 1.6e5 ;
41- }
56+ real r=sqrt (x*x+y*y+z*z);
57+ if (r<Rstart ) {
58+ d.Vc (PRS,k,j,i) = (gamma- 1 )/V ;
59+ }
4260
4361
4462 }
0 commit comments