Specify mesh (position) in ElmerSolver command line

Discussion about coding and new developments

Specify mesh (position) in ElmerSolver command line

Postby RaJa » 30 Jun 2016, 11:16

Hi folks,

I am currently trying to run a set of simulations where the mesh is constantly modified but the sif-file stays the same. As I do not want to replace results during the calculations each mesh is in a separate folder.

Currently, I need as much sif-files as I have meshs. The reason is the definition of the mesh inside the header-section of the sif-file which makes batch-operation a bit difficult. The other way would be the modification of the sif-file after each run which is also not straightforward when working with a Python script.

A nice feature would be, if the mesh file could be specified in the command line for calling the ElmerSolver. That would allow easy batch-operation as I would only need to modify the mesh position in the call to ElmerSolver. As Elmer places the results in the folder where the mesh is located, the results get separated nicely and I can save my project with a single sif-file and a bunch of mesh-directories.

In a way I like to call something like that:
Code: Select all
ElmverSolver case.sif mesh_directory_N
, where N gets replaced everytime.

Is that already possible or can that be done?
Posts: 60
Joined: 22 Oct 2014, 09:48

Re: Specify mesh (position) in ElmerSolver command line

Postby mzenker » 30 Jun 2016, 11:23

Hi Rainer,

I don't know of a possibility to do this within Elmer (but I may be wrong).
What I would consider is to create the sif-file on-the-fly with your Python script.


Posts: 1578
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Specify mesh (position) in ElmerSolver command line

Postby raback » 05 Jul 2016, 15:21


You set in the start of the sif file:
include mesh.name
Header :: Mesh DB "." $meshname$
and then specify the name in the file mesh.name
$meshname = "square"
For convinience the naming and calling could be a one-liner:
echo '$meshname="square"' > mesh.name; ElmerSolver case.sif
Some simple awk script could also do the job even more compactly.

Site Admin
Posts: 3111
Joined: 22 Aug 2009, 11:57
Location: Espoo, Finland

Return to Software development

Who is online

Users browsing this forum: No registered users and 2 guests