This subroutine load temporal table defined for a boundary.\n
If temporal is defined as lua function then set kind = temporal_lua else if temporal block is defined then load temporal table for predefined Fortran function variables and set kind = temporal_\a function_name else temporal is a constant value and set kind = temporal_const.\n \n Valid definitions: \li Constant ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = 1.0 ~~~~~~~~~~~~~~~~~~~~~ \li lua_function ~~~~~~~~~~~~~~~~~~~~~ temporal = 'linear' ~~~~~~~~~~~~~~~~~~~~~ Example: \a linear lua function \verbatim function linear(iTime) local to_time = 1000 if iTime < to_time then return iTime/to_time else return 1.0 end end \endverbatim \li Predefined Fortran function ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = {predefined="Fortranfun_name", min_factor = 0.0, max_factor = 1.0, from_time = 0.0, to_time = 1000.0} ~~~~~~~~~~~~~~~~~~~~~ \li Data from a file (periodic data supported) ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = {predefined="datafile", filename='data.dat', -- path/name of the datafile intp='linear', -- interpolation between the time tics ('linear','none') periodic= true} -- is the data periodic? ~~~~~~~~~~~~~~~~~~~~~ \n
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_temporal_type), | intent(out) | :: | me |
boundary temporal type |
||
type(flu_State) | :: | conf |
lua state |
|||
integer, | intent(in) | :: | parent |
parent handle contains temporal table |
||
character(len=*), | intent(in), | optional | :: | key |
state variable key string defined in lua |
subroutine tem_load_temporal( me, conf, parent, key )
! ---------------------------------------------------------------------------
!> boundary temporal type
type(tem_temporal_type), intent(out) :: me
!> lua state
type(flu_State) :: conf
!> parent handle contains temporal table
integer, intent(in) :: parent
!> state variable key string defined in lua
character(len=*), intent(in), optional :: key
! ---------------------------------------------------------------------------
type(aot_fun_type) :: fun
integer :: thandle
integer :: iError
character(len=labelLen) :: local_key
! ---------------------------------------------------------------------------
if(present(key)) then
local_key = trim(key)
else
local_key = 'temporal'
endif
! First test for a lua function
call aot_fun_open( L = conf, &
& parent = parent, &
& fun = fun, &
& key = trim( local_key ))
me%conf = conf
if (fun%handle /= 0) then
! This temporal modifier is defined as a Lua function
me%kind = 'lua_fun'
me%lua_fun_ref = aot_reference_for(conf)
write(logUnit(1),*)' Defined lua temporal function'
call aot_fun_close( L = conf, fun = fun )
else
! It is not defined as a function, try to interpret it as a table
call aot_table_open( L = conf, &
& thandle = thandle, &
& parent = parent, &
& key = trim( local_key ))
if (thandle /= 0) then
call aot_get_val( L = conf, &
& thandle = thandle, &
& key = 'predefined', &
& val = me%kind, &
& default = 'unknown', &
& ErrCode = iError)
write(logUnit(1),*)' A predefined temporal function is chosen: '&
& //trim(me%kind)
select case(trim(me%kind))
case('linear', 'smooth')
! Load the standard parameters necessary to describe the
! temporal behavior of the BC.
call load_temporal_linear( me = me%linear, &
& conf = conf, &
& thandle = thandle )
case('datafile')
! Load the filename for the datafile
call load_temporal_from_file( me = me%from_file, &
& conf = conf, &
& thandle = thandle )
case('cos')
call load_temporal_cos( freq = me%freq,&
& phi = me%phi, &
& offset = me%offset, &
& conf = conf, &
& thandle = thandle )
case default
write(logUnit(1),*)'ERROR in definition of the temporal '// &
& ' boundary Conditions:'
write(logUnit(1),*)'Selected an unknown temporal boundary'
write(logUnit(1),*)trim(me%kind)
call tem_abort()
end select
else
! As the entry for the variable is neither a function nor a table, try
! to interpret it as a constant variable
call aot_get_val( L = conf, &
& thandle = parent, &
& key = trim(local_key), &
& val = me%const, &
& ErrCode = iError )
if (btest(iError, aoterr_WrongType)) then
write(logUnit(1),*)'FATAL Error occured in definition of the '// &
& 'temporal boundary conditions'
write(logUnit(1),*)'while retrieving temporal constant:'
write(logUnit(1),*)'Variable has wrong type (should be a '// &
& 'real number)!'
write(logUnit(1),*)'STOPPING'
call tem_abort()
end if
if (btest(iError, aoterr_NonExistent)) then
! "temporal" variable not specified
me%kind = 'none'
me%const = 1.0_rk
else
me%kind = 'const'
end if
end if
end if
end subroutine tem_load_temporal