Lua functionality in Elmer

Numerical methods and mathematical models of Elmer
Post Reply
kataja
Posts: 73
Joined: 09 May 2014, 16:06
Antispam: Yes

Lua functionality in Elmer

Post by kataja » 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.
  • In keyword definition such as:

    Code: Select all

    temperature = variable time
      real lua "sin(tx[0])"
    
    there always needs to be some variable name on the right hand side of "variable".
  • 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"
    
Cheers,
Juhani

mb5
Posts: 17
Joined: 10 Jun 2017, 18:07
Antispam: Yes

Re: Lua functionality in Elmer

Post by mb5 » 04 Sep 2018, 17:05

Hi,

thanks for this implementation!
I use Lua with ELMER since 3 weeks on Linux. So it works very well - no problems so far :)

Regards
Martin

ReneeDegutis
Posts: 2
Joined: 20 Nov 2018, 18:27
Antispam: Yes

Re: Lua functionality in Elmer

Post by ReneeDegutis » 21 Nov 2018, 09:17

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/official) 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.
Hello kataja,

Thanks for this, I've just started working with Lua 5.1
Had to rename the posix_c.so to posix.so due to the bug issue report on Debian.

Renee

Post Reply