This function invokes the Lua function, in which the barycentric coordinates are computed from treeIds of an element.
Lua function defined in the script is connected to the conf handle and return the result of the function. The Lua function takes barycentric coordinate as input argument i.e fun_name(x,y,z)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | fun_ref |
Lua reference to the function to evaluate. |
||
type(flu_State) | :: | conf |
lua state |
|||
integer(kind=long_k), | intent(in) | :: | treeIds(n) |
treeIds of elements in given level |
||
type(treelmesh_type), | intent(in) | :: | tree |
global treelm mesh |
||
integer, | intent(in) | :: | n |
number of return values |
return value
function tem_spatial_lua_for_treeIds( fun_ref, conf, treeIds, tree, n ) &
& result(res)
! -------------------------------------------------------------------- !
!> Lua reference to the function to evaluate.
integer, intent(in) :: fun_ref
!> global treelm mesh
type( treelmesh_type ), intent(in) ::tree
!> number of return values
integer, intent(in) :: n
!> treeIds of elements in given level
integer(kind=long_k), intent(in) :: treeIds(n)
!> lua state
type(flu_State) :: conf
!> return value
real(kind=rk) :: res(n)
! -------------------------------------------------------------------- !
type(aot_fun_type) :: fun
integer :: iError
integer :: iDir, jDir
real(kind=rk) :: coord(3)
! -------------------------------------------------------------------- !
call aot_fun_open(L=conf, fun=fun, ref=fun_ref)
do iDir=1,n
coord = tem_BaryOfId( tree, treeIds(iDir) )
do jDir=1,3
call aot_fun_put(L=conf, fun=fun, arg=coord(jDir))
end do
call aot_fun_do(L=conf, fun=fun, nresults=1)
call aot_top_get_val(L=conf, val=res(iDir), ErrCode=iError)
if ( btest(iError,aoterr_Fatal) ) then
write(logunit(0),*) "ERROR Obtaining a spatial 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: 1'
write(logunit(0),*) 'ErrorCodes: ', iError
write(logunit(0),*) "Check return values of your Lua functions!"
call tem_abort()
end if
end do
call aot_fun_close(L=conf, fun=fun)
end function tem_spatial_lua_for_treeIds