CAD-to-CFD Pipeline: Running High-Order Simulations with Trixi.jl on WSL
Ingesting CAD into CFD: High-Performance Aerodynamics with Julia’s Trixi.jl on WSL
In the traditional engineering workflow, Computational Fluid Dynamics (CFD) is notorious for the "two-language problem" and software silos. Engineers design complex hulls, wings, or manifolds in a CAD suite, export them to bulky meshing software, and then run simulations in heavy, closed-source solvers like Ansys Fluent or highly complex frameworks like OpenFOAM.
If you want to modify your geometry based on fluid feedback, you have to loop all the way back to the beginning of the pipeline.
In 2026, the scientific computing ecosystem has shifted toward Software Defined Hardware workflows that merge geometric design and numerical physics into a single language: Julia.
At the absolute cutting edge of this movement is Trixi.jl—a file-parallel, highly adaptive numerical simulation framework designed for hyperbolic conservation laws. By utilizing high-order Discontinuous Galerkin (DG) methods on curved, unstructured meshes, Trixi.jl can ingest complex geometric profiles and simulate compressible fluid dynamics with extreme accuracy and speed.
This guide walks you through setting up a complete CAD-to-CFD pipeline from scratch using Trixi.jl inside the Windows Subsystem for Linux (WSL).
1. The Background: Why Trixi.jl and Discontinuous Galerkin?
Traditional commercial CFD solvers rely primarily on the Finite Volume Method (FVM). While robust, FVM struggles to scale efficiently to very high orders of accuracy on complex, curved surfaces without crushing your CPU under massive mesh elements.
Trixi.jl relies heavily on the Discontinuous Galerkin Spectral Element Method (DGSEM).
The Mathematical Advantage
DGSEM combines the best features of Finite Element and Finite Volume methods. It divides the physical space into elements, but allows the solution to be discontinuous across element boundaries, resolving numerical fluxes explicitly.
For a system governed by the Compressible Euler equations:
Where $u$ represents the state vector of fluid density, momentum, and energy, Trixi.jl maps polynomial approximations natively onto curved elements. This means it can conform perfectly to the sweeping curves of an imported CAD profile without requiring billions of tiny, flat-faced linear mesh cells.
2. The CAD-to-Mesh Bridge
Trixi.jl does not read raw .STEP or .IGES files directly. To pass your hardware design into the solver, you must convert the CAD surface into an unstructured, high-order mesh. The standard open-source pipeline is:
[ CAD Design (STEP/IGES) ]
│
▼
[ Gmsh / HOHQMesh (Generate Unstructured .mesh/.msh) ]
│
▼
[ Trixi.jl Solver (Run Simulation Configured via Elixir Script) ]
By exporting your CAD boundaries into Gmsh (an open-source 3D finite element mesh generator), you can define high-order polynomial boundaries that Trixi.jl imports smoothly as an unstructured mesh grid.
3. Setting Up Your Environment on WSL From Scratch
Because advanced parallel computing frameworks and high-order linear math libraries run natively on Linux, we will run our entire pipeline inside Windows Subsystem for Linux (WSL).
Step 1: Initialize WSL and Update Packages
Open your Windows Terminal (PowerShell) and step into your Linux instance:
wsl
sudo apt update && sudo apt upgrade -y
Step 2: Install Julia on WSL
Download and link the native Linux binaries for Julia:
cd ~
wget https://julialang-s3.julialang.org/bin/linux/x64/1.10/julia-1.10.2-linux-x86_64.tar.gz
tar -xvzf julia-1.10.2-linux-x86_64.tar.gz
sudo ln -s ~/julia-1.10.2/bin/julia /usr/local/bin/julia
Verify by typing julia into your terminal to open the interactive prompt.
Step 3: Configure Necessary System Libraries
Trixi.jl and its visualization engines rely on MPI (Message Passing Interface) and HDF5 for parallel data handling. Install these backend packages directly via the Linux package manager:
sudo apt install -y mpi-default-bin mpi-default-dev hdf5-tools paraview
4. Coding the CFD Simulation in Julia
Trixi.jl configures its simulation pipelines using custom Julia scripts called Elixirs. Let's build an elixir file that loads a 2D aerodynamic profile representing a cross-section of an ingested CAD part, sets up a compressible flow simulation, and runs the time-integration engine.
Step 1: Install Trixi and Solver Dependencies
Launch the Julia REPL by typing julia. Enter package mode by pressing ] and run:
(@v1.10) pkg> add Trixi, OrdinaryDiffEq, GLMakie
Step 2: Write the Simulation Elixir Script
Create a new file in your WSL workspace named cfd_elixir.jl:
using Trixi
using OrdinaryDiffEq
# 1. Define Equations (Compressible Euler Equations in 2D)
# Ideal gas constant gamma = 1.4 (Standard Air)
equations = CompressibleEulerEquations2D(1.4)
# 2. Set Up Boundary Conditions and Boundary State
# Freestream flow moving left-to-right at Mach 0.3
initial_condition = initial_condition_constant
boundary_condition_freestream = BoundaryConditionYourCondition(
initial_condition,
equations
)
# 3. Load Ingested Mesh Geometry
# Here we load a curved unstructured mesh exported from Gmsh (.msh)
# representing our CAD surface profile
mesh_file = joinpath(@__DIR__, "cad_profile.mesh")
# If you don't have a custom mesh file yet, you can test the script
# by replacing this block with Trixi's built-in unstructured example:
mesh = UnstructuredMesh2D(mesh_file)
# 4. Set Up the Discontinuous Galerkin (DG) Solver
# Using a 3rd-order polynomial basis (polydeg = 3)
volume_flux = flux_ranocha
surface_flux = flux_lax_friedrichs
solver = DGSEM(polydeg=3, surface_flux=surface_flux, volume_flux=volume_flux)
# 5. Assemble the Semi-Discretization Problem
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
# 6. Configure Time Integration Parameters
tspan = (0.0, 2.0) # Start and End time of simulation
ode = semidiscretize(semi, tspan)
# Append analysis and save-state callbacks to output VTK files
save_solution = SaveSolutionCallback(interval=50, save_initial_solution=true, save_final_solution=true)
callbacks = CallbackSet(save_solution)
# 7. Solve the System using OrdinaryDiffEq's explicit Runge-Kutta method
println("Launching Trixi.jl Parallel CFD Engine...")
sol = solve(ode, RDPK3SpFSAL45(), abstol=1e-6, reltol=1e-6, callback=callbacks)
println("Simulation Complete!")
5. Running the Simulation and Exporting Results
To run the simulation using multi-threaded execution to leverage all your CPU cores, execute the script directly from your WSL terminal using the -t flag:
julia -t auto cfd_elixir.jl
Trixi.jl will output solution states inside an out/ folder as high-density .h5 or .vtu files.
Post-Processing with ParaView
To analyze the pressure fields, shockwaves, or vortex shedding generated around your CAD geometry:
Launch ParaView via your WSL terminal (or use the Windows version pointing to the WSL file share).
Open the generated
.vtufile sequence from theout/folder.Apply the Warp By Vector or Stream Tracer filters to visualize velocity streamlines wrapped around your structural boundaries.
Conclusion: True Software Defined Hardware
By moving your fluid dynamics tracking loops into an open-source, high-order Julia environment like Trixi.jl, you break down the traditional wall separating CAD generation from physics verification. With high-order polynomial accuracy tracking complex curves smoothly inside WSL, you can automate shape refinement and test mechanical profiles with survey-grade math precision.
Are you planning to deploy Trixi.jl to simulate internal fluid flows through custom manifolds, or external aerodynamics across a drone wing? Let's discuss your mesh generation properties and boundary configurations in the comments section below!
Comments
Post a Comment