Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpredictable behaviour of warp mesh_query_point_sign_winding_number in a loop #70

Open
hsalehipour opened this issue Oct 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@hsalehipour
Copy link
Collaborator

hsalehipour commented Oct 11, 2024

  • 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 = 32 before 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!)
@hsalehipour hsalehipour changed the title Unpreditable behaviour of mesh_query_point_sign_winding_number in a loop Unpreditable behaviour of warp mesh_query_point_sign_winding_number in a loop Oct 11, 2024
@hsalehipour hsalehipour changed the title Unpreditable behaviour of warp mesh_query_point_sign_winding_number in a loop Unpredictable behaviour of warp mesh_query_point_sign_winding_number in a loop Oct 11, 2024
@hsalehipour
Copy link
Collaborator Author

hsalehipour commented Oct 11, 2024

If L99 - L194 in

query = wp.mesh_query_point_sign_winding_number(mesh_id, pos_solid_cell, max_length)
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

@hsalehipour
Copy link
Collaborator Author

hsalehipour commented Oct 11, 2024

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

@mehdiataei
Copy link
Contributor

This is not a bug. Before any IO, you must do wp.synchronize()

@mehdiataei mehdiataei reopened this Oct 11, 2024
@mehdiataei mehdiataei added the bug Something isn't working label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants