Lua functionality in Elmer
Posted: 04 Sep 2018, 12:40
Hi,
some of you might have noticed that there is a cmake option "WITH_LUA" available in Elmer. Setting that to true will compile and link Lua 5.1 (https://www.lua.org/) in to elmer solver library. Typically, evaluating Lua expressions is around 5 times faster than their matc counterparts and there are features only available to Lua and not for matc scripting.
Lua functionality is not yet enabled in Windows nor Launchpad builds. If the Lua functionality does not introduce any strange bugs we are likely to turn it on in Windows/Launchpad builds as well.
Lua can be used pretty much same way as MATC in elmer with few exceptions.
Juhani
some of you might have noticed that there is a cmake option "WITH_LUA" available in Elmer. Setting that to true will compile and link Lua 5.1 (https://www.lua.org/) in to elmer solver library. Typically, evaluating Lua expressions is around 5 times faster than their matc counterparts and there are features only available to Lua and not for matc scripting.
Lua functionality is not yet enabled in Windows nor Launchpad builds. If the Lua functionality does not introduce any strange bugs we are likely to turn it on in Windows/Launchpad builds as well.
Lua can be used pretty much same way as MATC in elmer with few exceptions.
- In keyword definition such as:
there always needs to be some variable name on the right hand side of "variable".
Code: Select all
temperature = variable time real lua "sin(tx[0])"
- You can place multiline LUA code in sif file as follows
Code: Select all
!LUA BEGIN ! --- lua line 1 ! --- lua line 2 ! ... !LUA END
- The lua script equivalent of "$" (in matc) is "#". For example "permittivity of vacuum = # epsilon" will evaluate "epsilon" as a lua expression, convert result into a string and insert that in place of "# epsilon"
- variables in 'real Lua "..."' always referred to tx[0], tx[1], ..., tx[n] in lua code instead of "tx(0), ..., tx(n)" or "tx" (in case of just one variable)
- Output order in Lua for tensorial keywords is row-wise (This is possibly the same as in matc)
Code: Select all
tensor keyword(3,2) = real time real lua "a11, a12, a13, a21, a22, a23"
Juhani