Skip to content

Commit 0bd2446

Browse files
authored
remove the isinstance check in the problem setups (#258)
we don't need to restrict the setups to CellCenterData2d -- FV2d works just as well for most. Additionally, enforcing this check is not really pythonic
1 parent 23cb4f4 commit 0bd2446

File tree

40 files changed

+0
-336
lines changed

40 files changed

+0
-336
lines changed

pyro/advection/problems/smooth.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import sys
2-
31
import numpy
42

5-
from pyro.mesh import patch
63
from pyro.util import msg
74

85
DEFAULT_INPUTS = "inputs.smooth"
@@ -16,12 +13,6 @@ def init_data(my_data, rp):
1613
if rp.get_param("driver.verbose"):
1714
msg.bold("initializing the smooth advection problem...")
1815

19-
# make sure that we are passed a valid patch object
20-
if not isinstance(my_data, patch.CellCenterData2d):
21-
print("ERROR: patch invalid in smooth.py")
22-
print(my_data.__class__)
23-
sys.exit()
24-
2516
dens = my_data.get_var("density")
2617

2718
xmin = my_data.grid.xmin

pyro/advection/problems/test.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import sys
2-
3-
from pyro.mesh import patch
4-
51
DEFAULT_INPUTS = None
62

73
PROBLEM_PARAMS = {}
@@ -11,12 +7,6 @@ def init_data(my_data, rp):
117
""" an init routine for unit testing """
128
del rp # this problem doesn't use runtime params
139

14-
# make sure that we are passed a valid patch object
15-
if not isinstance(my_data, patch.CellCenterData2d):
16-
print("ERROR: patch invalid in sedov.py")
17-
print(my_data.__class__)
18-
sys.exit()
19-
2010
# get the density, momenta, and energy as separate variables
2111
dens = my_data.get_var("density")
2212

pyro/advection/problems/tophat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
3-
from pyro.mesh import patch
41
from pyro.util import msg
52

63
DEFAULT_INPUTS = "inputs.tophat"
@@ -14,12 +11,6 @@ def init_data(myd, rp):
1411
if rp.get_param("driver.verbose"):
1512
msg.bold("initializing the tophat advection problem...")
1613

17-
# make sure that we are passed a valid patch object
18-
if not isinstance(myd, patch.CellCenterData2d):
19-
print("ERROR: patch invalid in tophat.py")
20-
print(myd.__class__)
21-
sys.exit()
22-
2314
dens = myd.get_var("density")
2415

2516
xmin = myd.grid.xmin

pyro/advection_nonuniform/problems/slotted.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22

3-
from pyro.mesh import patch
43
from pyro.util import msg
54

65
DEFAULT_INPUTS = "inputs.slotted"
@@ -15,11 +14,6 @@ def init_data(my_data, rp):
1514
if rp.get_param("driver.verbose"):
1615
msg.bold("initializing the slotted advection problem...")
1716

18-
# make sure that we are passed a valid patch object
19-
if not isinstance(my_data, patch.CellCenterData2d):
20-
print(my_data.__class__)
21-
msg.fail("ERROR: patch invalid in slotted.py")
22-
2317
offset = rp.get_param("slotted.offset")
2418
omega = rp.get_param("slotted.omega")
2519

pyro/advection_nonuniform/problems/test.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from pyro.mesh import patch
2-
from pyro.util import msg
3-
41
DEFAULT_INPUTS = None
52

63
PROBLEM_PARAMS = {}
@@ -10,11 +7,6 @@ def init_data(my_data, rp):
107
""" an init routine for unit testing """
118
del rp # this problem doesn't use runtime params
129

13-
# make sure that we are passed a valid patch object
14-
if not isinstance(my_data, patch.CellCenterData2d):
15-
print(my_data.__class__)
16-
msg.fail("ERROR: patch invalid in slotted.py")
17-
1810
# get the density, momenta, and energy as separate variables
1911
dens = my_data.get_var("density")
2012

pyro/burgers/problems/converge.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import sys
2-
31
import numpy
42

5-
from pyro.mesh import patch
63
from pyro.util import msg
74

85
DEFAULT_INPUTS = "inputs.converge.64"
@@ -14,12 +11,6 @@ def init_data(my_data, rp):
1411
if rp.get_param("driver.verbose"):
1512
msg.bold("initializing the smooth burgers convergence problem...")
1613

17-
# make sure that we are passed a valid patch object
18-
if not isinstance(my_data, patch.CellCenterData2d):
19-
print("ERROR: patch invalid in converge.py")
20-
print(my_data.__class__)
21-
sys.exit()
22-
2314
u = my_data.get_var("x-velocity")
2415
v = my_data.get_var("y-velocity")
2516

pyro/burgers/problems/test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
3-
from pyro.mesh import patch
41
from pyro.util import msg
52

63
DEFAULT_INPUTS = "inputs.test"
@@ -14,12 +11,6 @@ def init_data(myd, rp):
1411
if rp.get_param("driver.verbose"):
1512
msg.bold("initializing the burgers test problem...")
1613

17-
# make sure that we are passed a valid patch object
18-
if not isinstance(myd, patch.CellCenterData2d):
19-
print("ERROR: patch invalid in test.py")
20-
print(myd.__class__)
21-
sys.exit()
22-
2314
u = myd.get_var("x-velocity")
2415
v = myd.get_var("y-velocity")
2516

pyro/burgers/problems/tophat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
3-
from pyro.mesh import patch
41
from pyro.util import msg
52

63
DEFAULT_INPUTS = "inputs.tophat"
@@ -12,12 +9,6 @@ def init_data(myd, rp):
129
if rp.get_param("driver.verbose"):
1310
msg.bold("initializing the tophat burgers problem...")
1411

15-
# make sure that we are passed a valid patch object
16-
if not isinstance(myd, patch.CellCenterData2d):
17-
print("ERROR: patch invalid in tophat.py")
18-
print(myd.__class__)
19-
sys.exit()
20-
2112
u = myd.get_var("x-velocity")
2213
v = myd.get_var("y-velocity")
2314

pyro/compressible/problems/acoustic_pulse.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import sys
2-
31
import numpy as np
42

5-
from pyro.mesh import fv, patch
63
from pyro.util import msg
74

85
DEFAULT_INPUTS = "inputs.acoustic_pulse"
@@ -18,12 +15,6 @@ def init_data(myd, rp):
1815
if rp.get_param("driver.verbose"):
1916
msg.bold("initializing the acoustic pulse problem...")
2017

21-
# make sure that we are passed a valid patch object
22-
if not isinstance(myd, (patch.CellCenterData2d, fv.FV2d)):
23-
print("ERROR: patch invalid in acoustic_pulse.py")
24-
print(myd.__class__)
25-
sys.exit()
26-
2718
# get the density, momenta, and energy as separate variables
2819
dens = myd.get_var("density")
2920
xmom = myd.get_var("x-momentum")

pyro/compressible/problems/advect.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import sys
2-
31
import numpy as np
42

5-
from pyro.mesh import patch
63
from pyro.util import msg
74

85
DEFAULT_INPUTS = "inputs.advect.64"
@@ -16,12 +13,6 @@ def init_data(my_data, rp):
1613
if rp.get_param("driver.verbose"):
1714
msg.bold("initializing the advect problem...")
1815

19-
# make sure that we are passed a valid patch object
20-
if not isinstance(my_data, patch.CellCenterData2d):
21-
print("ERROR: patch invalid in advect.py")
22-
print(my_data.__class__)
23-
sys.exit()
24-
2516
# get the density, momenta, and energy as separate variables
2617
dens = my_data.get_var("density")
2718
xmom = my_data.get_var("x-momentum")

0 commit comments

Comments
 (0)