Skip to content

Commit 05797bf

Browse files
committed
add 1D reference case, and new setup
1 parent 7d71665 commit 05797bf

File tree

6 files changed

+181
-17
lines changed

6 files changed

+181
-17
lines changed

test/HD/SedovBlastWave/idefix.ini

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
[Grid]
2-
X1-grid 1 -0.5 256 u 0.5
3-
X2-grid 1 -0.5 256 u 0.5
4-
X3-grid 1 -0.5 256 u 0.5
2+
X1-grid 1 -0.5 128 u 0.5
3+
X2-grid 1 -0.5 128 u 0.5
4+
X3-grid 1 -0.5 128 u 0.5
55

66
[TimeIntegrator]
77
CFL 0.9
8-
tstop 5.0
8+
tstop 0.1
99
first_dt 1.e-6
1010
nstages 2
1111

1212
[Hydro]
1313
solver hllc
1414
gamma 1.666666666666666666
1515

16+
[Setup]
17+
Rstart 0.03
18+
1619
[Boundary]
1720
X1-beg periodic
1821
X1-end periodic
@@ -22,4 +25,4 @@ X3-beg periodic
2225
X3-end periodic
2326

2427
[Output]
25-
vtk 0.01
28+
vtk 0.1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define COMPONENTS 1
2+
#define DIMENSIONS 1
3+
4+
#define GEOMETRY SPHERICAL
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[Grid]
2+
X1-grid 1 0.001 4096 u 0.5
3+
X2-grid 1 -0.5 1 u 0.5
4+
X3-grid 1 -0.5 1 u 0.5
5+
6+
[TimeIntegrator]
7+
CFL 0.9
8+
tstop 0.1
9+
first_dt 1.e-9
10+
nstages 2
11+
12+
[Hydro]
13+
solver hllc
14+
gamma 1.666666666666666666
15+
16+
[Boundary]
17+
X1-beg outflow
18+
X1-end outflow
19+
X2-beg periodic
20+
X2-end periodic
21+
X3-beg periodic
22+
X3-end periodic
23+
24+
[Output]
25+
vtk 0.1
26+
log 1000
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "idefix.hpp"
2+
#include "setup.hpp"
3+
4+
5+
// Default constructor
6+
7+
8+
// Initialisation routine. Can be used to allocate
9+
// Arrays or variables which are used later on
10+
Setup::Setup(Input &input, Grid &grid, DataBlock &data, Output &output) {
11+
12+
}
13+
14+
// This routine initialize the flow
15+
// Note that data is on the device.
16+
// One can therefore define locally
17+
// a datahost and sync it, if needed
18+
void Setup::InitFlow(DataBlock &data) {
19+
// Create a host copy
20+
DataBlockHost d(data);
21+
22+
23+
for(int k = 0; k < d.np_tot[KDIR] ; k++) {
24+
for(int j = 0; j < d.np_tot[JDIR] ; j++) {
25+
for(int i = 0; i < d.np_tot[IDIR] ; i++) {
26+
real r = d.x[IDIR](i);
27+
28+
// Sedov Blast Wave Following Stone+2018, 3.4.4
29+
d.Vc(RHO,k,j,i) = 1.0;
30+
d.Vc(VX1,k,j,i) = 0.0;
31+
d.Vc(VX2,k,j,i) = 0.0;
32+
d.Vc(VX3,k,j,i) = 0.0;
33+
34+
d.Vc(PRS,k,j,i) = 0.01;
35+
36+
if(r<0.01) {
37+
d.Vc(PRS,k,j,i) = 1.6e5;
38+
}
39+
40+
41+
}
42+
}
43+
}
44+
45+
// Send it all, if needed
46+
d.SyncToDevice();
47+
}
48+
49+
// Analyse data to produce an output
50+
void MakeAnalysis(DataBlock & data) {
51+
52+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Thu Mar 5 11:29:41 2020
5+
6+
@author: glesur
7+
"""
8+
9+
import os
10+
import sys
11+
sys.path.append(os.getenv("IDEFIX_DIR"))
12+
from pytools.vtk_io import readVTK
13+
from pytools import sod
14+
import argparse
15+
import numpy as np
16+
import matplotlib.pyplot as plt
17+
from scipy.interpolate import interp1d
18+
19+
parser = argparse.ArgumentParser()
20+
parser.add_argument("-noplot",
21+
default=False,
22+
help="disable plotting",
23+
action="store_true")
24+
25+
26+
args, unknown=parser.parse_known_args()
27+
28+
V=readVTK('../data.0001.vtk')
29+
R=readVTK('1Dsolution/data.0001.vtk')
30+
31+
32+
33+
# Finally, let's plot solutions
34+
p = R.data['PRS'][:,0,0]
35+
x= R.r
36+
37+
[x3D, y3D, z3D]= np.meshgrid(V.x,V.y,V.z,indexing='ij')
38+
r3D=np.sqrt(x3D**2+y3D**2+z3D**2)
39+
p3D=V.data['PRS']
40+
41+
42+
solinterp=interp1d(x,p)
43+
44+
45+
if(not args.noplot):
46+
plt.figure(1)
47+
plt.plot(x,p)
48+
plt.plot(r3D.flatten(),p3D.flatten(),'+',markersize=2)
49+
plt.title('Pressure')
50+
51+
plt.ioff()
52+
plt.show()
53+
54+
error=np.mean(np.fabs(V.data['PRS'][:,0,0]-solinterp(V.x)))
55+
print("Error=%e"%error)
56+
if error<2e-3:
57+
print("SUCCESS!")
58+
sys.exit(0)
59+
else:
60+
print("FAILURE!")
61+
sys.exit(1)

test/HD/SedovBlastWave/setup.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
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
1010
Setup::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

Comments
 (0)