Skip to content

morkev/FluidX3D-easy-run

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy to Run FluidX3D

10 billion voxel Space Shuttle simulationStar Wars X-wing simulation

Compute Features

CFD model: Lattice-Boltzmann method

  • Streaming (2/2):

    f0temp(x,t) = f0(x, t)
    fitemp(x,t) = f(t%2 ? i : (i%2 ? i+1 : i-1))(i%2 ? x : x-ei, t)   for   i ∈ [1, q-1]

  • Collision:

    ρ(x,t) = (Σi fitemp(x,t)) + 1

    u(x,t) = 1ρ(x,t) Σi ci fitemp(x,t)

    fieq-shifted(x,t) = wi ρ · ((u°ci)2(2c4) - (u°u)(2c2) + (u°ci)c2) + wi (ρ-1)

    fitemp(x, tt) = fitemp(x,t) + Ωi(fitemp(x,t), fieq-shifted(x,t), τ)

  • Streaming (1/2):

    f0(x, tt) = f0temp(x, tt)
    f(t%2 ? (i%2 ? i+1 : i-1) : i)(i%2 ? x+ei : x, tt) = fitemp(x, tt)   for   i ∈ [1, q-1]


Velocity Sets:

  • D2Q9
  • D3Q15
  • D3Q19 (default)
  • D3Q27

Collision Operators:

  • Single-relaxation-time (SRT/BGK) (default)
  • Two-relaxation-time (TRT)

Only 8 flag bits per lattice point (can be used independently / at the same time):

  • TYPE_S (stationary or moving) solid boundaries
  • TYPE_E equilibrium boundaries (inflow/outflow)
  • TYPE_T temperature boundaries
  • TYPE_F free surface (fluid)
  • TYPE_I free surface (interface)
  • TYPE_G free surface (gas)
  • TYPE_X remaining for custom use or further extensions
  • TYPE_Y remaining for custom use or further extensions

Setup

Clone this repository:

git clone https://github.com/morkev/FluidX3D-easy-run.git

Go to the stl folder, and add the .stl file (or compatible format) there.

Declare whatever file you what to simulate in void main_setup() located in setup.cpp:

void main_setup() {
	// ######################################################### define simulation box size, viscosity and volume force ############################################################################
	const uint L = 256u;
	const float Re = 1000000.0f;
	const float u = 0.1f;
	LBM lbm(L, L*3u, L/2u, units.nu_from_Re(Re, (float)L, u));
	// #############################################################################################################################################################################################
	const float size = 1.75f*(float)L;
	const float3 center = float3(lbm.center().x, 0.52f*size, lbm.center().z+0.03f*size);
	// #############################################################################################################################################################################################
	// QUICK ROTATION FOR OBJECT ALIGNMENT
	// const float3x3 rotation = float3x3(float3(1, 0, 0), radians(-0.0f))*float3x3(float3(0, 0, 1), radians(270.0f))*float3x3(float3(1, 0, 0), radians(0.0f));
	// #############################################################################################################################################################################################
	const float3x3 rotation = float3x3(float3(1, 0, 0), radians(-10.0f))*float3x3(float3(0, 0, 1), radians(90.0f))*float3x3(float3(1, 0, 0), radians(90.0f));
	lbm.voxelize_stl(get_exe_path()+"../stl/F117.stl", center, rotation, size); // replace F117.stl with your file
	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;
	lbm.run();
} /**/

Compatibility

  • Works in Windows, Linux with C++17
  • Supports importing and voxelizing triangle meshes from binary .stl files
  • Supports exporting volumetric data as binary .vtk files
  • Supports exporting rendered frames as .png/.qoi/.bmp files; time-consuming image encoding is handled in parallel on the CPU while the simulation on GPU can continue without delay

References

Contact

About

Easy to run version of FluidX3D

Resources

License

Stars

Watchers

Forks

Languages

  • C++ 70.5%
  • C 29.4%
  • Shell 0.1%