diff --git a/examples/mesh/bc_demo.py b/examples/mesh/bc_demo.py index 6b198fd3b..3521d7fee 100644 --- a/examples/mesh/bc_demo.py +++ b/examples/mesh/bc_demo.py @@ -1,10 +1,9 @@ # test the boundary fill routine -import numpy as np - import mesh.boundary as bnd import mesh.patch +import numpy as np def doit(): diff --git a/pyro/mesh/patch.py b/pyro/mesh/patch.py index f31dc13c2..1b5d6997b 100644 --- a/pyro/mesh/patch.py +++ b/pyro/mesh/patch.py @@ -755,6 +755,11 @@ def write_data(self, f): ggrid.attrs["ymin"] = self.grid.ymin ggrid.attrs["ymax"] = self.grid.ymax + try: + ggrid.attrs["coord_type"] = self.grid.coord_type + except AttributeError: + pass + # data gstate = f.create_group("state") diff --git a/pyro/util/io_pyro.py b/pyro/util/io_pyro.py index a75a245e5..8188b53b3 100644 --- a/pyro/util/io_pyro.py +++ b/pyro/util/io_pyro.py @@ -6,7 +6,7 @@ import h5py import pyro.mesh.boundary as bnd -from pyro.mesh.patch import CellCenterData2d, Grid2d +from pyro.mesh.patch import Cartesian2d, CellCenterData2d, SphericalPolar from pyro.particles import particles @@ -48,9 +48,19 @@ def read(filename): # read in the grid info and create our grid grid = f["grid"].attrs - myg = Grid2d(grid["nx"], grid["ny"], ng=grid["ng"], - xmin=grid["xmin"], xmax=grid["xmax"], - ymin=grid["ymin"], ymax=grid["ymax"]) + try: + coord_type = grid["coord_type"] + except KeyError: + coord_type = 0 + + if coord_type == 1: + grid_class = SphericalPolar + else: + grid_class = Cartesian2d + + myg = grid_class(grid["nx"], grid["ny"], ng=grid["ng"], + xmin=grid["xmin"], xmax=grid["xmax"], + ymin=grid["ymin"], ymax=grid["ymax"]) # sometimes problems define custom BCs -- at the moment, we # are going to assume that these always map to BC.user. We