Personal tools
You are here: Home Forum Use mixed hex-tet mesh suggestions

mixed hex-tet mesh suggestions

Up to Use

mixed hex-tet mesh suggestions

Posted by vaina at October 20. 2010

Hi everybody.

I need a suggestion for a mixed hex-tet mesh, my temptatives failed (and i waste a lot time for each one). I'd like to generate a tet mesh for the inner 'kernel' (a sort of boxed shape - see img2) and a hex mesh in the outer volume (a big box divided into 4 quarters - see img1). I want a mixed mesh, with a hex mesh as large as possible becouse I need to lower computation time. Maybe the inner shape is not so complex to require a tet mesh, but it's just a preliminary study and shapes will become more complex, so I need to find out a general procedure. My troubles involve the matching of the two grids. I used a typical [hexa_3D - quadrangle_2D - regular_1D] algorithm for the outside box and applied a [tetrahedron (Netgen) - Netgen 2D/Length from edges/Quadrangle preference] to the inner box (with a Max Size 1D too). I also tried with [tetrahedron (Netgen) - Netgen  1D-2D/Fine/Max Sixe/Allow quadrangles/Optimize]. I prefer Netgen 2D becouse Netgen 1D-2D refines the mesh just around curves and so on, but I need to control cells size in other regions too (I'm not so expert and don't know alternatives). Anyway, I always failed.

What I am I wrong with?Thanks for your attention and your attention.

Attachments

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 20. 2010

Previously vaina wrote:

Hi everybody.

I need a suggestion for a mixed hex-tet mesh, ..

Hello vaina,

At the moment I do not have any solution.  What I suggest is, you provide a STEP file of the geometry you are attempting to mesh for others to attempt.  Without a model to try on, it is difficult to recommend a course of action.

Regards.

 

Re: mixed hex-tet mesh suggestions

Posted by vaina at October 22. 2010

Thanks for your reply, you're right. I was afraid the geometry would be too heavy.

I made a simpler and smaller model, in order to save meshing time. The aim doesn't change: I'd like to apply a tet mesh (more quadrangles as possibile) to the inner volume and create a hex mesh for the outer volumes.

Thanks again for your help.

Attachments

Re: mixed hex-tet mesh suggestions

Posted by vaina at October 26. 2010

[bump]

any idea? :-/

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010

Hi
The attached script does what you need. Modify the path to brep file before launching.

Regards
S.Michael

Attachments

Re: mixed hex-tet mesh suggestions

Posted by vaina at October 26. 2010

Thanks a lot for your help. I need some explanations, I hope you'll be patient with me. I'm not so experti in Salome platform, above all python scripts. I changed the path to brep file, I also put the script in the python lib folder before launching it, but I had an error:

p, li { white-space: pre-wrap; }

Python 2.4.4 (#1, Nov 5 2009, 15:07:42)

[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2

type help to get general information on environment

>>> execfile(r"/home/maurizio/salome_5.1.4/Python-2.4.4/lib/python2.4/mixed_hex-tet_mesh.py")

Traceback (most recent call last):

File "<input>", line 1, in ?

File "/home/maurizio/salome_5.1.4/Python-2.4.4/lib/python2.4/mixed_hex-tet_mesh.py", line 1, in ?

from smesh import *

File "/home/maurizio/salome_5.1.4/KERNEL_5.1.4/lib/python2.4/site-packages/salome/import_hook.py", line 161, in import_hook

module= original_import(name, globals, locals, fromlist, *args)

File "/home/maurizio/salome_5.1.4/KERNEL_5.1.4/lib/python2.4/site-packages/salome/import_hook.py", line 161, in import_hook

module= original_import(name, globals, locals, fromlist, *args)

File "/home/maurizio/salome_5.1.4/KERNEL_5.1.4/lib/python2.4/site-packages/salome/import_hook.py", line 161, in import_hook

module= original_import(name, globals, locals, fromlist, *args)

File "/home/maurizio/salome_5.1.4/KERNEL_5.1.4/lib/python2.4/site-packages/salome/import_hook.py", line 161, in import_hook

module= original_import(name, globals, locals, fromlist, *args)

File "/home/maurizio/salome_5.1.4/SMESH_5.1.4/bin/salome/smesh.py", line 40, in ?

smesh.init_smesh(salome.myStudy,geompy.geom)

AttributeError: 'NoneType' object has no attribute 'init_smesh'

>>>

 

Anyway, I tried to 'translate' your script in GUI 'language', but I can't manage it. I think the script imports brep geometry and (sub)explodes it to get the inner box. Then I have to create a compound from six faces - which are they? Maybe the external inner_box faces? I'm in doubt also with the compounded exploded edges: are they the outside inner_box edges? I tried to recognize faces and edges by exploding the whole geometry and checking the entities labels but I think they don't match.

Then I guess I have to apply the [hexa_3D - quadrangle_2D - regular_1D (5)] algorithm to the whole geometry and create 2 sub-meshes: a algorithm [tetrahedron (Netgen)] on the inner_box solid, a [triangle (which one? Mephisto, Netgen 2D...] algorithm on the faces compound and a [regular_1D (15)] algorithm on the edges compound. Am I right?

 

I truly apologize for my newbieness :(

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010

How do you run the script? Try this way
shell$ runSalome /home/maurizio/salome_5.1.4/Python-2.4.4/lib/python2.4/mixed_hex-tet_mesh.py

BR
S.Michael

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously Saint Michael wrote:

The attached script does what you need. Modify the path to brep file before launching.

Hello Saint Michael,

Elegant solution and it works beautifully!  I learned a lot from that example.  Thank you from me too.  My question is similar to vaina.  How does one choose the correct values in

"[ ff[i] for i in [6,13,15,19,20,21]]"

and also in

"[ ee[i] for i in [12,13,14,15,24,25,26,27,28,29,30,31]]"

So far I have not understood how to get the index value of the appropriate face(s) of a geompy entity corresponding to the faces shown in a GUI's OCC window.  In other words how did you know that you need to pick 6,13,15,19,20,21 in the first command?

Regards

Re: mixed hex-tet mesh suggestions

Posted by vaina at October 26. 2010

I tried that way but it doesn't work. I report my steps, I don't know where is my trouble.

I use Ubuntu 10.04 LTS, I downloaded your script and (already) put it in /home/maurizio/salome_5.1.4/Python-2.4.4/lib/python2.4. The .brep geometry file is in /home/maurizio/Scaricati/test/, so I edited your path in the script. If I load the script in GUI mode (I tried this way before your suggestion), I have the error message reported above; if i launch the script as you suggested, I obtain just the empty Salome GUI. Maybe my path is wrong but I really don't know why.

Please, Saint Michael or JMB, can you also help me to understand the script, as I asked in the previous message? I'd like to understand the procedure and 'translate' it in GUI mode, I'm in doubt with faces and edges (I can't check them becouse I can't launch the script). I'm also interested in JMB's question.

Thanks again for your attention.

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010

if i launch the script as you suggested, I obtain just the empty Salome GUI.

If the script passes w/o error, you just need to activate SMESH module and you'll see the result of script work.

BR
S.Michael

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010

Hi JMB
To select desired sub-shapes I published all sub-shapes returned by geompy.SubShapeAllSorted() with their indices

for i,e in enumerate(ee): geompy.addToStudyInFather( test_brep_1, e, "edge %s"%i )

and then I visually found sub-shapes I needed. Naturally this way is convenient to quickly make a test script but is not fit for an industrial program. In a general case it is necessary to analyse geometry of sub-shapes using utilities defined in geompyDC.py like GetShapesOnBox() etc.

BR
S.Michael

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously vaina wrote:

I tried that way but it doesn't work. I report my steps, I don't know where is my trouble.

I use Ubuntu 10.04 LTS, I downloaded your script and (already) put it in /home/maurizio/salome_5.1.4/Python-2.4.4/lib/python2.4. The .brep geometry file is in /home/maurizio/Scaricati/test/, so I edited your path in the script. If I load the script in GUI mode (I tried this way before your suggestion), I have the error message reported above; if i launch the script as you suggested, I obtain just the empty Salome GUI. Maybe my path is wrong but I really don't know why.

Please, Saint Michael or JMB, can you also help me to understand the script

Hello vaina,

I am trying to understand the functioning of Salome TUI<->GUI to re-post the script with comments.

In answer to you question about how to run the script, I would suggest copy and paste it line by line from a text editor to the Python console of Salome.  After each command you should be getting a prompt that lokks like this >>>.  If so that command was ok and then you can press the Refresh [F5] key to see if anything changed, etc.  Of course changes will only be seen in the Object Browser window pane after an addToStudy... type command has been processed.  If a script is lacking such a command, you can always manually type it in the Python Console.  Hopefully, this will enable you to learn and debug scripts as well.

Another way to create scripts is to do it the GUI way then "Dump Study" and examine the resulting *.py *_GEO.py & *_SMESH.py file asn learn from it.  There are a couple of YouTube videos showing the method, just Google "Salome Tutorial"

Running a script line by line is an utterly stupid and tedious way to do it, but as a beginner in any interpreted language I have found the method to be useful for learning.  Good Luck.

Regards.

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Corrected text:

... should be getting a prompt that looks like this >>>.

... file and learn from it.

 

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously Saint Michael wrote:

To select desired sub-shapes I published all sub-shapes returned by geompy.SubShapeAllSorted() with their indices

Hello Saint Michael

Thank you for the explanation.  I have two more questions:

1. Are you part of the Salome development team?  Of course you can choose NOT to answer this question if you do not want to and I will understand.

2. If you are, then why is it in Salome there isn't a column in the Object Browser window pane that can turned on to show the indices of the various sub-shapes of an object?  If you are not a developer then ignore this question too!  Then I make this a suggestion for improving Salome 5.1.+ !!!

Thank you again very much for your help.

Regards.

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010
2. Why is it in Salome there isn't a column in the Object Browser window pane that can turned on to show the indices of the various sub-shapes of an object?

An index of a sub-shape within a main shape is not so useful as it could be. This is because of instability of complex geometrical operations, so that an index of the same sub-shape can vary from launch to launch.

To answer this issue, it is recommended to use geompy.SubShapeAllSorted() returning sub-shapes in a stable order instead of retrieving sub-shapes by their indices.

BR
S.Michael

Re: mixed hex-tet mesh suggestions

Posted by Saint Michael at October 26. 2010

The script I attached does not badly need usage of geompy.SubShapeAllSorted() since sub-shape indices within a geometrical shape imported from a file are always the same, this is just to demonstrate a useful technic.

BR
S.Michael

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously Saint Michael wrote:

 sub-shape indices within a geometrical shape imported from a file are always the same

Hello S. Michael,

If that be the case, then I strongly urge the Salome development team to consider introducing a column that can be displayed in the Object Browser widow pane that displays the index of the sub-object for those objects where the indices are not changing.  Or even if they are varying from one run to another, maybe a refresh feature can display the latest values? 

That would make Salome so much more user friendly at the GUI level, thereby facilitating and encouraging users to graduate to the TUI level where the true power of Salome lies hidden!  Thank you.

Regards.

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously vaina wrote:

Please, Saint Michael or JMB, can you also help me to understand the script,

Hello vaina,

In answer to your request for help and for the benefit of other users (sometimes the forgetful me) I have created a brief tutorial here: http://www.caelinux.org/wiki/index.php/Contrib:JMB/SalomeHexaTetTUI#Pre-Requisite  

TO: S. Michael/vaina/others:Let me know if anything needs clarification or correction, or make the changes yourself since it is a Wiki!

Enjoy.

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

The link above does NOT work directly, so use this one http://www.caelinux.org/wiki/index.php/Main_Page  then navigate to Contrib: JMB -> SalomeHexaTetTUI

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Previously Saint Michael wrote:

for i,e in enumerate(ee): geompy.addToStudyInFather( test_brep_1, e, "edge %s"%i )

 

Hello S. Michael,

 

Your patience in explaining the details has been such a wonderful resource for me, and I believe it is for other novice TUI  users as well.  Kudos!

 

Regards.

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 26. 2010

Hello vaina,

As a gesture towards other users, would you be willing to write a tutorial on how to create the geometry you made and post it on the CAELinux Wiki Contrib: pages?  I believe for new SALOME users your example can be an immense benefit.  Thank you.

Regards.

Re: mixed hex-tet mesh suggestions

Posted by vaina at October 27. 2010

Hi Saint Michael and JMB,

   I report my progress.

1. I managed to translate the above script in GUI mode. My initial guess was right, but I didn't exactly know which faces and edges had to be compounded. Thanks to JMB's wiki page and his pictures (I still wasn't able to run the script), I could detect them. I applied [hexa_3D - quadrangle_2D - regular_1D (5 segments)] to the whole geometry and then created 3 submeshs: [tetrahedron (Netgen)] for the inner solid, [Triangle (Mephisto)] for the faces compound and [regular_1D (15 segments)] for the edges compound (the 6 faces and 12 edges belong to the inner box - see pic1 and pic2).

2. Later I found the trouble in launching the Saint Michael script. I ran it line by line and I guessed the problem concerned the .brep file path in my computer:

p, li { white-space: pre-wrap; }

>>> from smesh import *

>>> smesh.SetCurrentStudy(salome.myStudy)

>>> brep_file = "home/maurizio/Scaricati/test/test.brep"

>>> test_brep_1 = geompy.ImportBREP(brep_file)

Traceback (most recent call last):

File "<input>", line 1, in ?

File "/home/maurizio/salome_5.1.4/GEOM_5.1.4/bin/salome/geompyDC.py", line 3443, in ImportBREP

return self.Import(theFileName, "BREP")

File "/home/maurizio/salome_5.1.4/GEOM_5.1.4/bin/salome/geompyDC.py", line 3435, in Import

RaiseIfFailed("Import", self.InsertOp)

File "/home/maurizio/salome_5.1.4/GEOM_5.1.4/bin/salome/geompyDC.py", line 93, in RaiseIfFailed

raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()

RuntimeError: Import : BREP Import failed

I got mad for that. I use linux (Ubuntu 10.04 LTS) and I tried home/maurizio/Scaricati/test/test.brep, \/maurizio/Scaricati/test/test.brep, /maurizio/Scaricati/test/test.brep and ~/maurizio/Scaricati/test/test.brep. Now I have the solution: (at least) Ubuntu needs a slash before home: /home/user_account/....

***** Thank you very, very much to Saint Michael (had I a vision? :D) and JMB *****

PS for JMB: Yes, i can write a small tutorial about my geometry, if you believe it's useful. I'm surprised becouse it's very simple to create it - I can say that becouse I'm an absolute beginner. I can contact you by e-mail when it's ready (write your address by a private message, please).

Attachments

Re: mixed hex-tet mesh suggestions

Posted by JMB at October 27. 2010

Previously vaina wrote:

Now I have the solution... Thank you very, very much ...

Yes, i can write a small tutorial about my geometry, if you believe it's useful. I'm surprised because it's very simple to create it - 

 

Hello vaina,

I am glad it is finally resolved.  I have learned in the process too, thanks to S.Michael.  Precisely because it is a simple model I request you to make a tutorial on the CAELinux Wiki pages directly.  Beginners need simple examples to begin with.  Also a simple example means writing the Wiki can be short and simple too!

Secondly, constructing the geometry is the first stage of a full FEA study and your contributions will make the existing tutorial a little more comprehensive.  Of course completing the entire lesson would mean explaining how to do the CFD and post process the results; the last 2 of the total 4 stages.  Hint, hint... for the future!

Regards.

Powered by Ploneboard
Document Actions