Skip to content

Commit 6d970a0

Browse files
committed
[mesh motion] Gaussian RBF with compact support - spectral convergence
1 parent cbbd7ad commit 6d970a0

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/displacementSmartSimMotionSolver/pytorchApproximationModels/rbf_network.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ def __init__(self, centers, r_max, smoothness):
2828
self.a0 = nn.Parameter(torch.tensor(0.0))
2929
self.a = nn.Parameter(torch.zeros(self.dimension))
3030

31+
#def rbf(self, x):
32+
# r = torch.cdist(x, self.centers) / self.r_max
33+
# mask = (r < 1).float()
34+
# rm = (1 - r).clamp(min=0.0)
35+
36+
# phi = (1 + 6*r + (35/3)*r**2) * rm**6 # Only compute once
37+
# return phi * mask # Ensure compact support
38+
3139
def rbf(self, x):
40+
"""
41+
Compute Gaussian RBF instead of Wendland.
42+
"""
3243
r = torch.cdist(x, self.centers) / self.r_max
33-
mask = (r < 1).float()
34-
rm = (1 - r).clamp(min=0.0)
35-
36-
phi = (1 + 6*r + (35/3)*r**2) * rm**6 # Only compute once
37-
return phi * mask # Ensure compact support
44+
return torch.exp(-r**2) # Infinitely smooth Gaussian RBF
3845

3946

4047
def forward(self, x):
@@ -44,4 +51,4 @@ def forward(self, x):
4451
rbf_output = self.rbf(x)
4552
rbf_term = rbf_output @ self.weights
4653
linear_term = x @ self.a
47-
return self.a0 + rbf_term + linear_term
54+
return self.a0 + rbf_term #+ linear_term

src/displacementSmartSimMotionSolver/pytorchApproximationModels/test_rbf_network_stream_function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,5 @@ def main(num_points):
164164
if __name__ == "__main__":
165165
main(num_points=4)
166166
main(num_points=8)
167-
main(num_points=16)
167+
main(num_points=16)
168+
main(num_points=32)

0 commit comments

Comments
 (0)