Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store coord_type in the output file + fix reading #217

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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