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

I Couldn't Handle with it :( #44

Closed Djargomir closed 1 year ago

Djargomir commented 1 year ago

Hello everyone i'm a Metallurgical and Material Engineer and i wanna do study aerospace engineering as my master degree. That's why i wanna learn CFD things as much as i can and i'm interesting with FluidX3D. Today i tried some sample setups at FluidX3D and i compiled with succes but i couldn't get any render things. I Used Sample STL files (Concorde and 747). How can i get rendered images or videos? Because when compiling is done CMD screen is closing instantly.

My Setup.cpp file is this. I'm using Visual Studio 2022 and it's my first experience with this program. Thanks everyone in advance for their help.

`

#include "setup.hpp"
#include "info.hpp"
#include "lbm.hpp"
#include "graphics.hpp"

void main_setup() { // Star Wars TIE fighter
        // ######################################################### define simulation box size, viscosity and volume force ############################################################################
        const uint L = 256u;
        const float Re = 100000.0f;
        const float u = 0.125f;
        LBM lbm(L, L*2u, L, units.nu_from_Re(Re, (float)L, u));
        // #############################################################################################################################################################################################
        const float size = 0.65f*(float)L;
        const float3 center = float3(lbm.center().x, 0.6f*size, lbm.center().z);
        const float3x3 rotation = float3x3(float3(1, 0, 0), radians(90.0f));
        Mesh* mesh = read_stl(get_exe_path()+"../stl/TIE-fighter.stl", lbm.size(), center, rotation, size); // https://www.thingiverse.com/thing:2919109/files
        voxelize_mesh_hull(lbm, mesh, TYPE_S);
        const uint N=lbm.get_N(), Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); for(uint n=0u, x=0u, y=0u, z=0u; n<N; n++, lbm.coordinates(n, x, y, z)) {
            // ########################################################################### define geometry #############################################################################################
            if(lbm.flags[n]!=TYPE_S) lbm.u.y[n] = 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
        }   // #########################################################################################################################################################################################
        key_4 = true;
        Clock clock;
        lbm.run(0);
        while(lbm.get_t()<1000u) {
            lbm.graphics.set_camera_free(float3(1.0f*(float)Nx, -0.4f*(float)Ny, 0.63f*(float)Nz), -33.0f, 33.0f, 80.0f);
            lbm.graphics.write_frame_png(get_exe_path()+"export/t/");
            lbm.graphics.set_camera_free(float3(0.3f*(float)Nx, -1.5f*(float)Ny, -0.45f*(float)Nz), -83.0f, -10.0f, 40.0f);
            lbm.graphics.write_frame_png(get_exe_path()+"export/b/");
            lbm.graphics.set_camera_free(float3(0.0f*(float)Nx, 0.57f*(float)Ny, 0.7f*(float)Nz), 90.0f, 29.5f, 80.0f);
            lbm.graphics.write_frame_png(get_exe_path()+"export/f/");
            lbm.graphics.set_camera_free(float3(2.5f*(float)Nx, 0.0f*(float)Ny, 0.0f*(float)Nz), 0.0f, 0.0f, 50.0f);
            lbm.graphics.write_frame_png(get_exe_path()+"export/s/");
            while(revoxelizing.load()) sleep(0.01f); // wait for voxelizer thread to finish
            lbm.flags.write_to_device(); // lbm.flags on host is finished, write to device now
            revoxelizing = true; // indicate new voxelizer thread is starting
            thread voxelizer(revoxelize, &lbm, mesh); // start new voxelizer thread
            voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
            lbm.run(28u); // run LBM in parallel while CPU is voxelizing the next frame
        }
        write_file(get_exe_path()+"time.txt", print_time(clock.stop(1000u)));

`

ProjectPhysX commented 1 year ago

Comment out //#define BENCHMARK in src/defines.hpp, and if you're on Windows, uncomment #define WINDOWS_GRAPHICS. Then recompile, and you should see a graphicas window open.

Also check your Visual Studio settings to make the console does not close when the executable has finished, so you can read eventual error messages.

Djargomir commented 1 year ago

It works thank you so much. But there is another problem. The results are so weird what did i do wrong? Because im using directly your sample. Should i do change somethings? star wars TIE tie 2

Djargomir commented 1 year ago

resim_2022-11-26_193220564

I tried SF71H but i got this result :(

ProjectPhysX commented 1 year ago

For setups with very large Reynolds number (>~100000), uncomment #define SUBGRID in src/defines.hpp. This turns the direct numerical simulation (DNS) into a large eddy simulation (LES), which runs more stable at low grid resolutions.

Depending on your GPU VRAM capacity, your maximum grid resolutions might be much more limited. To enable about double the resolution of the default FP32 memory precision mode, you can uncomment #define FP16S (faster) or #define FP16C (more accurate) in src/defines.hpp.

I will make YouTube tutorials at tbe beginning of next year, stay tuned.

Have fun with the software!