This function invokes the Lua function for barycentric coordinates of an element specified by treeIds and returns an array with the given number of components.
Note, that the returned object by the Lua function has to be a table, except if there is only one component. For arrays of length 1 the Lua return value has to be a simple scalar, not a table!
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | fun_ref |
Reference of the function to open |
||
integer(kind=long_k), | intent(in) | :: | treeIds(n) |
treeIds of elements in given level |
||
type(tem_time_type), | intent(in) | :: | time |
timer object incl. the current time information |
||
type(treelmesh_type), | intent(in) | :: | tree |
global treelm mesh |
||
integer, | intent(in) | :: | n |
number of return values |
||
integer, | intent(in) | :: | ncomp |
number of components per returned value |
||
type(flu_State), | intent(in) | :: | conf |
lua state |
return value
function tem_spacetime_lua_vector_for_treeIds( fun_ref, treeIds, time, tree, & & n, ncomp, conf ) result(res) ! -------------------------------------------------------------------- ! !> Reference of the function to open integer, intent(in) :: fun_ref !> global treelm mesh type(treelmesh_type), intent(in) ::tree !> number of return values integer, intent(in) :: n !> number of components per returned value integer, intent(in) :: ncomp !> treeIds of elements in given level integer(kind=long_k), intent(in) :: treeIds(n) !> timer object incl. the current time information type(tem_time_type), intent(in) :: time !> return value real(kind=rk) :: res(n,ncomp) !> lua state type(flu_State), intent(in) :: conf ! -------------------------------------------------------------------- ! type(aot_fun_type) :: fun integer :: iError(ncomp) integer :: i, j real(kind=rk) :: coord(3) ! -------------------------------------------------------------------- ! call aot_fun_open(L = conf, fun = fun, ref = fun_ref) do i=1,n coord = tem_BaryOfId( tree, treeIds(i) ) do j=1,3 call aot_fun_put(L=conf, fun=fun, arg=coord(j)) end do call aot_fun_put(L=conf, fun=fun, arg=time%sim) call aot_fun_do(L=conf, fun=fun, nresults=1) if (nComp == 1) then call aot_top_get_val(L=conf, val=res(i,1), ErrCode=iError(1)) if ( any(btest(iError,aoterr_Fatal)) ) then write(logunit(0),*) "ERROR Obtaining a space time function" write(logunit(0),*) "Probably wrong number of components returned" write(logunit(0),*) "or a scalar was return as a lua table" write(logunit(0),*) 'Expected nComp: ', nComp write(logunit(0),*) 'ErrorCodes: ', iError write(logunit(0),*) "Check return values of your Lua functions!" call tem_abort() end if else call aot_top_get_val(L=conf, val=res(i,:), ErrCode=iError) if ( any(btest(iError,aoterr_Fatal)) ) then write(logunit(0),*) "ERROR Obtaining a space time function" write(logunit(0),*) "Probably wrong number of components returned" write(logunit(0),*) "or a scalar was return as a lua table" write(logunit(0),*) 'Expected nComp: ', nComp write(logunit(0),*) 'ErrorCodes: ', iError write(logunit(0),*) "Check return values of your Lua functions!" call tem_abort() end if end if end do call aot_fun_close(L = conf, fun = fun) end function tem_spacetime_lua_vector_for_treeIds