FluidX3D Documentation

repository·master·Indexed 26 days ago

https://github.com/projectphysx/fluidx3d

A high-performance Lattice Boltzmann Computational Fluid Dynamics (CFD) software utilizing OpenCL for execution on CPUs and GPUs. It features memory optimizations like Esoteric-Pull and FP16 compression to reduce VRAM footprint, supports cross-vendor multi-GPU pooling via domain decomposition, and includes integrated real-time rendering for volumetric data. The software supports various velocity sets (D2Q9, D3Q15, D3Q19, D3Q27), collision operators (SRT/BGK, TRT), and advanced models for thermal LBM, turbulence, and free surfaces.

Tokens
8.1K
Snippets
4
Records
61
Agent score
89%

What's inside FluidX3D

  1. Overview of FluidX3D Visualization and Rendering

    master

    FluidX3D solves the problem of massive volumetric data storage by allowing users to render raw simulation data directly in VRAM. This approach avoids exporting massive files (which can reach hundreds of TeraBytes for video) to hard disks.

    Key features include:

    • Real-time Rendering: Supports both rasterization and raytracing interactively.
    • Hardware Agnostic: Uses OpenCL, meaning it works on all GPUs (Nvidia, AMD, Intel) and even CPUs (with Intel CPU Runtime for OpenCL), including those without dedicated raytracing cores (e.g., A100, MI200).
    • ASCII Rendering Mode: Allows interactive visualization in a terminal (via SSH or WSL) when no monitor is available.
    • Multi-GPU Parallelization: Uses seamless domain decomposition rasterization to parallelize rendering across multiple GPUs via PCIe, without requiring SLI, NVLink, or MPI.
    • High Resolution: When interactive graphics are disabled, image resolution can scale up to the limits of VRAM (4K, 8K, 16K, and beyond).
  2. Extend FluidX3D with Advanced Models

    master

    FluidX3D supports several advanced physical models and extensions:

    • Boundary Types: Stationary/moving mid-grid bounce-back, equilibrium (non-reflective inflow/outflow), and temperature boundaries.
    • Forcing: Global force per volume (Guo forcing) and local force per volume (force fields).
    • Free Surface LBM (FSLBM): Includes Volume-of-Fluid (VoF) models and fully analytic PLIC for efficient curvature calculation.
    • Thermal LBM: Simulates thermal convection using a D3Q7 subgrid for thermal DDFs.
    • Turbulence Modeling: Smagorinsky-Lilly subgrid turbulence LES model for high Reynolds number stability.
    • Particle Interaction: Particles with immersed-boundary method (passive or 2-way-coupled).
  3. Understand the FluidX3D CFD Model (LBM)

    master

    FluidX3D uses the Lattice Boltzmann Method (LBM) for Computational Fluid Dynamics (CFD). The model includes:

    • Velocity Sets: Supports D2Q9, D3Q15, D3Q19 (default), and D3Q27.
    • Collision Operators: Supports Single-Relaxation-Time (SRT/BGK) (default) and Two-Relaxation-Time (TRT).
    • Optimizations: Uses DDF-shifting and algebraic optimizations to minimize round-off errors.
    • Core Operations: Includes streaming (part 1/2 and 2/2) and collision steps.
  4. Enable the SUBGRID extension for high Reynolds number stability

    master

    For simulations with very large Reynolds numbers ($Re > 100,000$), the LBM solver can become unstable due to small, fast-rotating vortices.

    The SUBGRID extension implements the Smagorinsky-Lilly model, which increases effective viscosity in areas of high shear rate to maintain stability. This extension has no additional performance cost.

  5. Use the PARTICLES extension for tracers or coupled particles

    master

    The PARTICLES extension allows adding particles to the grid-based simulation.

    Passive Tracers

    Enable PARTICLES and pass the particle count to the LBM constructor. You must then manually initialize particle positions in a loop.

    2-way-coupled Particles

    To allow particles to interact with the fluid (e.g., floating or sedimentation), you must also enable VOLUME_FORCE and FORCE_FIELD extensions, and provide a particle density (not equal to 1) in the LBM constructor.

  6. Enable the SURFACE extension for free water surfaces

    master

    To simulate free water surfaces, enable the SURFACE extension. This adds three flags to each cell: TYPE_F (fluid), TYPE_I (interface), and TYPE_G (gas).

    • Fluid cells: Use TYPE_F.
    • Interface cells: Account for surface tension if sigma > 0 in the LBM constructor. The interface is 1 cell thick.
    • Gas cells: Treated as vacuum.

    By default, all cells are initialized as TYPE_G. You must manually set fluid cells to TYPE_F during initialization. The interface layer is automatically handled during lbm.run(0u).

    Each cell also has a fill level lbm.phi[n]: 1 for fluid, ]0,1[ for interface, and 0 for gas. If not set manually, it defaults to 1 (fluid), 0.5 (interface), and 0 (gas).

  7. Compile FluidX3D on Windows

    master

    FluidX3D must be compiled from source using Visual Studio.

    1. Prerequisites: Install Visual Studio Community with the following workloads/components:
      • Desktop development with C++
      • MSVC v142
      • Windows 10 SDK
    2. Build: Open FluidX3D.sln in Visual Studio and click the Local Windows Debugger button.
    3. Select GPU: To run on a specific device, use the command line in the FluidX3D folder:
      • Single GPU: bin\FluidX3D.exe 0
      • Multiple GPUs: bin\FluidX3D.exe 0 1 3 6
    bin\FluidX3D.exe 0
  8. Enable the TEMPERATURE extension for thermal convection

    master

    The TEMPERATURE extension allows modeling thermal convection flows and automatically enables the VOLUME_FORCE extension.

    In the LBM constructor, you must provide the volume force (fx, fy, fz), the thermal diffusion coefficient alpha, and the thermal expansion coefficient beta (all in LBM units). The surface tension coefficient sigma must be passed as 0.0f and remains unused in this mode.

    Each cell has a temperature lbm.T[n] (default is 1 in LBM units). To set temperature boundary conditions, use the TYPE_T flag and assign a temperature value.

  9. Set initial and boundary conditions

    master

    By default, cells have $\rho=1, u=0, \text{flags}=0$. To define custom initial or boundary conditions, iterate over the grid using a parallel_for loop and assign values to individual cells using their linearized index n.

    Boundary Types:

    • Periodic: Default behavior for any cell where no boundary type is set.
    • Solid (TYPE_S): Non-moving, no-slip mid-grid bounce-back boundaries. Requires no extensions.
    • Equilibrium (TYPE_E): Inflow/outflow boundaries that enforce specific density/velocity. Requires EQUILIBRIUM_BOUNDARIES extension.
    • Moving Solid (TYPE_S with velocity): Moving no-slip boundaries. Requires MOVING_BOUNDARIES extension.
    • Volume Force: Drive flow via pressure gradient. Requires VOLUME_FORCE extension and setting fx, fy, fz in the LBM constructor.