CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[cfMesh] General workflow to create a flawless mesh in cfMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree28Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 31, 2019, 13:57
Default
  #21
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Hi,

Just wondering if you have the version of extractFeatureEdges.py that will work on salome 9.3.

Pei-Ying
phsieh2005 is offline   Reply With Quote

Old   July 31, 2019, 15:46
Default
  #22
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
Let me check, it should be trivial to adapt. I'll see tomorrow from office
time- is offline   Reply With Quote

Old   July 31, 2019, 16:01
Default
  #23
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Thanks!


When I tried Salome 9.3 on Linux mint 19.1 - python script from OpenFOAM-v1906+/cfMesh: I got the following error:


>>> exec(open("/home/phsieh/salome/extractFeatureEdges_1906.py", "rb").read())
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<string>", line 32
print 'Extracting edges of %s with feature angle > %g.' % (body.GetName(), minFeatureAngle)
^
SyntaxError: invalid syntax
phsieh2005 is offline   Reply With Quote

Old   August 4, 2019, 19:59
Default
  #24
Member
 
Join Date: Aug 2018
Posts: 47
Rep Power: 7
foamF is on a distinguished road
Quote:
Originally Posted by time- View Post
Let me check, it should be trivial to adapt. I'll see tomorrow from office
many thanks to time-!!! The python script converting fms works nice at Salome 9.3.0 window version.

really looking foward to your script on extractFeatureEdges. Hope it ll come out very soon, which is useful to me.
foamF is offline   Reply With Quote

Old   August 5, 2019, 02:06
Default
  #25
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
@phsieh2005

That error is related to print syntax that expects parentesis in python3.

I attached v3 compatible script. Tested on Salome 9.3.0 under windows. Should work under linux too as there is no file handling.

It won't work with Salome versions prior to 9, due to multiple study capabilities that has been dropped. If a universal version is needed it should be trivial to implement a couple of checks to issue correct statements but I have no time these days.

Bye
Attached Files
File Type: zip extractFeatureEdges3.zip (1.7 KB, 165 views)
arvindpj and Marpole like this.

Last edited by time-; August 5, 2019 at 02:07. Reason: corrected salome release number
time- is offline   Reply With Quote

Old   August 5, 2019, 06:58
Default
  #26
New Member
 
Join Date: Mar 2018
Posts: 4
Rep Power: 8
asia is on a distinguished road
Quote:
Originally Posted by schuyler View Post
This is a little bit of a late reply, but haven't been on the forum in a while. Sorry!

I have used cfMesh for quite a long time with lots of success. In terms of my meshing workflow it looks like this:

1. Generate a STEP, or BREP of the fluid domain. This usually entails a boolean subtraction in whatever CAD software I am using and then exporting.
2. Load the STEP into SALOME. In the geometry module use: New Entity -> Group -> Create Group . With this you can select and name all of your surface boundaries. Additionally you can name surface boundaries for refinement.
3. Run the "extractFeatureEdges.py" salome script provided with cfMesh. (select your geometry, press ctrl-t, and select the script).
4. Go to the mesh module. Here, simply create a surface mesh of the domain. I either use Mefisto for the 2D and wire discretization with adaptive spacing, or you can use Netgen 1D-2D with default settings. It depends on your geometry how good the result will be.
5. Load your boundaries from the geometry module into the mesh module (Mesh -> Create Groups From Geometry). Then select the boundaries you created in the geometry module. Make sure you include the edges. cfMesh needs these.
6. Finally, export your surface mesh, boundary information, and edges into an FMS file using the python script "salomeTriSurf.py". Again this is provided with cfMesh. First load the script (ctrl-t, select the script). Then in the python shell, type: triSurf().writeFms('FluidDomain.fms'). This will be output in your Salome folder.
7. Copy the FluidDomain.fms to your case file and refer to it in your meshdict.

The fms file contains all of your boundary information, the edges, and the geometry info. This also lets you use the Salome GUI to select groups of faces for boundaries. This is super helpful if you have a large number of faces. You can leave the faces you created for refinement specifications as separate patches, or you can rename them in using the meshDict.

Hopefully one of you finds this useful!
Thanks for sharing the workflow! After following the steps I found the mesh after cfMesh didn’t follow the face mesh generated by salome. It seems the cfmesh just used the geometry information and generated the mesh basic on the meshdict setting.
I think there might be 2 reasons. 1: I didn't export the correct fms file with mesh information. I don't really know how to check it. 2: I didn't specify in meshDict so that Cfmesh didn't follow the facemesh
Attached Images
File Type: jpg cfMesh.jpg (54.3 KB, 142 views)
File Type: png faceMesh from salome.png (63.5 KB, 123 views)
asia is offline   Reply With Quote

Old   August 5, 2019, 08:24
Default
  #27
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
@asia

You can think about cfMesh as a blockMesh + SHM on steroids, with different shape capabilities (SHM is cartesian only while cfMesh can produce tets and poly also)

The workflow is similar though: bounding box + base octree + local/obj refinements + snap and so forth.

What you export from Salome, as fms, is nothing different from a STL to feed snappyHexMesh with. It's used as a base surface to refine and snap cells on and the tria structure can't and won't be ported to the new mesh.

What is exactly the problem in the image you attached? Can you share more informations about that?

Bye
time- is offline   Reply With Quote

Old   August 5, 2019, 11:19
Default
  #28
New Member
 
Join Date: Mar 2018
Posts: 4
Rep Power: 8
asia is on a distinguished road
@Mattia

Thanks Mattia!

Since my geometry is kinda complex, I couldn't get very good mesh using cfmesh. Mesh without boundary layers is ok with dozens of 'negative volume decomposition tets' and concaved cells, while mesh with several boundary layers could have hundreds of bad cells.

So I'm looking for ways to get rid of or at least minimize these bad cells. I thought following these steps I quoted could get better mesh based on the face mesh generated from salome. But it seems the face mesh didn't influence the volume mesh procedure in cfMesh...
asia is offline   Reply With Quote

Old   August 5, 2019, 12:59
Default
  #29
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
As far as I know trisurface quality won't influence final cfMesh grid. Of course it must be conform to your base geometry.

For the rest I can't help you without more details.

If your case ain't confidential, consider to post geometry and meshdict (you may have to upload it somewhere)

Bye
time- is offline   Reply With Quote

Old   August 6, 2019, 09:14
Default
  #30
New Member
 
Join Date: Mar 2018
Posts: 4
Rep Power: 8
asia is on a distinguished road
Quote:
Originally Posted by time- View Post
As far as I know trisurface quality won't influence final cfMesh grid. Of course it must be conform to your base geometry.

For the rest I can't help you without more details.

If your case ain't confidential, consider to post geometry and meshdict (you may have to upload it somewhere)

Bye
Aha so the step of 'generate the face mesh in salome and export to cfMesh' is just to get the fms file containing the geometry information, instead of letting cfMesh do the mesh based the face mesh. Is my understanding correct?

Below is the geometry and meshDict files. I still haven't found a way to get a good mesh. Do these concaved cells and negative volume decomposition tets affect the simlation a lot?

https://drive.google.com/open?id=1Iz...4Hxm0-OrX-sge5
asia is offline   Reply With Quote

Old   August 6, 2019, 09:53
Default
  #31
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
Pretty much, yes.
I will look into your files better tonight but at first glance I saw there is no featureEdges definition in your fms file. Is this wanted or just an error?

Can you share IGES or STEP geometry file also? I'd like to inspect original geometry, prior to triangulation.

Bye
time- is offline   Reply With Quote

Old   August 6, 2019, 12:26
Default
  #32
New Member
 
Join Date: Mar 2018
Posts: 4
Rep Power: 8
asia is on a distinguished road
Sorry that I uploaded the wrong one. I uploaded a new fms file from salome, which has edge features. I don't know how to include boundaries in the whole step file so I upload the step for the whole geometry.

Thanks!
asia is offline   Reply With Quote

Old   August 8, 2020, 20:02
Default It osen't work with salome-9
  #33
New Member
 
Oliva
Join Date: Mar 2018
Posts: 4
Rep Power: 8
Oliva is on a distinguished road
Quote:
Originally Posted by asia View Post
Thanks for sharing the workflow! After following the steps I found the mesh after cfMesh didn’t follow the face mesh generated by salome. It seems the cfmesh just used the geometry information and generated the mesh basic on the meshdict setting.
I think there might be 2 reasons. 1: I didn't export the correct fms file with mesh information. I don't really know how to check it. 2: I didn't specify in meshDict so that Cfmesh didn't follow the facemesh

Hello
I have problem in using python script, because it doesn't work with the salome- 9.
Thanks
Oliva is offline   Reply With Quote

Old   August 13, 2020, 18:54
Default Then you can join them with renameBoundary by using a wildcard
  #34
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by bennn View Post
Hi,

I also noticed that cfMesh gives different results when ran several times. There are random functions in the source code that you can find with grep... I agree it is a bit scary but results are quite consistent, most of the time a bad mesh will remain a bad mesh, and a good mesh will remain a good mesh.

Regarding the workflow, here's what's working for me.

- Generate a detailed enough stl from salome/freecad etc... The default export settings from CAD softwares are NOT good enough, and sometimes you have to mesh the surface and export it. Several 100 of Mo is not uncommon as an input stl.

- Split your input surface in a single stl where you want cfmesh to catch a feature accurately : trailing edges etc... Then you can join them with renameBoundary by using a wildcard.

- A constant refinement is always better, but can be undoable in some geometries.

- Use additionalRefinementLevels rather than boundaryCellSize and minCellSize.

- Use optimize option in boundary layer

- De-feature or increase refinement level where cfmesh gives bad quality cells

- Eventually if all else fails, you can extract the surface from a bad quality volume mesh generated by cfmesh, and use that surface as input to a new cfmesh generation. The surface mesh might be better and more waterproof than the previous one. This trick has worked quite well on really complex geometries for me in the past.

Good luck !
Hello
I used cat utility for combining all stl parts but wasn't good. What did you mean by "Then you can join them with renameBoundary by using a wildcard"?, and the python script for making fms file dosen't work with salome 9.3. I changed the python script but ...
please help me. I don't know if the problem is from Salome or script.
Thank you a lot.
Engin.shlxtn is offline   Reply With Quote

Old   August 13, 2020, 18:59
Default Same problem
  #35
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by phsieh2005 View Post
Thanks!


When I tried Salome 9.3 on Linux mint 19.1 - python script from OpenFOAM-v1906+/cfMesh: I got the following error:


>>> exec(open("/home/phsieh/salome/extractFeatureEdges_1906.py", "rb").read())
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<string>", line 32
print 'Extracting edges of %s with feature angle > %g.' % (body.GetName(), minFeatureAngle)
^
SyntaxError: invalid syntax
I have the same problem"OF2006"
Shattun likes this.
Engin.shlxtn is offline   Reply With Quote

Old   October 15, 2020, 06:28
Default
  #36
Member
 
Eren
Join Date: Aug 2018
Posts: 86
Rep Power: 8
ErenC is on a distinguished road
Hello!
I have few bad cells and I realised that these iterations are not actually lowering them(also there is an error that I don't know what it is). Is says there are (for example) 300 highly skew faces, starts iterating but that value is just fluctuating near the first value. Any idea how to solve this?

Code:
This may impair the quality of the result.
289 highly skew faces detected.
--> FOAM Warning : 
    From bool Foam::Module::polyMeshGenChecks::checkFacePyramids(const Foam::Module::polyMeshGen&, bool, Foam::scalar, Foam::labelHashSet*, const boolList*)
    in file utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C at line 2107
    Error in face pyramids: 16 faces pointing the wrong way!
--> FOAM Warning : 
    From bool Foam::Module::polyMeshGenChecks::checkFaceFlatness(const Foam::Module::polyMeshGen&, bool, Foam::scalar, Foam::labelHashSet*, const boolList*)
    in file utilities/meshes/polyMeshGenChecks/polyMeshGenChecksGeometry.C at line 3008
    16 faces with severe warpage(flatness < 0.8) found
ErenC is offline   Reply With Quote

Old   December 6, 2020, 23:11
Default
  #37
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Quote:
Originally Posted by Engin.shlxtn View Post
I have the same problem"OF2006"

Use the new updated version of the scripts provided by the user time-
Attached Files
File Type: zip Salome-cfMesh.zip (7.9 KB, 57 views)
mmohaqeqf is offline   Reply With Quote

Old   December 7, 2020, 12:32
Default
  #38
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
While the two updated python scripts are working fine in latest version of Salome, I am currently having issues with conversion to fms file.


When I type



triSurf().writeFms("FileName.fms")


in the console, I get the following error.

Does anyone know how to resolve it?



Converting SMESH Mesh 'fda_nozzle' Face 1232 is assigned to both groups noname_Group_5 and inlet
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<string>", line 119, in __init__
RuntimeError: Groups of faces are not unique, i.e. they overlap.
mmohaqeqf is offline   Reply With Quote

Old   January 20, 2021, 15:04
Default external box cells alignement in CF Mesh
  #39
New Member
 
Join Date: Dec 2020
Posts: 26
Rep Power: 5
OlivierM is on a distinguished road
hello,
thank you for the cfMesh workflow. it's very good !

I have an issue which is about aligning the cells on the domain external faces, as you can see in the attached picture.

All the first cells are wrongly distributed and cut at less than a half of what they should be.

I also don't succeed to set up some expansion ratio along the main axis.

Would have some solution to manage these ?

thanks
Attached Images
File Type: jpg CFmesh external faces cells misalignement.JPG (175.8 KB, 51 views)
OlivierM is offline   Reply With Quote

Old   April 28, 2022, 14:02
Default
  #40
Member
 
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 6
gabrielfelix is on a distinguished road
Quote:
Originally Posted by bennn View Post
Hi,

I also noticed that cfMesh gives different results when ran several times. There are random functions in the source code that you can find with grep... I agree it is a bit scary but results are quite consistent, most of the time a bad mesh will remain a bad mesh, and a good mesh will remain a good mesh.

Regarding the workflow, here's what's working for me.

- Generate a detailed enough stl from salome/freecad etc... The default export settings from CAD softwares are NOT good enough, and sometimes you have to mesh the surface and export it. Several 100 of Mo is not uncommon as an input stl.

- Split your input surface in a single stl where you want cfmesh to catch a feature accurately : trailing edges etc... Then you can join them with renameBoundary by using a wildcard.

- A constant refinement is always better, but can be undoable in some geometries.

- Use additionalRefinementLevels rather than boundaryCellSize and minCellSize.

- Use optimize option in boundary layer

- De-feature or increase refinement level where cfmesh gives bad quality cells

- Eventually if all else fails, you can extract the surface from a bad quality volume mesh generated by cfmesh, and use that surface as input to a new cfmesh generation. The surface mesh might be better and more waterproof than the previous one. This trick has worked quite well on really complex geometries for me in the past.

Good luck !


Excellent tips! Thanks so much!
gabrielfelix is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gambit problems Althea FLUENT 22 January 4, 2017 03:19
Star CCM Overset Mesh Error (Rotating Turbine) thezack Siemens 7 October 12, 2016 11:14
How Can I create the mesh by using a quarter of mesh? sasanghomi FLUENT 0 July 29, 2013 16:15
Icemcfd 11: Loss of mesh from surface mesh option? Joe CFX 2 March 26, 2007 18:10


All times are GMT -4. The time now is 21:31.