-
Python Module Infrastructure
- ✅
setup.pyfor building the extension - ✅
pyproject.tomlfor modern Python packaging - ✅ pybind11 integration
- ✅ Successful compilation with MSVC
- ✅
-
Argument Validation
- ✅ Validates velocity set arguments (--D2Q9, --D3Q15, --D3Q19, --D3Q27)
- ✅ Proper error handling (throws Python exceptions instead of exit())
- ✅ Error messages returned to Python caller
- ✅ No console output when used as module
-
Module Interface
import fluidx3d # Function-level API fluidx3d.validate_args(['--D3Q27']) # Class-based API validator = fluidx3d.ArgumentValidator() validator.validate_args(['--D3Q27']) validator.get_version()
# Windows (from FluidX3D-2.16 directory)
python setup.py build_ext --inplace
copy src\fluidx3d.cp314-win_amd64.pyd fluidx3d.pyd
# Test
python test_module.py============================================================
FluidX3D Python Module Test
============================================================
Version: 2.16.0-python
Test 1: Validating with no arguments...
✅ SUCCESS: Caught expected error: Must pick one of --D3Q15 --D3Q19 --D3Q27 or --D2Q9
Test 2: Validating with valid arguments (--D3Q27)...
✅ SUCCESS: Arguments validated successfully!
Test 3: Validating with multiple velocity sets...
✅ SUCCESS: Caught expected error: Can only pick one velocity set (...)
Test 4: Using ArgumentValidator class...
✅ SUCCESS: Arguments validated!
============================================================
-
Expand Argument Parsing
- Integrate full
cxxoptsargument parsing - Support all FluidX3D CLI arguments
- Create Python-friendly parameter structure
- Integrate full
-
Core Simulation Functionality
- Expose LBM class to Python
- Implement simulation initialization
- Add run() method for stepping simulation
- Support different velocity sets at runtime
-
Data Exchange
- Return velocity fields as NumPy arrays
- Return pressure fields as NumPy arrays
- Extract force/drag coefficients
- Zero-copy access where possible
-
Graphics Integration
- Optional graphics rendering
- Frame export to files
- Video generation support
-
Testing & Validation
- Compare results with standalone .exe
- Performance benchmarking
- Memory usage profiling
We began with a minimal standalone module (just argument validation) to:
- ✅ Verify pybind11 integration works
- ✅ Test build system
- ✅ Confirm error handling approach
- ✅ Establish development workflow
Rather than linking all of FluidX3D's C++ code at once (which caused 30+ linker errors), we'll:
- Add components incrementally
- Create thin wrappers for external dependencies
- Mock/stub GUI components (not needed in Python)
- Focus on compute-only functionality first
Once core functionality works:
- Create wheel distributions (.whl)
- Support Windows, Linux, macOS
- Provide pre-built binaries for common platforms
- Publish to PyPI for
pip install fluidx3d
- C++17 standard
- MSVC optimization: /O2 /fp:fast
- Link-time code generation (LTCG)
- Tested: Python 3.14.0
- Target: Python 3.11.14+
- Module naming:
fluidx3d.cp3XX-win_amd64.pyd
- pybind11 >= 2.6.0
- numpy >= 1.19.0 (for future data exchange)
- OpenCL (for computation, will add later)
- ✅ Modern Python packaging (pyproject.toml + setup.py)
- ✅ Exception handling instead of exit() calls
- ✅ Incremental development (working minimal version first)
- ✅ Test-driven (test script validates functionality)
- ✅ Cross-version support (3.11+)
- Module compiles successfully
- Module imports in Python
- Argument validation works
- Errors properly returned to Python
- No console pollution
- Run actual LBM simulation from Python
- Extract simulation results
- Match performance of standalone .exe
- Support all CLI arguments
- NumPy array integration
- Multiple simulation management
- Pythonic API design
- PyPI distribution
- FluidX3D original: https://github.com/ProjectPhysX/FluidX3D
- pybind11 docs: https://pybind11.readthedocs.io/
- Python packaging: https://packaging.python.org/
Last Updated: 2025-11-04
Status: Phase 1 Complete, Phase 2 Planning