Passing environmental variables to ElmerSolver command file

Numerical methods and mathematical models of Elmer
Post Reply
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Passing environmental variables to ElmerSolver command file

Post by raback »

Hi All,

Have you ever had the desire to make a minor alternation to the sif without editing it. Particularly if you do batch jobs sometimes the problem might be that you cannot edit the sif file since you would affect all the jobs in the queue.

Now, there is a handy solution for this that Juha just implemented in the devel branch. This involves a MATC function "env" that reads the environmental variable and passes it on as a string.

For example, if you set the following environmental variables (as in bash),

Code: Select all

export ELMER_ITERS=1
export ELMER_ITERMETHOD=bicgstab
export ELMER_TOL=1.0e-8
you can then use them in the sif file as follows,

Code: Select all

Solver 1
  Equation = "Heat Equation"
  Variable = "Temperature"
  Linear System Solver = "Iterative"
  Linear System Iterative Method = $ env("ELMER_ITERMETHOD")
  Linear System Max Iterations = $ env("ELMER_ITERS")
  Linear System Convergence Tolerance = $ env("ELMER_TOL")
  ...
Now this is so handy with so little coding effort that I only wonder why was this not done before ;-)

-Peter
Takala
Posts: 186
Joined: 23 Aug 2009, 23:59

Re: Passing environmental variables to ElmerSolver command file

Post by Takala »

Nice!
Post Reply