Skip to content

Commit

Permalink
store coord_type in the output file + fix reading
Browse files Browse the repository at this point in the history
this allows us to plot the output again
  • Loading branch information
zingale committed Aug 30, 2024
1 parent 7a1562f commit 3e2ec4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pyro/mesh/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 KeyError:
pass

# data
gstate = f.create_group("state")

Expand Down
13 changes: 9 additions & 4 deletions pyro/util/io_pyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import h5py

import pyro.mesh.boundary as bnd
from pyro.mesh.patch import CellCenterData2d, Grid2d
from pyro.mesh.patch import CellCenterData2d, Cartesian2d, SphericalPolar
from pyro.particles import particles


Expand Down Expand Up @@ -48,9 +48,14 @@ 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"])
if grid["coord_type"] == 0:
grid_class = Cartesian2d
elif grid["coord_type"] == 1:
grid_class = SphericalPolar

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
Expand Down

0 comments on commit 3e2ec4f

Please sign in to comment.