Skip to content
Open
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
26 changes: 25 additions & 1 deletion ppmpy/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FVGrid:
"""

def __init__(self, nx, ng, *,
xmin=0.0, xmax=1.0):
xmin=0.0, xmax=1.0, geometry="Cartesian"):

self.xmin = xmin
self.xmax = xmax
Expand All @@ -72,6 +72,30 @@ def __init__(self, nx, ng, *,
self.xr = xmin + (np.arange(nx+2*ng)-ng+1.0)*self.dx
self.x = xmin + (np.arange(nx+2*ng)-ng+0.5)*self.dx

self.geometry = geometry

# area is nodal, so area[i] is A_{i-1/2}
self.area = np.zeros(self.nq+1)

self.volume = np.zeros(self.nq)

if geometry in ["cartesian", "Cartesian"]:
self.area[:] = 1.0
self.volume[:] = 1.0

elif geometry == "spherical":
self.area[0:self.nq-2] = 4.0 * np.pi * self.xl[:]**2
self.area[self.nq-1] = 4.0 * np.pi * self.xr[-1]**2

# volume is 4/3 pi (r_r**3 - r_l**3). We factor it to reduce roundoff
self.volume[:] = 4.0 * np.pi / 3.0 * (self.xl[:]**2 +
2.0 * self.xl[:] * self.xr[:]
+ self.xr[:]**2) * self.dx

else:
raise ValueError("invalid geometry")


def scratch_array(self, nc=1):
""" return a scratch array dimensioned for our grid

Expand Down
Loading