Skip to content

Commit fdc1e59

Browse files
authored
enforce reflect boundary condition when theta boundary ~ [0,pi] (#300)
1 parent 0af42f6 commit fdc1e59

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pyro/mesh/patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ class SphericalPolar(Grid2d):
245245
def __init__(self, nx, ny, *, ng=1,
246246
xmin=0.2, xmax=1.0, ymin=0.0, ymax=1.0):
247247

248+
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)
249+
248250
# Make sure theta is within [0, PI]
249251
assert ymin >= 0.0 and ymax <= np.pi, "y or \u03b8 should be within [0, \u03c0]."
250252

251253
# Make sure the ghost cells doesn't extend out negative x(r)
252-
assert xmin - ng*(xmax-xmin)/nx >= 0.0, \
254+
assert xmin - ng*self.dx >= 0.0, \
253255
"xmin (r-direction), must be large enough so ghost cell doesn't have negative x."
254256

255-
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)
256-
257257
self.coord_type = 1
258258

259259
# Length of the side along r-direction, dr

pyro/simulation_null.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import h5py
2+
import numpy as np
23

34
import pyro.mesh.boundary as bnd
45
import pyro.util.profile_pyro as profile
@@ -52,6 +53,19 @@ def grid_setup(rp, ng=1):
5253
ymin=ymin, ymax=ymax,
5354
ng=ng)
5455

56+
# Make sure y-boundary condition is reflect when
57+
# ymin = 0 and ymax = pi
58+
59+
if grid_type == "SphericalPolar":
60+
if ymin <= 0.05:
61+
rp.set_param("mesh.ylboundary", "reflect")
62+
msg.warning("With SphericalPolar grid," +
63+
" mesh.ylboundary auto set to reflect when ymin ~ 0")
64+
if abs(np.pi - ymax) <= 0.05:
65+
rp.set_param("mesh.yrboundary", "reflect")
66+
msg.warning("With SphericalPolar grid," +
67+
" mesh.yrboundary auto set to reflect when ymax ~ pi")
68+
5569
return my_grid
5670

5771

0 commit comments

Comments
 (0)