Mesh refinement is probably one of the hardest components of OpenFOAM, for me this mainly revolves around snappyhexmesh and blockmesh, with one or more STL files exported from SolidWorks as the input.
The first thing to get right is the position in the the blockmesh, you can do this using a transform, or by changing the coordinates in the blockmeshdict. Then check the refinement box is suitably sized, this one was too small so I made it larger using the refinementbox settings:
refinementBox { type searchableBox; min (-1.0 -1.4 0.0); max ( 8.0 1.4 2.5); }
Next up is to look at the basic refinement and improve that, currently, the basic mesh looks like this:
Using feature edge detection should align the cells better with the edges of the features. First we run surfaceFeatureExtract on the STL file, then update snappyhexmesh to use edge detection.
features ( { file "seven.eMesh"; level 10; } );
I also turn on feature snapping
nFeatureSnapIter 5;
This makes the edges much cleaner, but the mesh is still too course.
Adding more layers of refinement around the car should improve the mesh some more, to do this we use the addLayersControls settings below:
nSurfaceLayers 3; expansionRatio 1.3; finalLayerThickness 0.7; minThickness 0.25;
Next I make the bounding box slightly finer using blockmesh
blocks ( hex (0 1 2 3 4 5 6 7) (80 32 32) simpleGrading (1 1 1) );
At this point I also need to turn up the max cells a little, and add another refinement level
maxGlobalCells 12000000; refinementSurfaces { seven { // Surface-wise min and max refinement level level (5 6); } }
As you would expect, mesh size increases dramatically, as does the time to create the mesh. The result is improved, however the quality of the mesh is still poor in places, this will need further effort.