Skip to content

Add cavity flow example using foamlib to sphinx-gallery #13

@tkoyama010

Description

@tkoyama010

Overview

Add a comprehensive cavity flow example to sphinx-gallery that demonstrates using foamlib with OpenFOAM.

OpenFOAM Installation Methods

This example will support multiple OpenFOAM installation methods:

  1. openfoam-app: Using gerlero/openfoam-app - AppImage-based OpenFOAM
  2. Ubuntu APT: OpenFOAM installed via Ubuntu package manager (apt install openfoam)

Reference Tutorial

This example will be based on the classic OpenFOAM tutorial:

  • Tutorial Path: tutorials/incompressible/icoFoam/cavity/cavity
  • Solver: icoFoam (transient solver for incompressible, laminar flow)
  • Case Description: 2D square cavity with lid-driven flow

Tasks

  • Create cavity case setup using foamlib (based on OpenFOAM cavity tutorial)
  • Implement blockMesh mesh generation (20x20 grid)
  • Run icoFoam solver (using openfoam-app or system OpenFOAM)
  • Post-process results and visualize velocity field
  • Add detailed documentation explaining each step
  • Document how to use both openfoam-app and APT-installed OpenFOAM

Example Structure

The example should include:

  1. Case Setup: Create cavity geometry and boundary conditions using foamlib
    • Square cavity: 0.1m x 0.1m
    • Moving top wall with U = 1 m/s
    • Stationary side and bottom walls
  2. Mesh Generation: Execute blockMesh
    • Uniform mesh: 20x20 cells
    • Support both openfoam-app and system OpenFOAM
  3. Solver Execution: Run icoFoam solver
    • End time: 0.5s
    • Time step: 0.005s
  4. Post-processing: Extract and visualize results
    • Velocity profiles along cavity centerlines
    • Pressure contours
    • Streamlines
  5. Validation: Compare results with OpenFOAM tutorial case

Acceptance Criteria

  • Example runs successfully in sphinx-gallery
  • Generates meaningful plots and visualizations (matplotlib)
  • Includes clear explanations of foamlib usage
  • Works with both openfoam-app and APT-installed OpenFOAM
  • Can be executed in CI/CD pipeline
  • Results match OpenFOAM cavity tutorial

Related

Parent issue: #2

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions