Page 1 of 1

Lua functionality in Elmer

Posted: 04 Sep 2018, 12:40
by kataja
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

Re: Lua functionality in Elmer

Posted: 04 Sep 2018, 17:05
by mb5
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

Re: Lua functionality in Elmer

Posted: 21 Nov 2018, 09:17
by ReneeDegutis
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

Re: Lua functionality in Elmer

Posted: 06 Dec 2019, 17:12
by vikramonice
Hi!

Is there a way to disable Lua, once installed? I used PPA package for installation which doesn't gives a choice to not have it. Sorry, if its a basic question. I'm relatively new to Linux.

Thanks a lot!
Vikram

Re: Lua functionality in Elmer

Posted: 08 Dec 2019, 16:54
by raback
Hi Vikram,

No. There is just compile time flag WITH_LUA.

What is the problem having LUA active?

-Peter

Re: Lua functionality in Elmer

Posted: 08 Dec 2019, 17:04
by vikramonice
Hi Peter,

Thanks for your response. I have been trying to install Elmer using cmake and have been running into one error after another. PPA installation works fine but it has LUA activated. I'm picking up some work that I did a couple of years back and with LUA active the old SIF files are not working. If there was a PPA package with LUA disabled, it would have been great, but I couldn't find one.

-Vikram

Re: Lua functionality in Elmer

Posted: 09 Dec 2019, 17:09
by mzenker
Hi,

if I understand corrctly, if you don't use LUA, it will not be active and you should see no difference due to LUA. So either your old sif files contain expressions which activate LUA unintentionnally, or there is another problem.
You might post the sif file and the error message here so that some expert can have a look...

HTH,
Matthias