SketchUp - Salome Meshing Work-Flow

Mesh generators, CAD programs, and other tools
rainer.ochs
Posts: 22
Joined: 19 Oct 2012, 01:24
Antispam: Yes

SketchUp - Salome Meshing Work-Flow

Post 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
Attachments
plugin1.zip
Plugin witch corrected templates
(17.12 KiB) Downloaded 693 times
example.zip
Example case used in the description
(890.35 KiB) Downloaded 769 times
Sketchup-Salome Workflow.pdf
Detailed description with example
(178.89 KiB) Downloaded 1023 times
Last edited by rainer.ochs on 22 Jul 2013, 19:27, edited 1 time in total.
Epy
Posts: 11
Joined: 12 Nov 2012, 02:29
Antispam: Yes
Location: CA, USA
Contact:

Re: SketchUp - Salome Meshing Work-Flow

Post 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.
rainer.ochs
Posts: 22
Joined: 19 Oct 2012, 01:24
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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
bomastudio
Posts: 36
Joined: 22 Aug 2012, 13:43
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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.
rainer.ochs
Posts: 22
Joined: 19 Oct 2012, 01:24
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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.
bomastudio
Posts: 36
Joined: 22 Aug 2012, 13:43
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post by bomastudio »

Renamed *.skp file. No strange char, no blanks in names.... still problems! Thank U!!!
Attachments
ELMER1.zip
(35.25 KiB) Downloaded 537 times
rainer.ochs
Posts: 22
Joined: 19 Oct 2012, 01:24
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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
bomastudio
Posts: 36
Joined: 22 Aug 2012, 13:43
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post by bomastudio »

Thank you!!!
rainer.ochs
Posts: 22
Joined: 19 Oct 2012, 01:24
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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
juanbevan
Posts: 5
Joined: 30 Oct 2014, 16:02
Antispam: Yes

Re: SketchUp - Salome Meshing Work-Flow

Post 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.
Attachments
cubes.7z
cube file in 7Z:
(6.73 KiB) Downloaded 435 times
Post Reply