Page 1 of 2

SketchUp - Salome Meshing Work-Flow

Posted: 28 Nov 2012, 01:54
by rainer.ochs
If the simulation geometry is complex or there are multiple bodies involved generating the mesh is a major task.
The mesh generators have GUIs difficult to use so often it is required to code the geometry in the form of a script.
Besides the big effort this is inflexible and error prone.

On the other side there are CAD tools that allow the generation of Geometry in a more intuitive form.
My favourite choice is SketchUp because it is free, has a very intuitive and easy to use GUI and has a scripting interface for extensions and plug ins. And Salome is the only mesher that works satisfactory with multiple imported bodies.

As an Engineer I am interested in a quick and easy to use solution. I have to see what I do and I want to do it quickly. I am optimizing geometry what requires a lot of slightly different geometry to mesh. And I want my bodies and boundaries to have static indexes to reuse the .sif-files

So I have written a plug-in for SketchUp that does the meshing of a complete model using Salome as a mesher.
I have used it for some time and am very satisfied with it. It basically automates the workflow given in the Wiki for Salome in a push-button solution.

It has the following features:
- one or more bodies that may have common faces
- Bodies may be contained within other bodies
- Geometry may be very complex
- the indexes of the bodies can be controlled from the SketchUp model
- the indexes of boundaries can be controlled from the SketchUp model
- Meshing parameters can be controlled from SketchUp.

How it works:
- The geometry is drawn in SketchUp.
- Each body is grouped, the group is named and the name contains a String that denotes the body index ("part1 INDEX=1")
- each boundary that is needed in the simulation for boundary conditions is attached a material. The material name is edited to contain the "INDEX=n" string.
- The function "Elmer Salome Meshing" is executed from the tools menu.
- The plug-in now exports all groups in IGES format, using the name of the group.
- The plug-in generates a python script for Salome
- the plug-in starts Salome with the script as a parameter (at first start the user is prompted to give the location of Salome)
- Salome executes the script, imports the bodies. Then bodies and boundaries are identified from coordinate information SketchUp has placed in the script and grouped in the given order. The model is meshed with the parameters given in SketchUp and saved in .unv-format. when completed a log-file is written.
- As soon as the log file is present the plug-in starts ElmerGrid to convert the unv to elmer format and displays the Salome-log.

7/2013: There was an bug in the template for single bodies.

Rainer

Re: SketchUp - Salome Meshing Work-Flow

Posted: 29 Nov 2012, 01:56
by Epy
Very nice. I am surprised however that you are satisfied with SketchUp, as it models everything as polygons (i.e. circular objects are approximations), or at least it used to be that way. I frequently had problems with surfaces closing, etc.

Re: SketchUp - Salome Meshing Work-Flow

Posted: 29 Nov 2012, 11:17
by rainer.ochs
SketchUp models all as polygons. At least for circles and cylinder / cone surfaces I retrieve the curvature and pass it via IGES to Salome. For the moment that satisfies my needs.
I have however used spline interpolation within SketchUp to avoid these problems in other applications. Up to now I did not succeed to transport this via IGES.

Rainer

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 13:51
by bomastudio
Hi, I've got a problem with the plugin. After Salome (6.4.0) starts, nothing happens. If I try to load manually the *.py script I get the following error message:

Code: Select all

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
type help to get general information on environment
>>> execfile(r"C:/Users/Ale/Desktop/ELMER1/Senza titolo.py")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:/Users/Ale/Desktop/ELMER1/Senza titolo.py", line 172
    gg.createAndDisplayGO(id_p1)
     ^
SyntaxError: invalid syntax
>>> 
What is wrong??

I attach the *.skp file.

Thank you.

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 14:20
by rainer.ochs
Hello,
try to not use whitespace in filenames or the Group names, also avoid language specific characters - both may cause problems.
The name of the py script is the name of the sketchUp file, so you have to rename it.
If this does not help, send me the skp and the generated .py.

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 15:14
by bomastudio
Renamed *.skp file. No strange char, no blanks in names.... still problems! Thank U!!!

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 15:54
by rainer.ochs
Yes, there is a bug in the script - I will upload the corrected one tonight.
The script for multiple bodies works, the one for one body has the bug.
Rainer

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 16:00
by bomastudio
Thank you!!!

Re: SketchUp - Salome Meshing Work-Flow

Posted: 22 Jul 2013, 19:31
by rainer.ochs
I have uploaded a new version. Plese note, that your design is scaled in meter, but the box where you give the mesh sizes accepts mm. You have to give rather big values then to have a reasonable mesh count - otherwiese Salome will crash with a memory error.
In Sketchup you also can select a template in mm - that would be more straightforwad.

Please report on your results with this workflow!

Rainer

Re: SketchUp - Salome Meshing Work-Flow

Posted: 03 Nov 2014, 18:31
by juanbevan
Hi Rainer, thank you very much for the workflow and the plug-in. This seems to work for me (as far as running it and generating a mesh) although I have not been able to create a mesh conforming to two bodies sharing an inner face for a simple two cube structure (as per the .skp file attached). I used the Push-pull tool in SketchUp8 (windows 32 version) to create one surface on top of another but it seems that as I define groups the interfacing face can only be defined for one of the two groups and not for both. It would be great to hear your recommendation as to how address this problem.

I have manged to generate meshes from volumes that I independently create and superimpose on top of each other but unfortunately this does not generate a multi-solid body with a conformal mesh between them.

Advice on how to define the volumes (geometries and groups) would be very much appreciated.