ProjectPhysX / FluidX3D

The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs via OpenCL. Free for non-commercial use.
https://youtube.com/@ProjectPhysX
Other
3.81k stars 301 forks source link

after Mesh rotation voxelize_mesh_on_device() overrites Flags on a "Wall" if Mesh touches the "Wall" #56

Closed skoz90 closed 1 year ago

skoz90 commented 1 year ago

I am modelling a Car with rotating Tires. The ground z = 0 has the Flags = TYPE_S with set velocity of u. The Carbody and the Tires are setup with the the Flag (TYPE_S|TYPE_X) I need the TYPE_X Flag for the Force readout.

For the Rotations of the Tires I use a similiar procedure as the Demo of the Rotating Fan.

        meshTireFR->rotate(float3x3(idk, angular_u*4.0f)); // rotate mesh
        lbm.voxelize_mesh_on_device(meshTireFR, TYPE_S | TYPE_X, centerTireFR, float3(0.0f), RotationTire);
        lbm.run(1u);

I noticed that if the Tire touches the Ground all Voxels inside the Projection surface of the tire on the Ground are reset with the Flags of the Tire.

This is a picture before the simulation was started. You can see that one of Tires touches the Ground. Bild1

After the Rotations of the Tires all the Ground Areas below the Tires have a Purple Rim. Indicating that something off. Bild2

i think thats happening because of the new revoxlizing algorithmen.

ProjectPhysX commented 1 year ago

Short solution: In your case it looks like the wheels are rotational symmetric, so no re-voxelization is needed after initialization. Then you can simply move the wheel voxelization calls before the loop where you set the ground plane. So first voxelize wheels, then set ground plane, then start the simulation.


For cases where the wheels are not rotational symmetric and need to be periodically revoxelized: The new revoxelization modifies all flags in the bounding box of the mesh. If the wheel bounding box overlaps with the ground boundary plane, the boundary flags in this location are also overwritten/cleared. Only the flag type handed over to the voxelization call is affected, all other flag bits remain unchanged.

In your case, you revoxelize the TYPE_S flag for the wheel, and the ground also is TYPE_S. I've built-in a failsafe that, when there is a translational/rotational velocity present for revoxelized cells, other cells in the bounding box with the same flag but 0 velocity are ignored. If the ground velocity was set to 0, the problem would not arise. But since you have a moving ground plane too, there is no way for the algorithm to differentiate between clearing wheel and ground voxels in the bounding box.

There is 2 possible solutions:

  1. Carefully move the wheel up such that the ground plane is just outside its bounding-box.
  2. After re-voxelization, read flags from device, overwrite the ground plane flags manually, and write back to device. This is potentially slower.