Skip to content

Commit 5d3dfee

Browse files
finished fixing init and docs
1 parent dcae4e9 commit 5d3dfee

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

pygem/bffd.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,18 @@ class BFFD(CFFD):
5151
5252
>>> from pygem import BFFD
5353
>>> import numpy as np
54-
>>> bffd = BFFD()
54+
>>> b=np.random.rand(3)
55+
>>> bffd = BFFD([2,2,2],b)
5556
>>> bffd.read_parameters('tests/test_datasets/parameters_test_ffd_sphere.prm')
5657
>>> original_mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
57-
>>> b=bffd.linconstraint(original_mesh_points)
58-
>>> bffd.valconstraint=b
59-
>>> bffd.indices=np.arange(np.prod(bffd.n_control_points)*3).tolist()
60-
>>> bffd.M=np.eye(len(bffd.indices))
61-
>>> new_mesh_points = bffd(original_mesh_points)
62-
>>> assert np.isclose(np.linalg.norm(bffd.linconstraint(new_mesh_points)-b),np.array([0.]))
58+
>>> bffd.adjust_control_points(original_mesh_points[:-4])
59+
>>> assert np.isclose(np.linalg.norm(bffd.fun(bffd.ffd(original_mesh_points[:-4]))-b),np.array([0.]))
60+
>>> new_mesh_points = bffd.ffd(original_mesh_points)
6361
'''
64-
def __init__(self, n_control_points=None, fun=None, fixval=None, weight_matrix=None, mask=None):
65-
super().__init__(n_control_points,fun,fixval,weight_matrix,mask)
62+
def __init__(self, n_control_points=None, fixval=None, weight_matrix=None, mask=None):
63+
super().__init__(n_control_points,None,fixval,weight_matrix,mask)
6664

6765
def linfun(x):
6866
return np.mean(x.reshape(-1, 3), axis=0)
6967

70-
self.fun = linfun
71-
72-
def __call__(self, src_pts):
73-
return super().__call__(src_pts)
68+
self.fun = linfun

pygem/vffd.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ class VFFD(CFFD):
5757
>>> mesh = meshio.read('tests/test_datasets/test_sphere.stl')
5858
>>> original_mesh_points=mesh.points
5959
>>> triangles = mesh.cells_dict["triangle"]
60-
>>> vffd = VFFD(triangles,[2,2,2])
60+
>>> b=np.random.rand()
61+
>>> vffd = VFFD(triangles,[2,2,2],b)
6162
>>> vffd.read_parameters('tests/test_datasets/parameters_test_ffd_sphere.prm')
62-
>>> b=vffd.linconstraint(original_mesh_points)
63-
>>> vffd.valconstraint=np.array([b])
64-
>>> vffd.indices=np.arange(np.prod(vffd.n_control_points)*3).tolist()
65-
>>> vffd.M=np.eye(len(vffd.indices))
63+
>>> vffd.adjust_control_points(original_mesh_points)
6664
>>> new_mesh_points = vffd(original_mesh_points)
67-
>>> assert np.isclose(np.linalg.norm(vffd.linconstraint(new_mesh_points)-b),np.array([0.]))
65+
>>> assert np.isclose(np.linalg.norm(vffd.fun(new_mesh_points)-b),np.array([0.]),atol=1e-07)
66+
6867
'''
69-
def __init__(self, triangles, n_control_points=None, fun=None, fixval=None, weight_matrix=None, mask=None ):
70-
super().__init__(n_control_points,fun,fixval,weight_matrix,mask)
68+
def __init__(self, triangles, n_control_points=None, fixval=None, weight_matrix=None, mask=None ):
69+
super().__init__(n_control_points,None,fixval,weight_matrix,mask)
7170
self.triangles = triangles
7271
self.vweight = [1 / 3, 1 / 3, 1 / 3]
7372

@@ -88,5 +87,4 @@ def adjust_control_points(self, src_pts):
8887
self.weight_matrix = np.eye(np.sum(self.mask.astype(int)))
8988
self.fixval = self.fun(
9089
self.ffd(src_pts)) + self.vweight[i] * (diffvolume)
91-
super().adjust_control_points(src_pts)
92-
90+
super().adjust_control_points(src_pts)

0 commit comments

Comments
 (0)