Skip to content

Commit 1594edf

Browse files
committed
AxisymmetricWall: Add refine method
Subdivides wall segments into smaller pieces.
1 parent f65207a commit 1594edf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

xbout/wall.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ def __iter__(self):
3939
zip(zip(self.Rs, self.Zs), zip(np.roll(self.Rs, -1), np.roll(self.Zs, -1)))
4040
)
4141

42+
def refine(self, factor: int):
43+
"""
44+
Split wall elements into factor elements
45+
46+
Returns a new AxisymmetricWall
47+
"""
48+
49+
# Wall is a closed loop
50+
xold = np.linspace(0, 1, len(self.Rs), endpoint=False)
51+
xnew = np.linspace(0, 1, len(self.Rs) * factor, endpoint=False)
52+
53+
Rs = np.interp(xnew, xold, self.Rs, period=1.0)
54+
Zs = np.interp(xnew, xold, self.Zs, period=1.0)
55+
56+
return AxisymmetricWall(Rs, Zs)
57+
4258
def to_polygon(self):
4359
"""
4460
Returns a 2D Numpy array [npoints, 2]

0 commit comments

Comments
 (0)