63
63
)
64
64
65
65
POLY_GRID_SIZE = 1e-12
66
- _NUM_PTS_DIM_BOX_FACE = 200
66
+ _BOX_FACE_GRID_SIZE = 1e-3
67
67
68
68
69
69
_shapely_operations = {
@@ -1722,8 +1722,14 @@ def compute_tangential_vectors(
1722
1722
rotated_corners = (rotation_matrix @ face_corners .T ).T
1723
1723
p1 , p2 , p3 , p4 = rotated_corners
1724
1724
1725
- num_s = _NUM_PTS_DIM_BOX_FACE
1726
- num_t = _NUM_PTS_DIM_BOX_FACE
1725
+ # Determine number of points along each face edge based on _BOX_FACE_GRID_SIZE
1726
+ edge1 = rotated_corners [1 ] - rotated_corners [0 ]
1727
+ edge2 = rotated_corners [2 ] - rotated_corners [0 ]
1728
+ len_s = np .linalg .norm (edge1 )
1729
+ len_t = np .linalg .norm (edge2 )
1730
+ num_s = max (1 , int (np .ceil (len_s / _BOX_FACE_GRID_SIZE )))
1731
+ num_t = max (1 , int (np .ceil (len_t / _BOX_FACE_GRID_SIZE )))
1732
+
1727
1733
s_vals = np .linspace (0 , 1 , 2 * num_s + 1 )[1 ::2 ]
1728
1734
t_vals = np .linspace (0 , 1 , 2 * num_t + 1 )[1 ::2 ]
1729
1735
S , T = np .meshgrid (s_vals , t_vals , indexing = "ij" )
@@ -1757,7 +1763,7 @@ def compute_tangential_vectors(
1757
1763
perps1 = perps1 ,
1758
1764
perps2 = perps2 ,
1759
1765
)
1760
- return surface_mesh , n_local
1766
+ return surface_mesh
1761
1767
1762
1768
1763
1769
""" Abstract subclasses """
@@ -2657,11 +2663,6 @@ def derivative_faces(
2657
2663
2658
2664
for min_max_index , _ in enumerate ((0 , - 1 )):
2659
2665
for axis in range (3 ):
2660
- if rotation_matrix is not None :
2661
- rotation_matrix = rotation_matrix
2662
- else :
2663
- rotation_matrix = None
2664
-
2665
2666
vjp_face = self .derivative_face (
2666
2667
min_max_index = min_max_index ,
2667
2668
axis_normal = axis ,
@@ -2685,7 +2686,7 @@ def derivative_face(
2685
2686
Compute the derivative (VJP) with respect to shifting a face of a rotated box,
2686
2687
using full integration over that face.
2687
2688
"""
2688
- mesh , _ = self .build_box_face_mesh (
2689
+ mesh = self .build_box_face_mesh (
2689
2690
center = np .asarray (self .center , float ),
2690
2691
size = np .asarray (self .size , float ),
2691
2692
axis_normal = axis_normal ,
@@ -3018,7 +3019,6 @@ def compute_derivatives(self, derivative_info: DerivativeInfo) -> AutogradFieldM
3018
3019
)
3019
3020
derivative_map [("geometry" , "center" )] = transformed_center_gradient
3020
3021
derivative_map [("geometry" , "size" )] = transformed_size_gradient
3021
- derivative_map [("transform" ,)] = np .zeros ((4 , 4 ))
3022
3022
return derivative_map
3023
3023
3024
3024
0 commit comments