The Bubbles project provides a sophisticated toolset for the analysis, validation, and maintenance of OpenFOAM simulation environments. It is designed to address the inherent complexities of the OpenFOAM dictionary syntax and the structural dependencies across its distributed configuration files.
The system is constructed upon a Single Source of Truth (SSoT) architecture. Rather than treating individual dictionaries as isolated text entities, Bubbles internalizes the entire case state into a hierarchical Abstract Syntax Tree (AST). This allows for rigorous cross-validation between disparate components, such as mesh definitions, boundary conditions, and numerical schemes.
- Lexical Analyzer: A hand-written lexer capable of discerning the nuanced tokens of the OpenFOAM dialect, including nested blocks, physical dimensions, macro expansions, and C-style comments.
- Recursive-Descent Parser: A non-generative parser that transforms raw dictionary strings into a validated
FoamDictstructure, preserving the semantic hierarchy of the original source. - Case Manager: A high-level orchestrator that maintains the case state in memory, enabling real-time consistency checks between the
system/,constant/, and0/directories. - Terminal Interface: A modern user interface built on the Bubble Tea framework, providing a structured, tabular view of configuration keys without necessitating directory traversal.
The implementation follows the principle of "Perfect Round-trip Preservation." A primary objective is to ensure that the process of parsing and subsequent writing does not degrade the original file's integrity. To achieve this, the AST is designed to manage "trivia"—the whitespace and comments that provide essential context for human operators.
To support the diverse variations between ESI-OpenFOAM and the Foundation releases, Bubbles utilizes an extensible schema layer. These schemas define the mandatory keywords and valid parameter ranges for specific solvers. By decoupling the logic from the data, the tool remains compatible with both legacy and modern versions of the OpenFOAM environment.
The project is implemented in Go. To compile and run the initial interface, execute the following commands within the repository root:
go mod tidy
go run main.go- Data Model: Hierarchical AST with support for scalars, blocks, lists, and dimension sets.
- Validation: Cross-file patch verification and physical dimension consistency checks.
- Interface: Table-driven terminal UI with focused navigation and key-value previews.
Bubbles is an ongoing effort to bring modern software engineering practices to the domain of computational fluid dynamics.