This routine loads the deformation table from transformation table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_deformation_type), | intent(out) | :: | deform |
deform for spatial object |
||
type(flu_State) | :: | conf |
lua state |
|||
integer, | intent(in) | :: | thandle |
spatial object parent handle |
subroutine tem_load_deformation( deform, conf, thandle )
!--------------------------------------------------------------------------!
!inferface variables
!> deform for spatial object
type(tem_deformation_type), intent(out) :: deform
!> lua state
type(flu_state) :: conf
!> spatial object parent handle
integer, intent(in) :: thandle
!--------------------------------------------------------------------------!
integer :: deform_handle, deform_subhandle
integer :: iError, iPos
integer :: vError(3), errFatal(3)
real(kind=rk) :: const, vec(3)
!--------------------------------------------------------------------------!
errFatal = aoterr_fatal
deform%active = .false.
deform%matrix = 0.0_rk
!First check if deformation is defined as a constant
call aot_get_val(L=conf, thandle = thandle, key='deformation', &
& val=const, ErrCode=iError)
if(btest(iError, aoterr_fatal)) then
call aot_table_open(L = conf, parent = thandle, &
& thandle = deform_handle, &
& key = 'deformation')
if(deform_handle > 0) then
deform%active = .true.
!deformation is defined as a table
call aot_table_open(L = conf, parent = deform_handle, &
& thandle = deform_subhandle, &
& pos = 1)
if(deform_subhandle > 0) then
call aot_table_close(L=conf, thandle=deform_subHandle)
!sub table exist load it as matrix
do iPos=1,3
call aot_get_val(L=conf, thandle=deform_handle, &
& pos=iPos, val=vec, ErrCode=vError)
if (any(btest(vError, errFatal))) then
write(logunit(0),*) 'Error in configuration: '
write(logunit(0),*) ' Deformation table at pos', iPos
call tem_abort()
end if
deform%matrix(iPos,:) = vec
end do
else
call aot_table_close(L=conf, thandle=deform_Handle)
!if single table then it is vec
call aot_get_val(L=conf, thandle=thandle, &
& key='deformation', val=vec, ErrCode=vError)
if (any(btest(vError, errFatal))) then
write(logunit(0),*) 'Error in configuration: '
write(logunit(0),*) ' Loading deformation table as vector'
call tem_abort()
end if
deform%matrix(1,1) = vec(1)
deform%matrix(2,2) = vec(2)
deform%matrix(3,3) = vec(3)
endif
else !deformation table not defined
!close the table
call aot_table_close(L=conf, thandle=deform_Handle)
endif
else
!it is a constant scaling factor
deform%active = .true.
deform%matrix(1,1) = const
deform%matrix(2,2) = const
deform%matrix(3,3) = const
endif
if (deform%active) then
write(logunit(1),"(A,3E12.5)") ' Deformation = ', deform%matrix(1,:)
write(logunit(1),"(A,3E12.5)") ' ', deform%matrix(2,:)
write(logunit(1),"(A,3E12.5)") ' ', deform%matrix(3,:)
endif
end subroutine tem_load_deformation