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, t+Δt) = fitemp(x,t) + Ωi(fitemp(x,t), fieq-shifted(x,t), τ) - Streaming (1/2):
f0(x, t+Δt) = f0temp(x, t+Δt)
f(t%2 ? (i%2 ? i+1 : i-1) : i)(i%2 ? x+ei : x, t+Δt) = fitemp(x, t+Δt) for i ∈ [1, q-1]
- D2Q9
- D3Q15
- D3Q19 (default)
- D3Q27
- Single-relaxation-time (SRT/BGK) (default)
- Two-relaxation-time (TRT)
TYPE_S
(stationary or moving) solid boundariesTYPE_E
equilibrium boundaries (inflow/outflow)TYPE_T
temperature boundariesTYPE_F
free surface (fluid)TYPE_I
free surface (interface)TYPE_G
free surface (gas)TYPE_X
remaining for custom use or further extensionsTYPE_Y
remaining for custom use or further extensions
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();
} /**/
- 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
- Lehmann, M.: Esoteric Pull and Esoteric Push: Two Simple In-Place Streaming Schemes for the Lattice Boltzmann Method on GPUs. Computation, 10, 92, (2022)
- Lehmann, M., Krause, M., Amati, G., Sega, M., Harting, J. and Gekle, S.: Accuracy and performance of the lattice Boltzmann method with 64-bit, 32-bit, and customized 16-bit number formats. Phys. Rev. E 106, 015308, (2022)
- Lehmann, M.: Combined scientific CFD simulation and interactive raytracing with OpenCL. IWOCL'22: International Workshop on OpenCL, 3, 1-2, (2022)
- Lehmann, M., Oehlschlägel, L.M., Häusl, F., Held, A. and Gekle, S.: Ejection of marine microplastics by raindrops: a computational and experimental study. Micropl.&Nanopl. 1, 18, (2021)
- Lehmann, M.: High Performance Free Surface LBM on GPUs. Master's thesis, (2019)
- Lehmann, M. and Gekle, S.: Analytic Solution to the Piecewise Linear Interface Construction Problem and Its Application in Curvature Calculation for Volume-of-Fluid Simulation Codes. Computation, 10, 21, (2022)
- This is a fork of FluidX3D, developed by Dr. Moritz Lehmann [email protected].
- This is a ready to run version for those that don't have a heavy coding background, modified by Kevin Mora [email protected].