XLB
XLB copied to clipboard
Unpredictable behaviour of warp mesh_query_point_sign_winding_number in a loop
- Pull the latest code in major_refactoring branch (e.g after this PR )
- Put a break point in L187 of wind tunnel example here
- Run in debug mode and see the computed "c_d" (the value should be virtually zero at iteration 0, it is not!).
- delete cache
- Now add this line
wp.config.max_unroll = 32before xlb_init in the Wind tunnel example and run again in debug mode up to the same breakpoint and see the value of "c_d" (it is zero this time!)
If L99 - L194 in https://github.com/Autodesk/XLB/blob/38431881b62c69cdf04b546107e8aaa4fcf7c7cb/xlb/operator/boundary_masker/mesh_distance_boundary_masker.py#L100 are replaced with the following (effectively making mesh_distance_masker similar to mesh_masker), then "c_d = 0.0" is obtained without increasing max_unroll:
# evaluate if point is inside mesh
query = wp.mesh_query_point_sign_winding_number(mesh_id, pos_solid_cell, max_length)
if query.result and query.sign <= 0: # TODO: fix this
# Set bc_mask of solid to a large number to enable skipping LBM operations
bc_mask[0, index[0], index[1], index[2]] = wp.uint8(255)
# Find neighboring fluid cells along each lattice direction and the their fractional distance to the mesh
for l in range(_q):
# Get the index of the streaming direction
push_index = wp.vec3i()
for d in range(self.velocity_set.d):
push_index[d] = index[d] + _c[d, l]
shape = wp.vec3i(missing_mask.shape[1], missing_mask.shape[2], missing_mask.shape[3])
if check_index_bounds(push_index, shape):
# Set the boundary id and missing_mask
bc_mask[0, push_index[0], push_index[1], push_index[2]] = wp.uint8(id_number)
missing_mask[l, push_index[0], push_index[1], push_index[2]] = True
Even when "c_d ~ 0" is obtained, there is some weird randomness in its value everytime it is run. eg. 0.00079 vs 0.00033
This is not a bug. Before any IO, you must do wp.synchronize()