FOAMPilot Examples
FOAMPilot is a Python library designed to simplify the creation, configuration, and execution of OpenFOAM simulations. It provides a modular and intuitive approach to manage CFD cases, mesh generation, boundary conditions, function objects, and post-processing of results.
This section presents different examples illustrating the advantages and flexibility of FOAMPilot for automating CFD workflows and facilitating learning OpenFOAM with Python.
Objectives of the Examples
The examples aim to:
- Show how to initialize an OpenFOAM case from Python.
- Demonstrate mesh generation and modification using JSON files.
- Illustrate the definition of fluid properties and boundary conditions.
- Set up
functionObjectsto monitor physical quantities (forces, pressure, field averages, etc.). - Create and manage OpenFOAM-specific dictionaries (
topoSetDict,createPatchDict, etc.). - Run the simulation and automate post-processing.
- Provide reproducible examples for learning and prototyping.
List of Examples
This section will be updated as more tests are developed.
- Muffler: A detailed example of a car muffler, showing complex mesh generation, boundary conditions, and analysis of acoustic and fluidic results.
- SimpleCar: Example based on the official OpenFOAM tutorial SimpleCar, illustrating the simulation of airflow around a simple car with JSON-based mesh generation, boundary condition application, and aerodynamic force monitoring.
Notes
Each example comes with a standalone Python script that:
- Defines the case path (
current_path). - Initializes fluid properties (density, viscosity, pressure, temperature, etc.).
- Initializes the FOAMPilot solver and system/constant folders.
- Generates the mesh from a JSON file.
- Adds the necessary
functionObjects(field average, reference pressure, run-time control, etc.). - Manipulates OpenFOAM dictionaries for patch creation and zone definition.
- Applies boundary conditions using the modern API.
- Runs the simulation.
- Automatically post-processes results and exports CSV, JSON, PNG, and HTML files.
These examples are designed to be modular and easily adaptable to various CFD case studies.