Skip to content

Commit 19b904f

Browse files
committed
added spherical setup
1 parent e70b0af commit 19b904f

File tree

3 files changed

+71
-9
lines changed

3 files changed

+71
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define COMPONENTS 3
2+
#define DIMENSIONS 3
3+
4+
#define GEOMETRY SPHERICAL
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[Grid]
2+
X1-grid 1 0.5 32 u 1.5
3+
X2-grid 1 0.0 32 u 1.0
4+
X3-grid 1 0.0 256 u 6.283185307179586
5+
6+
[TimeIntegrator]
7+
CFL 0.9
8+
tstop 0.1
9+
first_dt 1.e-6
10+
nstages 2
11+
12+
[Hydro]
13+
solver hll
14+
gamma 1.666666666666666666
15+
16+
[Setup]
17+
Rstart 0.03
18+
19+
[Boundary]
20+
X1-beg outflow
21+
X1-end outflow
22+
X2-beg axis
23+
X2-end outflow
24+
X3-beg periodic
25+
X3-end periodic
26+
27+
[Output]
28+
vtk 0.01

test/HD/SedovBlastWave/setup.cpp

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,31 @@ void Setup::InitFlow(DataBlock &data) {
2020
DataBlockHost d(data);
2121

2222
real V = 0;
23+
#if GEOMETRY == SPHERICAL
24+
const real x0 = 0.1;
25+
const real y0 = 0.0;
26+
const real z0 = 1.0;
27+
#endif
2328
for(int k = 0; k < d.np_int[KDIR] ; k++) {
2429
for(int j = 0; j < d.np_int[JDIR] ; j++) {
2530
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 GEOMETRY == CARTESIAN
32+
real x = d.x[IDIR](i);
33+
real y = d.x[JDIR](j);
34+
real z = d.x[KDIR](k);
35+
real r=sqrt(x*x+y*y+z*z);
36+
37+
#elif GEOMETRY == SPHERICAL
38+
real r = d.x[IDIR](i);
39+
real th = d.x[JDIR](j);
40+
real phi = d.x[KDIR](k);
41+
42+
real x = r*sin(th)*cos(phi) - x0;
43+
real y = r*sin(th)*sin(phi) - y0;
44+
real z = r*cos(th) - z0;
45+
46+
r=sqrt(x*x+y*y+z*z);
47+
#endif
3148
if(r<Rstart) {
3249
V += d.dV(k,j,i);
3350
}
@@ -41,9 +58,23 @@ void Setup::InitFlow(DataBlock &data) {
4158
for(int k = 0; k < d.np_tot[KDIR] ; k++) {
4259
for(int j = 0; j < d.np_tot[JDIR] ; j++) {
4360
for(int i = 0; i < d.np_tot[IDIR] ; i++) {
44-
real x = d.x[IDIR](i);
45-
real y = d.x[JDIR](j);
46-
real z = d.x[KDIR](k);
61+
#if GEOMETRY == CARTESIAN
62+
real x = d.x[IDIR](i);
63+
real y = d.x[JDIR](j);
64+
real z = d.x[KDIR](k);
65+
real r=sqrt(x*x+y*y+z*z);
66+
67+
#elif GEOMETRY == SPHERICAL
68+
real r = d.x[IDIR](i);
69+
real th = d.x[JDIR](j);
70+
real phi = d.x[KDIR](k);
71+
72+
real x = r*sin(th)*cos(phi) - x0;
73+
real y = r*sin(th)*sin(phi) - y0;
74+
real z = r*cos(th) - z0;
75+
76+
r=sqrt(x*x+y*y+z*z);
77+
#endif
4778

4879
// Sedov Blast Wave Following Stone+2018, 3.4.4
4980
d.Vc(RHO,k,j,i) = 1.0;
@@ -53,7 +84,6 @@ void Setup::InitFlow(DataBlock &data) {
5384

5485
d.Vc(PRS,k,j,i) = 0.01;
5586

56-
real r=sqrt(x*x+y*y+z*z);
5787
if(r<Rstart) {
5888
d.Vc(PRS,k,j,i) = (gamma-1)/V;
5989
}

0 commit comments

Comments
 (0)