← Back to list

A DevOps Engineer’s Guide to Computational Fluid Dynamics

Building production-ready CFD simulation pipelines from scratch

Uzair Ahmad · 2025-09-15 07:30 · 0 claps · 5.4 min read
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud

A DevOps Engineer’s Guide to Computational Fluid Dynamics

Building production-ready CFD simulation pipelines from scratch

📁 Complete source code: GitHub Repository

This tutorial

Read on if you are interested in automating scientific computing workloads and learning more about:

  • Container orchestration with Docker
  • Cross-platform compatibility using WSL
  • Automation scripting with Bash and Python
  • Modern development workflows with VS Code
  • Development environment standardization with Github

Key DevOps skills you will learn

This tutorial imparts several critical DevOps competencies:

🐳 Containerization

  • Multi-stage Dockerfiles
  • Volume mounting for data persistence
  • Container lifecycle management

🔧 Automation Scripting

  • Bash scripting with error handling
  • Parameterized simulation workflows
  • Automated result processing

💻 Development Environment

  • VS Code integration with containers
  • Cross-platform development (Windows/WSL/Linux)
  • Consistent tooling across environments

📊 Monitoring & Validation

  • Automated result validation
  • Performance metrics collection
  • Structured logging and reporting

Prerequisites

Before we begin, ensure you have:

  • Windows 10/11 with WSL2 enabled
  • Docker Desktop installed and running
  • VS Code with Remote-WSL extension
  • Basic understanding of Linux commands

Architecture Overview

Our Beginner Level setup creates a foundation for scalable CFD simulations. The dev environment is going to use WSL2 — Ubuntu image, Docker desktop and OpenFoam. The simulation will run in OpenFoam container but we will orchestrate the show from Ubuntu.

Dev environment & Environment

Dev environment & Environment

Step 1: Setting Up WSL2 Ubuntu Environment

Install Docker Desktop

from here.

Install WSL2 Ubuntu

Open PowerShell

Launching Windows PowerShell

Launching Windows PowerShell

and run:

wsl --install -d Ubuntu-22.04

After installation, launch Ubuntu and create your user account.

wsl -d Ubuntu-22.04

Ubuntu terminal

Ubuntu terminal

Install essential dev tools .

# Update system packages
sudo apt update && sudo apt upgrade -y
# Install essential development tools
sudo apt install -y curl wget git vim tree htop
# Verify Docker is accessible from WSL
docker --version

WSL — Docker Desktop Integration

WSL2 — Ubuntu 22.04 — Docker Desktop intgration

WSL2 — Ubuntu 22.04 — Docker Desktop intgration

Step 2: OpenFOAM Docker Image Strategy

Understanding OpenFOAM Docker Images

OpenFOAM is a complex CFD toolkit. Rather than installing it directly, we’ll use the official Docker image for consistency and portability.

Create our project structure:

# Create project directory
mkdir ~/devops-cfd-beginner
cd ~/devops-cfd-beginner
# Create directory structure
proj_name="CFD-OpenFoam"
# Make directories
mkdir -p $proj_name/{containers/openfoam,scripts,simulations/cavity-flow/{0,constant,system}}
# Make files
touch $proj_name/containers/openfoam/Dockerfile \
      $proj_name/scripts/{generate-plots.py,generate-report.py,run-blockMesh.sh,run-parametric-study.sh} \
      $proj_name/simulations/cavity-flow/0/{U,p} \
      $proj_name/simulations/cavity-flow/constant/{transportProperties,turbulenceProperties} \
      $proj_name/simulations/cavity-flow/system/{blockMeshDict,controlDict,fvSchemes,fvSolution}
x2@DESKTOP-CVLQANC:~/devops/CFD-OpenFoam$ tree
.
├── containers
│   └── openfoam
│       └── Dockerfile
├── scripts
│   ├── generate-plots.py
│   ├── generate-report.py
│   ├── run-blockMesh.sh
│   └── run-parametric-study.sh
└── simulations
    └── cavity-flow
        ├── 0
        │   ├── U
        │   └── p
        ├── constant
        │   ├── transportProperties
        │   └── turbulenceProperties
        └── system
            ├── blockMeshDict
            ├── controlDict
            ├── fvSchemes
            └── fvSolution

Custom Dockerfile for Development

Create ~/DevOps/CFD-OpenFoam/containers/openfoam/Dockerfile:

# computational fluid dynamics (CFD) simulation
# Stage 1: Base OpenFOAM + Python
FROM openfoam/openfoam9-paraview56 AS base

# Set environment variables
ENV REYNOLDS_NUMBER=100 \
    MESH_RESOLUTION=20 \
    SIMULATION_TIME=1000

WORKDIR /opt/CFD_Simulation_1
USER root

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3 python3-pip jq curl bc \
    && rm -rf /var/lib/apt/lists/*

# Install Python packages
RUN pip3 install numpy matplotlib pandas

# Create foamuser
RUN useradd -m -s /bin/bash foamuser

# FIX: Create directories expected by OpenFOAM bashrc
RUN mkdir -p /home/foamuser/platforms \
    && chown -R foamuser:foamuser /home/foamuser \
    && mkdir -p /opt/ThirdParty-9 \
    && chown -R foamuser:foamuser /opt/ThirdParty-9

RUN mkdir -p /opt/CFD_Simulation_1 && \
    chown -R foamuser:foamuser /opt/CFD_Simulation_1

# Copy simulation cases and scripts
COPY --chown=foamuser:foamuser ./simulations/ ./simulations/
COPY --chown=foamuser:foamuser ./scripts/ ./scripts/

# Make scripts executable
RUN chmod +x scripts/*.sh

# Always source OpenFOAM for interactive shells
RUN echo "source /opt/openfoam9/etc/bashrc" >> /etc/bash.bashrc

# Stage 2: Production
FROM base AS production

USER foamuser
WORKDIR /opt/CFD_Simulation_1

# Default command (parametric study)
CMD ["bash", "-lc", "./scripts/run-blockMesh.sh"]

Step 3: Creating the Cavity Flow Simulation

Understanding the Test Case

The lid-driven cavity flow is perfect for our DevOps pipeline because it:

  • Runs quickly (essential for CI/CD)
  • Has predictable results (easy to validate)
  • Requires minimal geometry (reduces complexity)
  • Demonstrates core CFD concepts

CFD Simulation Files

.
├── 0
│   ├── U
│   └── p
├── constant
│   ├── transportProperties
│   └── turbulenceProperties
└── system
    ├── blockMeshDict
    ├── controlDict
    ├── fvSchemes
    └── fvSolution

Here’s a brief overview of each file’s role to set the context:

0/: This directory contains initial and boundary conditions.

  • U: Defines the velocity field (initial values and boundary conditions).
  • p: Defines the pressure field (initial values and boundary conditions).

constant/:

  • transportProperties: Specifies fluid properties (e.g., viscosity, density) and transport models.
  • turbulenceProperties: Defines the turbulence model (e.g., laminar, k-epsilon, k-omega).

system/:

  • blockMeshDict: Describes the computational mesh geometry and structure.
  • controlDict: Controls simulation settings like time step, duration, and output frequency.
  • fvSchemes: Specifies numerical schemes for discretization (e.g., for convection, diffusion).
  • fvSolution: Defines solver settings and convergence criteria for the equations.

Step 4: Docker Automation Script

VS Code Development Setup

Install VS Code extensions. Open VS Code and install these essential extensions:

  1. Remote — WSL (Microsoft)
  2. Docker (Microsoft)

Open Integrated terminal inside VS Code : Press Ctrl+` (backtick) — Connect with WSL:Ubuntu and Open project

VS Code — WSL2 (Ubuntu) — Terminal

VS Code — WSL2 (Ubuntu) — Terminal

Build and Test the OpenFoam Container:

docker build

Run the following command in Ubuntu terminal connected to VS Code and check the image running in Docker Desktop.

docker build -f containers/openfoam/Dockerfile -t openfoam-sim .

Openfoam-sim docker image created

Openfoam-sim docker image created

You can also see the currently live images using following command.

# list active docker images
docker images

List of active images

List of active images

docker run

Run the following command directly in Ubuntu terminal or Ubuntu terminal connected to VS Code.

docker run -it --rm -v $(pwd):/workspace openfoam-sim bash

Step 7: Run the simulation

Create [scripts/run-parametric-study.sh](https://github.com/DrUzair/devops-cfd-beginner/blob/712e45ee1b742679ff235cd77a240b89d34730dd/scripts/run-parametric-study.sh):

Make scripts executable and test:

# Make scripts executable
chmod +x scripts/*.sh
# Run complete pipeline
./scripts/run-parametric-study.sh
# View results
cat ./results/summary_Re100.txt

Key DevOps Skills Demonstrated

This Level 1 setup showcases several critical DevOps competencies:

🐳 Containerization

  • Multi-stage Dockerfiles
  • Volume mounting for data persistence
  • Container lifecycle management

🔧 Automation Scripting

  • Bash scripting with error handling
  • Parameterized simulation workflows
  • Automated result processing

💻 Development Environment

  • VS Code integration with containers
  • Cross-platform development (Windows/WSL/Linux)
  • Consistent tooling across environments

📊 Monitoring & Validation

  • Automated result validation
  • Performance metrics collection
  • Structured logging and reporting

Next Steps: Level 2 Preview

In Level 2, we’ll enhance this foundation with:

  • GitHub Actions CI/CD for automated testing
  • Multi-environment deployments (dev/staging/prod)
  • Automated docker image builds and registry pushes
  • Integration testing with multiple Reynolds numbers
  • Slack/email notifications for simulation completion

Production Considerations

While this Level 1 setup is excellent for development, production deployments would require:

Security

  • Non-root container execution
  • Secrets management for credentials
  • Network security policies

Scalability

  • Kubernetes orchestration
  • Horizontal

메타데이터
post_id
c2c495c8f31e
slug
a-devops-engineers-guide-to-computational-fluid-dynamics-c2c495c8f31e
url
https://medium.com/@uzairg/a-devops-engineers-guide-to-computational-fluid-dynamics-c2c495c8f31e
canonical_url
https://medium.com/@uzairg/a-devops-engineers-guide-to-computational-fluid-dynamics-c2c495c8f31e
author_url
https://medium.com/@uzairg
status
ok
fetched_at
2026-07-17 13:02:47