Skip to content

Commit

Permalink
store coord_type in the output file + fix reading (#217)
Browse files Browse the repository at this point in the history
this allows us to plot the output again
  • Loading branch information
zingale authored Aug 30, 2024
1 parent bc93acc commit 8f935b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 1 addition & 2 deletions examples/mesh/bc_demo.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
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 AttributeError:
pass

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

Expand Down
18 changes: 14 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 Cartesian2d, CellCenterData2d, SphericalPolar
from pyro.particles import particles


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

0 comments on commit 8f935b7

Please sign in to comment.