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.48k stars 281 forks source link

How do I define the axis of rotation for a geometry that is rotated 15 degrees about the y-axis? #165

Closed wjsjtu123 closed 3 months ago

wjsjtu123 commented 3 months ago

When I was simulating the effect of the six propeller rotations on the wings of the airplane, I rotated the wings with the propellers by 15 degrees along the y-axis, at which point the axis of rotation of the propellers should not have been at the original (1,0,0), but should have been (0.9659,0,0.2588), so I made a change to the code. When I voxelized all the propellers before the simulation loop, and then voxelized the propellers again in the while loop of the simulation, the propellers did not rotate in accordance with the given axis of rotation, and I didn't voxelize the wings a second time in the whie loop, so in the subsequent results, I could only see the wake generated by the rotation of the propellers, and the results are shown in the figure. file:///home/ps/weijun_simulation_data/LBM_data/DEP_15d/DEP_1/image-000017880.png The code is as follows

        lbm.voxelize_mesh_on_device(fuselage);
    lbm.voxelize_mesh_on_device(wing,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_1,TYPE_S|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_2,TYPE_S|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_3,TYPE_S|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_4,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_5,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_6,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    print_info("propeller_1_z="+to_string(units.si_x(propeller_1->get_bounding_box_size().z)));
    const uint Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); parallel_for(lbm.get_N(), [&](ulong n) { uint x=0u, y=0u, z=0u; lbm.coordinates(n, x, y, z);
        if(lbm.flags[n]!=TYPE_S) lbm.u.x[n] =  lbm_u;
        if(x==0u||x==Nx-1u||y==0u||y==Ny-1u||z==0u||z==Nz-1u) lbm.flags[n] = TYPE_E; // all non periodic
    }); // ####################################################################### run simulation, export images and data ##########################################################################
    lbm.graphics.visualization_modes = VIS_FLAG_SURFACE|VIS_Q_CRITERION;
    lbm.run(0u); // initialize simulation
#if defined(FP16S)
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP16S/"+to_string(memory)+"MB/";
#elif defined(FP16C)
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP16C/"+to_string(memory)+"MB/";
#else // FP32
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP32/"+to_string(memory)+"MB/";
#endif // FP32
    while(lbm.get_t()<=units.t(si_T)) { // main simulation loop
        lbm.voxelize_mesh_on_device(propeller_1, TYPE_S|TYPE_X, propeller_1->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f)); // revoxelize mesh on GPU
        lbm.voxelize_mesh_on_device(propeller_2, TYPE_S|TYPE_X|TYPE_X, propeller_2->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_3, TYPE_S|TYPE_X|TYPE_X|TYPE_X, propeller_3->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_4, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_4->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_5, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_5->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_6, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_6->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));

        lbm.run(lbm_dt); // run dt time steps
        propeller_1->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega)); // rotate mesh
        propeller_2->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_3->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_4->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_5->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_6->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
    }

Since I only see the wake flow from the propeller in the result, I voxelize the wing again in the while loop. The code is as follows lbm.voxelize_mesh_on_device(fuselage);

    lbm.voxelize_mesh_on_device(wing,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_1,TYPE_S|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_2,TYPE_S|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_3,TYPE_S|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_4,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_5,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    lbm.voxelize_mesh_on_device(propeller_6,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
    print_info("propeller_1_z="+to_string(units.si_x(propeller_1->get_bounding_box_size().z)));
    const uint Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); parallel_for(lbm.get_N(), [&](ulong n) { uint x=0u, y=0u, z=0u; lbm.coordinates(n, x, y, z);
        if(lbm.flags[n]!=TYPE_S) lbm.u.x[n] =  lbm_u;
        if(x==0u||x==Nx-1u||y==0u||y==Ny-1u||z==0u||z==Nz-1u) lbm.flags[n] = TYPE_E; // all non periodic
    }); // ####################################################################### run simulation, export images and data ##########################################################################
    lbm.graphics.visualization_modes = VIS_FLAG_SURFACE|VIS_Q_CRITERION;
    lbm.run(0u); // initialize simulation
#if defined(FP16S)
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP16S/"+to_string(memory)+"MB/";
#elif defined(FP16C)
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP16C/"+to_string(memory)+"MB/";
#else // FP32
    const string path = "/home/ps/weijun_simulation_data/FluidX3D-master/data/";//get_exe_path()+"FP32/"+to_string(memory)+"MB/";
#endif // FP32
    while(lbm.get_t()<=units.t(si_T)) { // main simulation loop
        lbm.voxelize_mesh_on_device(wing,TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X);
        lbm.voxelize_mesh_on_device(propeller_1, TYPE_S|TYPE_X, propeller_1->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f)); // revoxelize mesh on GPU
        lbm.voxelize_mesh_on_device(propeller_2, TYPE_S|TYPE_X|TYPE_X, propeller_2->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_3, TYPE_S|TYPE_X|TYPE_X|TYPE_X, propeller_3->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_4, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_4->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_5, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_5->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));
        lbm.voxelize_mesh_on_device(propeller_6, TYPE_S|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X|TYPE_X, propeller_6->get_center(), float3(0.0f), float3(propeller_omega*0.9659f, 0.0f, propeller_omega*0.2588f));

        lbm.run(lbm_dt); // run dt time steps
        propeller_1->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega)); // rotate mesh
        propeller_2->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_3->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_4->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_5->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
        propeller_6->rotate(float3x3(float3(0.9659f, 0.0f, 0.2588f), propeller_domega));
    }

The result shows the wake flow generated by the wing, however, for the propeller, in both the results it is found that the propeller is not rotating according to the given axis of rotation, is it because my axis of rotation is wrongly defined? How can I fix it, thanks a lot! 图片1