CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   Problem Meshing a V-notch Weir with snappyHexMesh (

kflora November 14, 2011 23:50

Problem Meshing a V-notch Weir with snappyHexMesh
3 Attachment(s)
Hi Foamers,

I am trying to create a mesh using snappyHexMesh and am coming to the conclusion that even with the new Surface Feature Extract in 2.0.x, SHM is probably not the right tool to create the mesh for a Sharp-crested V-notch weir due to the sharp angles in both the vertical and transverse directions of the notch.

As you can see in the Snapped picture, the hex cells don't see to be able to me snapped onto the sharp edge of the weir crest, but generate a very uneven surface.

I have tried the AddLayers some, but mostly snapping to achieve using the following snap controls which I have tried to modify without success:

// Settings for the snapping.
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;

//- Relative distance for points to be attracted by surface feature point
// or edge. True distance is this factor times local
// maximum edge length.
tolerance 1.0;

//- Number of mesh displacement relaxation iterations.
nSolveIter 300;

//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;

//- Highly experimental and wip: number of feature edge snapping
// iterations. Leave out altogether to disable.
nFeatureSnapIter 10;

Does anyone have any suggestion for how to get SHM to work in this case or an alternative program for creating the mesh?

Thanks in advance.

mgdenno November 19, 2011 15:16

Hi kflora,

SHM can definitely do what you are trying to do. I am not at my work computer right now, where I have notes on how to do it, but I know you need to extract the edges and use them as input to SHM.

Checkout this link:


kflora November 19, 2011 21:15

2 Attachment(s)
Thanks Matthew for taking interest in this problem. I have run the edge feature extraction utility (surfaceFeatureExtract ) as was suggested in the link you provided and can see in ParaView the lines that were extracted (see attached image). I have also used the command in snapppyHexMeshDict as was suggested:

//- Highly experimental and wip: number of feature edge snapping
// iterations. Leave out altogether to disable.
nFeatureSnapIter 10;

Still, I am not able to achieve a smooth mesh along the crest of the weir. Attached is the zip of the my case directory if you want try your hand at it.

I would love to see your notes if you can get it to work.


linnemann November 20, 2011 05:42


Why not use Salome to create the geometry and mesh?

The geometry is so simple that you will be able to do a fully structured mesh.

If you send me a step/brep/iges or a sketch I would be able to create the mesh in 5min, with perfect matching of the edges.

EDIT: Or blockmesh would be relative easy.

kflora November 20, 2011 12:33

1 Attachment(s)

I haven't used Salome, but that's a program I will look into. Attached is a iges file I created using FreeCad which I have never used before either, so hopefully it gives you what you need. Basically, the weir is located 4m down in the flume, is 1 m wide by 1.5 m high with a thickness of 0.05 m. The V-notch is 0.5 m deep with a angle of 2V:1H down (-0.1 m down across the 0.05 m thickness of the weir).

Thanks for you help and idea.

linnemann November 21, 2011 06:26


Here it is in Salome format. Right click on the mesh and push compute. If you want another grading you can adjust the mesh hypothesis.

After compute export as UNV format (right click the mesh in the tree).

Use ideasUnvToFoam on the unv file and it will convert to OF format.

Read some nice tutorials here.

You can also create groups on the faces which will be converted into pathes when running the ideaUnvToFoam command.
Otherwise you can always use autoPatch 45 to split the mesh into patches where face angle exceeds 45.

Hope this helps.

nofrizal December 11, 2011 14:23

hi linneman,

i am new of using salome-meca, i want to ask
where can I see the dimmension I am working with?

linnemann December 11, 2011 15:17


Its always mm

kflora December 11, 2011 19:18


Thanks for your help with Salome. I have been looking Salome over and working through the tutorials which are helpful. One question I had was how to generate a mesh with the V-notch weir such that the weir is the obstacle and flow goes over it. Does one need to cut the mesh you developed out of a bigger box mesh? or is there a another way to generate a mesh for flow over the weir to be used in openfoam?

linnemann December 15, 2011 03:06


Well sure there are many ways to obtain what you want, but I would do the following.

Again use Salome but instead of making the "Solid" part you have to think inverse and design the "Fluid" part.

This will consists of multiple smaller boxes in order to create a fully structured mesh.

This will not be difficult but a little more time consuming.

Just remember in Salome to create a structured mesh, each block must have 12 edges and 6 faces, no more no less.

The easy fast, and in my opinion, slightly worse way would be to take the solid already made in Salome, make a bigger box around it (the fluid part) and cut the V-notch away from the big box.

Export the Geometry, not mesh, to BREP file format and open in Netgen compiled with OCC (OpenCasCade). My centFOAM packages for CentOS have that. Netgen creates unstructured tet cells but they are quite good and it will snap completely to the edges. Netgen can also assign boundary numbers and export directly to OF format.

Hope this helps.

kflora December 16, 2011 14:16

Thanks for the advice. In your preferred appoach, it sounds like if the geometry were significanty more complex than the V-notch weir (e.g., a large group of piles under a bridge foundation), then this may to too involved and no longer the best option. Correct?

I had thought about the second approach you mentioned. I don't quite understand why the need to go through Netgen, however. Can't one create a mesh in Salome using this approach as well?

linnemann December 19, 2011 02:58


No it just means that instead of two blocks, like the Salome geometry I've uploaded, you need to have 34 blocks to have a fully structured mesh.
Again its not any more difficult just a bit more tedious.

I just use Netgen because even though Salome tet mesher is based on Netgen, Netgen itself produces a slightly better mesh and faster, and it has direct support for OF mesh export.

All times are GMT -4. The time now is 12:30.