How chfeder/turbulence_generator works
Project type and purpose
• This is a scientific turbulence-generator library and command-line tool (TurbGen) written in C++ with MPI/HDF5 support.
• It provides a core API (TurbGen.h/C++), a parallel CLI (TurbGen.cpp), demo drivers (TurbGenDemo.cpp), legacy ports in C and Fortran, a Python frontend, and integration “plugins” for hydrodynamics codes (FLASH, AREPO‐style interfaces).
File structure
• Top-level:
• Core C++ library and executables: TurbGen.h, TurbGen.cpp, TurbGenDemo.cpp, TurbGen.par, Makefile
• Legacy implementations: legacy_c/ (C), legacy_fortran/ (Fortran)
• Python frontend: python/TurbGen.py
• Plugins for FLASH: plugins/flash/{StirICsMain, StirMain, legacy_fortran} with F90 and C wrappers
• Build system:
• Root Makefile
• Sub-directory Makefiles for legacy and plugins
• Config and parameter files:
• TurbGen.par
• plugin Config subdirectories
• legacy input (.inp)
README for additional insights
• Core objective: generate time sequences of random Fourier modes via an OU process, write HDF5 output or return a single realization.
• Supported integrations: AREPO, FLASH, GADGET, PHANTOM, PLUTO.
• Python frontend also computes statistics (PDFs, power spectra).
a. Main components
• Core TurbGen Library (C++)
• Parallel CLI Application (TurbGen.exe)
• Demo CLI (TurbGenDemo)
• Legacy C/Fortran modules
• Python Frontend (python/TurbGen.py)
• Plugin Adapters for Simulation Codes (FLASH StirICsMain, StirMain)
• External Simulation Engines (FLASH, AREPO, GADGET, etc.)
• Data stores: Parameter files (.par, .inp), HDF5 output
b. Relationships and data flows
• Parameter file → CLI/Demo/Python → Core Library → HDF5 output
• Simulation Engine loads Plugin → Plugin Adapter calls Core Library (in‐process) → simulation uses turbulence field
• Python frontend may invoke CLI as subprocess or link against library via C‐API wrapper
• Legacy modules compile separately but follow the same call flow
c. Architectural patterns and design principles
• Layered modular design: Core library at center, adapters around it
• Plugin/Adapter pattern: each simulation code has a thin interface module (Fortran or C wrapper)
• Cross‐language interoperability: C++ core with C and Fortran bindings, plus Python glue
• Parallel computing: MPI in core and CLI
d. Key technologies and frameworks
• C++ (TurbGen.h/.cpp), MPI, HDF5
• Fortran 90 for legacy and plugin modules
• Python for frontend and analysis
• Make (Makefiles) as build orchestrator
• Shell scripts (misc/make_movie.sh) and PowerPoint slides (misc/TurbGen.pptx) for documentation/tools
Elements
• Clear labels on each component (e.g., “TurbGen Core Library” vs. “FLASH Plugin Adapter”)
• Core library (e.g., blue rectangle)
• Executables & frontends (green ellipse)
• Plugins/Adapters (orange hexagon)
• External simulation codes (grey rectangle)