CAD simplification for CFD with FreeCAD: three GrabCAD models, step by step

Published by Ruggero Poletto on

TL;DR

  • We took three public GrabCAD models (a 4″ flanged ball valve, a centrifugal water pump, a sports car body) and prepared them for CFD in FreeCAD 1.0.2, then meshed the original and simplified geometry with snappyHexMesh (OpenFOAM v2312) on cloudHPC.
  • Valve: 18 parts โ†’ one fluid volume (1.17 L) with 6 faces. The STL went from 254,486 to 2,542 triangles and the extracted feature edges from 18,376 to 252.
  • Pump: 81 parts โ†’ one wetted fluid volume, split into a rotor zone (0.55 L) and a stator zone (1.63 L). Feature edges fell from 27,573 to 6,524, max skewness from 10.45 to 3.98 (inside the checkMesh limit of 4), snappyHexMesh time from 44.0 s to 38.0 s.
  • Cell count did not change (243 k vs 238 k, 694 k vs 692 k): at this resolution the gain is mesh robustness and quality, not size. Simplification pays when it removes features smaller than your target cell.
  • Car body: outer skin extracted (387 โ†’ 34 faces), but FreeCAD could not close its large openings automatically โ€“ the car is left for a follow-up.
  • The fluid volume is the only thing CFD needs. Build it with Boolean Cut (domain minus solids), check it for leaks, then remove what the mesh cannot resolve.

Why simplify CAD before CFD?

A manufacturing CAD model describes the solid: bolts, threads, handles, bearings, gaskets, logos. A CFD model needs the fluid: the volume the flow occupies, with clean, closed boundaries and named inlets and outlets. Every detail that is smaller than the cell size either gets lost by the mesher or, worse, produces skewed cells, snapping errors and leaks.

The workflow in this post is the one we use on real projects:

  1. Import and inspect โ€“ how many parts, solids, shells; are they closed?
  2. Remove what does not touch the fluid โ€“ handles, bolts, nuts, motor-side parts.
  3. Extract the fluid volume โ€“ a bounding body minus the solids (Part โ†’ Boolean โ†’ Cut).
  4. Check for leaks โ€“ the fluid must not connect to the outside through clearances or missing gaskets.
  5. Defeature โ€“ remove pockets, slivers and tiny gaps (Part โ†’ Defeaturing).
  6. Add the CFD extras โ€“ inlet/outlet extensions, rotating zones, symmetry planes.
  7. Export named STL regions for snappyHexMesh.

All three models come from the GrabCAD Community Library and are credited in the References.

Results at a glance

Case Geometry CAD faces STL triangles Feature edges Cells Max skewness Failed checks snappy time [s]
Ball valve 4″ Class 150 Original (18 parts, fused) 561 254,486 18,376 243,084 6.43 3 11.4
Simplified fluid volume 6 2,542 252 238,210 8.37 3 14.1
Centrifugal water pump Original wetted parts (10 of 81) 320 513,916 27,573 693,929 10.45 3 44.0
Simplified fluid volume 142 325,852 6,524 692,361 3.98 2 38.0
Sports car body Outer skin extracted (387 โ†’ 34 faces); openings not closed automatically, no mesh run โ€“ see Case 3
Original vs simplified geometry: feature edges, max skewness and snappyHexMesh time
Original vs simplified geometry: feature edges, max skewness and snappyHexMesh time
Geometry size before and after simplification
Geometry size before and after simplification

How the runs were set up

  • CAD tool: FreeCAD 1.0.2 (conda AppImage) on the cloudHPC remote desktop, Part workbench and the built-in Python console.
  • Mesher: OpenFOAM v2312 snappyHexMesh, app snappyHexMesh-v2312 on cloudHPC, 8 vCPU hypercore spot, one run per geometry.
  • Same mesh settings for original and simplified: identical blockMesh box (4 mm cells), surface refinement level (2 2), feature level 2, resolveFeatureAngle 30, no boundary layers, same locationInMesh. Only the STL changes.
  • Quality: checkMesh v2312 with default thresholds (skewness limit 4).

The full cases (STL, snappyHexMeshDict, FreeCAD scripts) are available on request.

Case 1 โ€“ 4″ Class 150 flanged ball valve

Model: “4” CLASS 150 FLANGED BALL VALVE” by Chris Yao, GrabCAD (STEP). 18 parts: body halves, ball, stem, handle, studs and nuts.

Goal: internal flow through the open valve, inlet and outlet pipes 5D and 10D long.

The original valve in FreeCAD
The original valve in FreeCAD

Step 1 โ€“ Import the STEP

File โ†’ Open โ†’ valve.step. In the import dialog keep Merge all objects, OFF, so each part stays separate and can be hidden or picked.

STEP import options
STEP import options

Step 2 โ€“ Find the flow path

View โ†’ Clipping plane (Z) shows the bore and the ball in open position. Measure the bore radius on a flange face (Measure โ†’ Measure distance or select the circular edge and read Radius in the property panel).

Clipping plane through the valve
Clipping plane through the valve

Step 3 โ€“ Fuse all solids

Select all parts in the tree โ†’ Part โ†’ Boolean โ†’ Union. Here the union is only a tool body: we never mesh it.

Part โ†’ Boolean โ†’ Union
Part โ†’ Boolean โ†’ Union

Step 4 โ€“ Fluid volume by subtraction

Part โ†’ Primitives โ†’ Cylinder: radius 100 mm, height 228 mm, placed from flange face to flange face (X = โˆ’106 mm, axis along X). Select the cylinder, then the Fusion โ†’ Part โ†’ Boolean โ†’ Cut. Part โ†’ Compound โ†’ Explode compound splits the result: the small inner solid is the fluid, the outer ring is the space around the body and is deleted.

Cylinder primitive spanning the two flange faces
Cylinder primitive spanning the two flange faces
Extracted fluid volume (blue)
Extracted fluid volume (blue)

Python console equivalent:

d = App.ActiveDocument
cyl = d.addObject('Part::Cylinder', 'Cylinder'); cyl.Radius = 100; cyl.Height = 228
cyl.Placement = App.Placement(App.Vector(-106, 0, 0), App.Rotation(App.Vector(0, 1, 0), 90))
cut = d.addObject('Part::Cut', 'Cut'); cut.Base = cyl; cut.Tool = d.Fusion
d.recompute()
fluid = [s for s in cut.Shape.Solids if s.isInside(App.Vector(0, 0, 0), 0.01, True)][0]

Step 5 โ€“ Defeature the stem pocket

The fluid volume has 13 faces; three belong to the small pocket around the stem seal. Select them (Ctrl+click) โ†’ Part โ†’ Defeaturing. The result has 6 faces and is a valid solid.

Stem-pocket faces selected for Part โ†’ Defeaturing
Stem-pocket faces selected for Part โ†’ Defeaturing

Step 6 โ€“ Inlet and outlet extensions

Select the inlet face โ†’ Part โ†’ Extrude, Custom direction: normal, length 500 mm (5D). Same for the outlet, 1000 mm (10D). Tip: if Part โ†’ Extrude complains when you pick a face of a feature, copy the face first (Part โ†’ Create a copy โ†’ Create simple copy) and extrude the copy. Fuse the three bodies with Union and set Refine = true.

Final valve domain with pipes
Final valve domain with pipes

Step 7 โ€“ Export named regions

Export inlet, outlet and walls as separate solids in one ASCII STL so snappyHexMesh creates three patches (a 10-line FreeCAD macro that writes one solid block per region): File โ†’ Export โ†’ STL works for one region per file.

What we learned

  • The fluid of a well-modelled valve is simple: 6 faces. The STL was 100ร— smaller and snappyHexMesh extracted 252 feature edges instead of 18,376.
  • At 4 mm base cells with level-2 surfaces the mesh was the same size (243 k vs 238 k cells) and the simplified case had more highly skewed faces (54 vs 28). Fewer feature edges also means fewer edges to snap to: on the sharp flange/pipe junction you may need implicitFeatureSnap or one more refinement level. Simplification is not automatically better mesh quality; check checkMesh every time.

Case 2 โ€“ Centrifugal water pump

Model: “Centrifugal Water Pump” by Fernando Mangili Luiz, GrabCAD (STEP). 81 parts, 1,570 faces: volute casing, impeller, shaft, bearing housing, bearings, covers, gaskets, seals, screws.

Goal: a stator (volute) fluid zone and a rotor zone around the impeller, ready for MRF or AMI.

Original pump assembly
Original pump assembly

Step 1 โ€“ Keep only what is wetted

Of 81 parts only 10 touch the water: casing (Carcaรงa), adapter, shaft, impeller (Rotor), impeller lock, two drain plugs (DIN 910), two wear rings (Anel de Vedaรงรฃo), two casing gaskets (Junta). Hide the rest (Space bar in the tree) โ€“ bearings, bearing housing, covers, screws.

Step 2 โ€“ Fluid by multi-tool Cut, not Union + Cut

We first fused the wetted parts (Union) and cut them from a box. The fused body came out at 593 cmยณ against 1,545 cmยณ for the separate parts: overlapping, touching assembly parts make the Boolean union drop material. Cutting all tools at once from the box (select the box first, then all tools โ†’ Part โ†’ Boolean โ†’ Cut; Python box.cut([tools])) gave a correct volume.

Step 3 โ€“ Find the leaks

The first fluid “volume” touched the box walls everywhere: the water could leave through the shaft seal chamber, the gap left by a missing gasket and the box border. We checked faces lying on the box planes (a short script in the Python console) and fixed them by:

  • including the gaskets and drain plugs as tools;
  • shrinking the box back to the casing/adapter gasket plane (x = 440.5 mm), so the seal chamber is closed by a flat wall.

After that one solid of 2,180.5 cmยณ touches the box only at the suction (8,992 mmยฒ) and discharge (5,025 mmยฒ) flanges.

Step 4 โ€“ Close the wear-ring clearances

The 0.60 mm and 0.75 mm wear-ring gaps would need many cells across. For a first design study we closed them: a thin tube (r 55โ€“56.9 mm) over each ring, cut from the fluid. Volume removed: 3.2 cmยณ and 2.5 cmยณ. Leakage flow is then missing โ€“ state it in the report or model it later with a porous zone.

Simplified pump fluid volume
Simplified pump fluid volume

Step 5 โ€“ Rotor and stator zones

Part โ†’ Primitives โ†’ Cylinder (r = 60.5 mm, from x = 354.9 to 419.9 mm, on the shaft axis) โ†’ Part โ†’ Boolean โ†’ Intersection with the fluid = rotor zone, 546.6 cmยณ; Cut = stator zone, 1,628.3 cmยณ.

Rotor zone
Rotor zone
Stator (blue) and rotor (orange) zones
Stator (blue) and rotor (orange) zones

Step 6 โ€“ Pipes and export

Inlet extruded 500 mm, outlet 400 mm, fused into one 8,681 cmยณ domain with named inlet, outlet and walls.

Pump domain with inlet and outlet pipes
Pump domain with inlet and outlet pipes

What we learned

  • Max skewness dropped from 10.45 to 3.98 and the “highly skew faces” check passed after simplification; feature edges fell 4ร—; meshing was 14 % faster.
  • 22 sliver faces below 1 mmยฒ remain where assembly parts touch. They did not hurt this mesh, but they are the first thing to clean if snapping fails at finer levels.
  • Union of a whole assembly is the classic trap: always compare the fused volume with the sum of the parts.

Case 3 โ€“ Sports car body (external aerodynamics)

Model: “sports car body” by Mikko H, GrabCAD (STEP, 111 MB). 12 thickened surface bodies, 387 faces, 23.1 mยฒ of surface, open windows and wheel arches, no wheels.

Outer skin (blue) and open edges (red)
Outer skin (blue) and open edges (red)

Step 1 โ€“ Thick shells to solids

The bodies import as closed shells, not solids: Part โ†’ Convert to solid on each (Python Part.Solid(shell)). The main body is 24.3 L of “sheet metal”; mirrors (47โ€“62 cmยณ each), side intakes and the rear panel are separate bodies.

Step 2 โ€“ Keep only the outer skin

For external aero only the faces the air sees matter. Of the 189 faces of the main body we kept 34 outer faces (6.51 mยฒ): a ray cast from each face along its outward normal that hits the car again means the face looks into the cabin; 54 inner faces and 101 rim faces (the sheet thickness) were dropped. Mirrors are removed โ€“ a typical first simplification.

Step 3 โ€“ Close the openings

The skin has three free-edge loops: a 6-edge window opening (3.9 m of edge), a 2-edge roof/rear opening (3.5 m) and one large 90-edge underbody loop (27.2 m) that runs around all four wheel arches.

What didn’t work (yet)

  • Meshes โ†’ Fill holes (Mesh workbench, fillupHoles) after tessellating the skin added only 450 triangles: it closed the small gaps but not the three real openings, and the result had self-intersections.
  • Surface โ†’ Filling (Part.makeFilledFace) on the loop edges produced an invalid patch on the window loop (negative area) and the sewn shell stayed open after 157 s.

The car is therefore not meshed in this post. The honest lesson: a thickened-surface show model needs a manual closing strategy โ€“ Filling per opening with ordered boundary edges and a few guide curves, a flat underbody from a sketch at ride height, and wheel cylinders โ€“ or a surface-wrapping mesher that does not need a watertight STL. We will cover it in a follow-up.

What we learned

  • Thickened-surface “show” models are the hardest input for CFD: no solid, no underbody, no wheels. Expect to spend more time here than on both internal-flow cases together.
  • Keeping only the outer skin is quick and removes most of the model (387 โ†’ 34 faces), but closing large openings automatically does not work in FreeCAD 1.0.2: plan to model the closing surfaces by hand.

Run times and costs

Run Solver Instance snappyHexMesh [s] Billed [vCPUยทh] Cost
valve_raw snappyHexMesh-v2312 8 vCPU hypercore spot 11.4 0.93 โ‚ฌ0.10
valve_simpl snappyHexMesh-v2312 8 vCPU hypercore spot 14.1 0.91 โ‚ฌ0.10
pump_raw snappyHexMesh-v2312 8 vCPU hypercore spot 44.0 0.88 โ‚ฌ0.10
pump_simpl snappyHexMesh-v2312 8 vCPU hypercore spot 38.0 0.88 โ‚ฌ0.10

The billed time is dominated by boot, file transfer and shutdown (~7 min per run); the mesher itself ran under a minute. FreeCAD ran on the cloudHPC remote desktop.

How to run this on cloudHPC

  1. Start a remote desktop and open FreeCAD 1.0.2 from the desktop icon; your storage is mounted in ~/cloudHPC-storage.
  2. Simplify, export the STL into <case>/constant/triSurface/ in the storage folder.
  3. Upload a case with system/blockMeshDict, snappyHexMeshDict, surfaceFeatureExtractDict, controlDict and decomposeParDict (the same dictionaries for original and simplified cases).
  4. Launch snappyHexMesh-v2312 on hypercore (spot is fine for meshing). cloudHPC runs blockMesh, surfaceFeatureExtract, decomposePar, snappyHexMesh and checkMesh in parallel and returns the logs.

FAQ

Which FreeCAD workbench is best for CFD geometry cleanup? The Part workbench: Boolean Union/Cut/Common, Defeaturing, Extrude, Shape builder and Check geometry cover most of the work. Surface โ†’ Filling closes large openings; the Mesh workbench repairs STL.

How do I get the fluid volume of a valve or pump in FreeCAD? Make a body that encloses the flow path (cylinder or box bounded by the flanges), select it first, then the solids, and run Part โ†’ Boolean โ†’ Cut. Explode the compound and keep the solid that contains a known point in the bore.

Why does Part โ†’ Boolean โ†’ Union lose material on an assembly? Touching and overlapping parts give the OpenCASCADE fuse ambiguous faces. Compare the fused volume with the sum of the parts; if it differs, cut all tools at once from the bounding body instead.

Does CAD simplification reduce the cell count? Only if the removed features would have been refined. In our tests the cell count stayed within 2 %; the benefits were fewer feature edges, lower skewness and fewer snapping problems.

Should I close small clearances like wear-ring gaps? For a first performance estimate, yes โ€“ a 0.6 mm gap needs several cells across. Report the missing leakage, or model it later with a porous or baffle region.

References


CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs