Page 1 of 1

Python and Elmer

Posted: 04 Apr 2016, 14:24
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

Re: Python and Elmer

Posted: 04 Apr 2016, 14:33
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

Re: Python and Elmer

Posted: 05 Apr 2016, 11:51
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

Re: Python and Elmer

Posted: 05 Apr 2016, 14:54
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

Re: Python and Elmer

Posted: 05 Apr 2016, 23:37
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?

Re: Python and Elmer

Posted: 06 Apr 2016, 12:07
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

Re: Python and Elmer

Posted: 06 Apr 2016, 12:29
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

Re: Python and Elmer

Posted: 06 Apr 2016, 14:06
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

Re: Python and Elmer

Posted: 06 Apr 2016, 15:29
by annier
Hi Peter,
Thank you for the nice information. It will benefit the Elmer NonGUI users.

Yours Sincerely,
Anil Kunwar

Re: Python and Elmer

Posted: 13 Jul 2016, 16:22
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