CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Community Contributions (
-   -   [cfMesh] cfMesh workflow with complex geometries (

SzpetnyJohan April 2, 2019 09:45

cfMesh workflow with complex geometries

I'd like to start my first post on this forum with a big thanks for the great tool cfMesh is.
It is very convenient to use, but there is one thing that keeps it from being perfect.

I have the following problem with cfMesh.
The 3d geometry I start with is an .stl file containing an object bounded in a box. To create patches I use createFeatureEdges and create an .ftr file. As my object has many sharp corners it is being divided into thousands of tiny patches. It is a pain to work with so many patches so I have to merge them.
One option I used is a createPatch command. It allows to merge the patches and preserve all sharp corners. (copy-pasting thousands of patch names to createPatchDict is really irritating). Unfortunately I am not able to create a boundary layer afterwards as generateBoundaryLayers refers to patch names in my .ftr file and not those created with createPatch.
As it is not acceptable to ignore the boundary layer in my case, I tried a different workflow.
The other option is to use mergeSurfacePatches on my .ftr file. This way I can merge those tiny patches and name them before creating a mesh. It allows to create a boundary layer by referring to a new patch name, but a different problem appears. When the patches are merged the sharp edges are not being preserved.

To sum it up the two workflows I know either do not allow me to create a boundary layer or do not preserve sharp corners.

I believe there must be a simple way to create a mesh with a boundary layer AND sharp edges, so could you please share with me the workflow you use when working with cfmesh?

Krao May 22, 2019 09:51

Hi Patryk,

The problem you have defined is not clear, I use cfMesh and have never come across this problem. If you share more information about your 'complex' geometry. I can give some inputs.


SzpetnyJohan May 24, 2019 07:52


Thank you for the response. I managed to partially "resolve" my problem. I would delete this thread if I knew how to do this. I am sorry.

This problem appears because cfMesh does not preserve sharp corners in the geometry after you merge the patches. It seems that the only option to preserve the geometry is to divide it into many tiny patches. After using surfaceFeatureEdges sometimes there are as many as 5000 patches defining the object. When you start with a single stl containing both the object and the bounding box you are not able to find which patches refer to the box and which refer to the object. You have to do this by first generating a rough mesh and after that checking in paraFoam by trial and error which patch refers to which surface. With thousands of patches it takes a lot of time.

I had the problem described earlier because I merged patches before creating the mesh and I couldn't understand why cfMesh didn't preserve sharp corners of the geometry.

nope August 14, 2019 10:23


I'm not sure if you already though of that, anyway this is the way i handle this:

For each distinctive part i want to use for boundary conditions, i create stl files and name them properly (also within the file, not only filename).

Merge the stl files so there are multiple solids with their proper name within one stl file.

Do the surfaceFeatureEdges. Each "subpatch" created by surfaceFeatureEdges starts with the name you gave to the solid in the stl and a increasing number.

Within the meshDict, you can now use regular expressions to reference to multiple "subpatches" created by surfaceFeatureEdges. This makes life much easier. Attention here, OF v1806 has a bug that prevents regular expressions to work properly with cfMesh. Use OF v1812 and you will be fine.

Let me know if this is useful or something is not clear.

Cheers, nope

All times are GMT -4. The time now is 00:16.