Lua functionality in Elmer

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

Lua functionality in Elmer

Post 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
mb5
Posts: 20
Joined: 10 Jun 2017, 18:07
Antispam: Yes

Re: Lua functionality in Elmer

Post 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
ReneeDegutis
Posts: 2
Joined: 20 Nov 2018, 18:27
Antispam: Yes

Re: Lua functionality in Elmer

Post 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
vikramonice
Posts: 2
Joined: 19 Sep 2016, 16:04
Antispam: Yes

Re: Lua functionality in Elmer

Post 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
raback
Site Admin
Posts: 4803
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Lua functionality in Elmer

Post by raback »

Hi Vikram,

No. There is just compile time flag WITH_LUA.

What is the problem having LUA active?

-Peter
vikramonice
Posts: 2
Joined: 19 Sep 2016, 16:04
Antispam: Yes

Re: Lua functionality in Elmer

Post 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
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Lua functionality in Elmer

Post 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
Post Reply