Skip to content

Commit f95c046

Browse files
authored
Add uniform_boundary_points to dde.geometry.Hypercube (#1811)
1 parent 0cd82d4 commit f95c046

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

deepxde/geometry/geometry_nd.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,37 @@ def uniform_points(self, n, boundary=True):
8181
)
8282
return x
8383

84+
def uniform_boundary_points(self, n):
85+
points_per_face = max(1, n // (2 * self.dim))
86+
points = []
87+
for d in range(self.dim):
88+
for boundary in [self.xmin[d], self.xmax[d]]:
89+
xi = []
90+
for i in range(self.dim):
91+
if i == d:
92+
xi.append(np.array([boundary], dtype=config.real(np)))
93+
else:
94+
ni = int(np.ceil(points_per_face ** (1 / (self.dim - 1))))
95+
xi.append(
96+
np.linspace(
97+
self.xmin[i],
98+
self.xmax[i],
99+
num=ni + 1,
100+
endpoint=False,
101+
dtype=config.real(np),
102+
)[1:]
103+
)
104+
face_points = np.array(list(itertools.product(*xi)))
105+
points.append(face_points)
106+
points = np.vstack(points)
107+
if n != len(points):
108+
print(
109+
"Warning: {} points required, but {} points sampled.".format(
110+
n, len(points)
111+
)
112+
)
113+
return points
114+
84115
def random_points(self, n, random="pseudo"):
85116
x = sample(n, self.dim, random)
86117
return (self.xmax - self.xmin) * x + self.xmin

0 commit comments

Comments
 (0)