Skip to content

Commit

Permalink
remove the isinstance check in the problem setups (#258)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zingale authored Sep 6, 2024
1 parent 23cb4f4 commit 0bd2446
Show file tree
Hide file tree
Showing 40 changed files with 0 additions and 336 deletions.
9 changes: 0 additions & 9 deletions pyro/advection/problems/smooth.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in smooth.py")
print(my_data.__class__)
sys.exit()

dens = my_data.get_var("density")

xmin = my_data.grid.xmin
Expand Down
10 changes: 0 additions & 10 deletions pyro/advection/problems/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import sys

from pyro.mesh import patch

DEFAULT_INPUTS = None

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in sedov.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")

Expand Down
9 changes: 0 additions & 9 deletions pyro/advection/problems/tophat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import sys

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
print("ERROR: patch invalid in tophat.py")
print(myd.__class__)
sys.exit()

dens = myd.get_var("density")

xmin = myd.grid.xmin
Expand Down
6 changes: 0 additions & 6 deletions pyro/advection_nonuniform/problems/slotted.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print(my_data.__class__)
msg.fail("ERROR: patch invalid in slotted.py")

offset = rp.get_param("slotted.offset")
omega = rp.get_param("slotted.omega")

Expand Down
8 changes: 0 additions & 8 deletions pyro/advection_nonuniform/problems/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = None

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print(my_data.__class__)
msg.fail("ERROR: patch invalid in slotted.py")

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")

Expand Down
9 changes: 0 additions & 9 deletions pyro/burgers/problems/converge.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in converge.py")
print(my_data.__class__)
sys.exit()

u = my_data.get_var("x-velocity")
v = my_data.get_var("y-velocity")

Expand Down
9 changes: 0 additions & 9 deletions pyro/burgers/problems/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import sys

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
print("ERROR: patch invalid in test.py")
print(myd.__class__)
sys.exit()

u = myd.get_var("x-velocity")
v = myd.get_var("y-velocity")

Expand Down
9 changes: 0 additions & 9 deletions pyro/burgers/problems/tophat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import sys

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
print("ERROR: patch invalid in tophat.py")
print(myd.__class__)
sys.exit()

u = myd.get_var("x-velocity")
v = myd.get_var("y-velocity")

Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/acoustic_pulse.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import fv, patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(myd, (patch.CellCenterData2d, fv.FV2d)):
print("ERROR: patch invalid in acoustic_pulse.py")
print(myd.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = myd.get_var("density")
xmom = myd.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/advect.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

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

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in advect.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/bubble.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.bubble"
Expand All @@ -22,12 +19,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the bubble problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in bubble.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/gresho.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.gresho"
Expand All @@ -19,12 +16,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the Gresho vortex problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("Error: patch invalid in gresho.py")
print(my_data.__class__)
sys.exit()

# get the density and velocities
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/hse.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.hse"
Expand All @@ -17,12 +14,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the HSE problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in hse.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
6 changes: 0 additions & 6 deletions pyro/compressible/problems/kh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.kh"
Expand All @@ -18,11 +17,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the Kelvin-Helmholtz problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print(my_data.__class__)
msg.fail("ERROR: patch invalid in kh.py")

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/logo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import sys

import matplotlib.pyplot as plt
import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.logo"
Expand All @@ -17,12 +14,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the logo problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in logo.py")
print(my_data.__class__)
sys.exit()

# create the logo
myg = my_data.grid

Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/quad.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.quad"
Expand Down Expand Up @@ -41,12 +38,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the quadrant problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in quad.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
8 changes: 0 additions & 8 deletions pyro/compressible/problems/ramp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import math
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.ramp"
Expand All @@ -29,12 +27,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the double Mach reflection problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in ramp.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
9 changes: 0 additions & 9 deletions pyro/compressible/problems/rt.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys

import numpy as np

from pyro.mesh import patch
from pyro.util import msg

DEFAULT_INPUTS = "inputs.rt"
Expand All @@ -20,12 +17,6 @@ def init_data(my_data, rp):
if rp.get_param("driver.verbose"):
msg.bold("initializing the rt problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in rt.py")
print(my_data.__class__)
sys.exit()

# get the density, momenta, and energy as separate variables
dens = my_data.get_var("density")
xmom = my_data.get_var("x-momentum")
Expand Down
Loading

0 comments on commit 0bd2446

Please sign in to comment.