Skip to content

Commit 274ac3f

Browse files
committed
Bug fix: Cuboid.random_boundary_points
1 parent e205f82 commit 274ac3f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

deepxde/geometry/geometry_3d.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ def random_boundary_points(self, n, random="pseudo"):
3737
)
3838
if n <= 8:
3939
return x_corner[np.random.choice(8, size=n, replace=False)]
40-
n -= 8
4140

4241
pts = [x_corner]
43-
density = n / self.area
42+
density = (n - 8) / self.area
4443
rect = Rectangle(self.xmin[:-1], self.xmax[:-1])
4544
for z in [self.xmin[-1], self.xmax[-1]]:
4645
u = rect.random_points(int(np.ceil(density * rect.area)), random=random)
@@ -53,7 +52,10 @@ def random_boundary_points(self, n, random="pseudo"):
5352
for x in [self.xmin[0], self.xmax[0]]:
5453
u = rect.random_points(int(np.ceil(density * rect.area)), random=random)
5554
pts.append(np.hstack((np.full((len(u), 1), x), u)))
56-
return np.vstack(pts)
55+
pts = np.vstack(pts)
56+
if len(pts) > n:
57+
return pts[np.random.choice(len(pts), size=n, replace=False)]
58+
return pts
5759

5860
def uniform_boundary_points(self, n):
5961
h = (self.area / n) ** 0.5

0 commit comments

Comments
 (0)