OpenFOAM Pre-processing in 2026 - Mesh, Surface & Field (Guide)
OpenFOAM Pre-processing in 2026
The complete map of OpenFOAM's pre-processing tools — mesh generation, manipulation and conversion, surface utilities, and field initialisation — explained for real 2026 workflows.
In CFD, the simulation is only as good as the preparation behind it — and in OpenFOAM, that preparation is pre-processing. Before a single solver iteration runs, you must build a mesh, clean up surfaces, and set sensible starting fields. OpenFOAM gives you a rich toolbox of command-line utilities for exactly this, organised into three areas: Mesh (generation, manipulation, conversion), Surface (utilities), and Field (initialisation). This 2026 guide walks through each, so you know which tool to reach for at every stage.
What This Guide Covers
What Is Pre-processing in OpenFOAM?
Pre-processing is everything you do to prepare a case before the solver runs. In OpenFOAM it breaks into three families of command-line utilities:
Mesh
Generate, manipulate and convert the computational grid — the heart of pre-processing.
Surface
Inspect, repair and smooth the triangulated geometry (STL/OBJ) that the mesh wraps around.
Field
Initialise the flow and turbulence fields so the solver starts from a sensible state.
Mesh
The mesh is the single most important pre-processing output. OpenFOAM's mesh utilities fall into three groups: Generation, Manipulation, and Conversion.
Mesh — Generation
Building the grid from scratch. The two workhorses:
blockMesh
Structured hexahedral mesh from a block description in blockMeshDict. Ideal for simple shapes and the background mesh.
snappyHexMesh
Automatic split-hex mesher: refines a background mesh, snaps to an STL surface, adds boundary layers. The tool for complex geometry.
extrudeMesh
Extrude a 2D mesh or a patch into 3D — handy for 2D studies and thin layers.
snappyHexMesh runs in three phases, all controlled in system/snappyHexMeshDict:
| Phase | What it does |
|---|---|
| Castellation | Refines the background hex mesh around surfaces, volumes and gaps |
| Snapping | Morphs the mesh onto the geometry surfaces & features while keeping quality |
| Layers | Adds prismatic boundary layers by shrinking the mesh and infilling |
$ blockMesh # background mesh from blockMeshDict $ surfaceFeatureExtract # extract sharp edges for snapping $ snappyHexMesh -overwrite # refine + snap + layers $ checkMesh # validate -> Mesh OK
snappyHexMeshConfig can auto-write blockMeshDict, surfaceFeaturesDict and snappyHexMeshDict from your STL/OBJ geometry, detecting whether it's an internal or external flow — a big head start. Match the near-wall layers to your target with the y+ calculator, and confirm mesh independence with a grid-independence test.Mesh — Manipulation
Adjusting an existing mesh without regenerating it. Common tools:
| Utility | Purpose |
|---|---|
transformPoints | Scale, translate, rotate the whole mesh |
topoSet | Create cell/face/point sets & zones (for sources, porous zones, refinement) |
createPatch | Create or combine boundary patches (e.g. cyclic) |
mergeMeshes / mirrorMesh | Combine meshes, or mirror a symmetric half |
checkMesh | Validate quality — the one you run every time |
$ transformPoints "scale=(0.001 0.001 0.001)" # mm -> m $ topoSet # build zones from system/topoSetDict $ createPatch -overwrite # fix up patches
Mesh — Conversion
Already have a mesh from another tool? Convert it to OpenFOAM's polyMesh format instead of rebuilding it:
| From | Converter |
|---|---|
| ANSYS Fluent (.msh) | fluentMeshToFoam |
| ANSYS (input) | ansysToFoam |
| Gmsh (.msh) | gmshToFoam |
| CFX-4 | cfx4ToFoam |
| I-DEAS UNV | ideasUnvToFoam |
| OpenFOAM → Fluent | foamMeshToFluent |
$ fluentMeshToFoam mesh.msh # writes into constant/polyMesh/ $ checkMesh # always check after converting
checkMesh after converting. Imported meshes can have different unit scales or orientation — use transformPoints to fix scale (e.g. mm→m) if the domain looks 1000× too big or small.Surface Utilities
Before snappyHexMesh can mesh around your geometry, the triangulated surface (STL/OBJ) must be clean and watertight. Surface utilities inspect and repair it:
surfaceInertia
Computes mass, centre of mass and inertia of a surface. In 2026 it also reports the average area normal — useful for orientation and extrusion.
surfaceLambdaMuSmooth
Smooths a noisy/faceted surface using lambda-mu smoothing — removes roughness without shrinking the shape.
surfaceFeatureExtract
Extracts sharp edges into .eMesh files so snappyHexMesh can snap to them crisply.
surfaceCheck
Reports surface quality problems — non-manifold edges, holes, illegal triangles — before you mesh.
$ surfaceCheck geometry.stl # find holes / bad triangles $ surfaceLambdaMuSmooth geometry.stl out.stl 0.33 -0.34 10 # smooth $ surfaceFeatureExtract # edges for snapping
Build and repair geometry upstream with open-source CAD tools like FreeCAD or Blender.
Field Initialisation
A solver that starts from a good field converges faster and more stably than one starting from zero. OpenFOAM's field utilities set that up:
applyBoundaryLayer
Imposes an initial turbulent boundary layer on the velocity field — a realistic start for wall-bounded turbulent flows.
setTurbulenceFields
Initialises turbulence quantities (k, ε/ω). In 2026 it needs only the reference speed as input — quick and consistent.
setFields
Sets different field values in different regions (e.g. a patch of high concentration or a filled zone) via setFieldsDict.
mapFields / potentialFoam
Map a solution from a coarse run, or use potentialFoam for a cheap, sensible initial flow.
$ setFields # region values from setFieldsDict $ applyBoundaryLayer -ybl 0.1 # turbulent BL over 0.1 m $ setTurbulenceFields -Uref 10 # init turbulence from Uref=10 m/s $ potentialFoam # cheap initial flow field
Typical Pre-processing Workflow
- Prepare geometry: place STL/OBJ in
constant/geometry; check & smooth with surface utilities. - Background mesh:
blockMesh. - Extract features:
surfaceFeatureExtract. - Body-fitted mesh:
snappyHexMesh(castellate → snap → layers). - Or convert an external mesh:
fluentMeshToFoam,gmshToFoam… - Manipulate & check:
transformPoints,topoSet,createPatch, thencheckMesh. - Initialise fields:
setFields,applyBoundaryLayer,setTurbulenceFields. - Run the solver.
For the full solver-side picture, see our best open-source CFD tools guide.
Frequently Asked Questions
What is pre-processing in OpenFOAM?
Everything done before the solver runs: preparing/meshing geometry, manipulating or converting the mesh, and initialising fields — via mesh, surface and field utilities.
What are the main mesh generation utilities in OpenFOAM?
blockMesh (structured hex from blockMeshDict) and snappyHexMesh (auto split-hex: refine, snap to STL, add layers), plus helpers like extrudeMesh and snappyHexMeshConfig.
How do I convert a mesh to OpenFOAM format?
Use a converter: fluentMeshToFoam, ansysToFoam, gmshToFoam, cfx4ToFoam, ideasUnvToFoam. It writes into constant/polyMesh. Always run checkMesh after.
What are surface utilities used for in OpenFOAM?
To inspect and repair the STL/OBJ surface before meshing: surfaceInertia (mass/inertia + average area normal), surfaceLambdaMuSmooth (smoothing), surfaceFeatureExtract (edges), surfaceCheck (quality).
What do applyBoundaryLayer and setTurbulenceFields do?
applyBoundaryLayer imposes an initial turbulent boundary layer on velocity; setTurbulenceFields initialises turbulence quantities from just a reference speed. Both improve stability and convergence.
Why is meshing the most important part of pre-processing?
Because mesh quality controls accuracy and stability. Poor non-orthogonality/skewness causes most divergence — hence "good mesh, good results." Always checkMesh before solving.
Conclusion
OpenFOAM pre-processing is a toolbox, and knowing which tool to grab is half the battle. Remember the three families: Mesh (generate with blockMesh/snappyHexMesh, manipulate with transformPoints/topoSet, convert with fluentMeshToFoam and friends), Surface (inspect & smooth with surfaceInertia, surfaceLambdaMuSmooth, surfaceFeatureExtract), and Field (initialise with applyBoundaryLayer, setTurbulenceFields, setFields). Prepare a clean surface, build and check a quality mesh, start from a sensible field — and your solver is set up to succeed.
For more OpenFOAM, CFD and simulation tutorials plus free engineering calculators, explore Free CFD Tutorial. If this guide helped you, please share it with your fellow CFD engineers and students.

Comments
Post a Comment