Python and Elmer

General discussion about Elmer
Post Reply
homerun4711
Posts: 40
Joined: 07 Jun 2011, 11:24
Antispam: Yes

Python and Elmer

Post by homerun4711 »

Hello,

has someone ever written a Python wrapper or another Python interface for Elmer?

I was just thinking if this might be useful for me, maybe with MeshPy (tetgen)
for mesh generation and Mayavi (VTK, now working with Python 3)
for visualization.

Kind regards,
Markus
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Python and Elmer

Post by mzenker »

Hi Markus,

I haven't done that, but I am thinking for a long time that a thing like that would be useful, and would love to have the time to do it.
Have you considered the Salomé platform? This would involve the Salomé geometry and mesh module for preprocessing, and ParaView for postprocessing. They use Python as well.

Matthias
homerun4711
Posts: 40
Joined: 07 Jun 2011, 11:24
Antispam: Yes

Re: Python and Elmer

Post by homerun4711 »

Hello Matthias,

I just saw that Salome is available for Windows now, nice.
Last time I checked, about 2012, it wasn't and my company computer runs Win7.
Will take a look.

About a wrapper for Elmer, is there a list of all available input variables somewhere,
maybe with default values, that could be parsed to get them into python?

What could the structure be like? Python writes the input files directly?
Or is there some binary interface that could be used? Like talking to a dll directly?

Kind regards,
Markus
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Python and Elmer

Post by mzenker »

Hi,

I have used Salomé under Windoze 7 several times, it appears resonably stable to me.
The workflow I imagine for Elmer in Salomé would be something like

1. Prepare (or import) the mesh in Salomé mesh module
2. Define equations, materials, BCs etc. in some Elmer module
3. Write a sif file and mesh files
4. Run the simulation using a shell/system command
5. Do the postprocessing with ParaView

The Elmer Module under 2. would have to be built. Possibily ElmerGUI code or at least the pyqt menu definitions could be reused for that.
Under 3., one could use unv format for the mesh, but the body and BC information would have to be handled separately. Or One can use Salomé MED format, then Elmergrid would have to be enabled to convert that to Elmer mesh format, taking care of the body and boundary numbering, which must match with the sif file.
For 5., it can either be done using vtu written by Elmer. Or ResultoutputSolver would have to learn to write MED format, so that the Salomé ParaView module (ParaVis) can be used directly. Then one would have the workflow completely within the Salomé platform.

As I said, I would love to do at least a part of the work, but I don't have the time...

Matthias
KaiMartin
Posts: 42
Joined: 02 Jun 2013, 00:07
Antispam: Yes
Location: Hannover, Germany
Contact:

Re: Python and Elmer

Post by KaiMartin »

Haven't heard of Salomé before. So I checked the projects website and found:
What can you do with SALOME?
  • Create/modify, import/export (IGES, STEP, BREP), repair/clean CAD models
  • Mesh CAD models, edit mesh, check mesh quality, import/export mesh (MED, UNV, DAT, STL)
  • Handle physical properties and quantities attached to geometrical items
  • Perform computation using one or more external solvers (coupling)
  • Display computation results (scalar, vectorial)
  • Manage studies (create, save, reload)
Hmm.
Maybe I miss something. But how does this expand on what ElmerGUI can already do all by itself?
Is it better at importing, meshing or post processing?
---<)kaimartin(>---
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Python and Elmer

Post by mzenker »

Hi,

Salomé itself is good at importing a geometry and meshing it. And since Salomé is an integrated environment, existing software can be integrated as a module. They have done that with ParaView, so thanks to the ParaView module (they call it ParaVis), Salomé is also good at postprocessing.

IMO the task would be to create a new Salomé module having roughly the functionality of ElmerGUI, but as part of the integrated enviromnent. At present, one tedious task is always to manage numbers/names of bodies and boundaries, as they get renumbered at mesh import by Elmer. If an Elmer module was integrated in Salomé, you could define and name bodies and boundaries in the mesh module and use this information directly in Elmer.

Matthias
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Python and Elmer

Post by raback »

Hi Matthias

I agree that this would be a great goal. Elmer project is mainly a project for ElmerSolver, very small part of the effort has gone to ElmerGUI.

When working with Salome there is a way to maintain names when exporting in UNV format for Elmer. In Elmer analysis can then directly use these names, for example, as

Code: Select all

Simulation 
  ...
  Use Mesh Names = True
End 

Body 1
  Name = mixer
  ...
End 
...
Boundary Condition 7
  Name = inlet
  Velocity 1 = 1.0 
End 
Thus you don't need to play with "Target Bodies" or "Target Boundaries".

-Peter
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Python and Elmer

Post by mzenker »

Hi Peter,

interesting hint, thanks!
This is useful especially fo the nonGUI Elmer users.
For the GUI users, the GUI would have to know those names...

Matthias
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Python and Elmer

Post by annier »

Hi Peter,
Thank you for the nice information. It will benefit the Elmer NonGUI users.

Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Python and Elmer

Post by annier »

raback wrote: When working with Salome there is a way to maintain names when exporting in UNV format for Elmer. In Elmer analysis can then directly use these names, for example, as

Code: Select all

Simulation 
  ...
  Use Mesh Names = True
End 

Body 1
  Name = mixer
  ...
End 
...
Boundary Condition 7
  Name = inlet
  Velocity 1 = 1.0 
End 
Thus you don't need to play with "Target Bodies" or "Target Boundaries".
Hi Peter,
If we have to use two boundaries with same boundary conditions, do we set like this?

Code: Select all

Boundary Condition 7
  Name = "inlet outlet"
  Velocity 1 = 1.0 
End 
Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
Post Reply