Read in an arbitrary shapes from a lua file defined as multiple tables
read a shape like for example inside a tracking table
tracking = {
{variable = { 'velocity' },
shape = { kind = 'canoND',
object = { origin = { 1.0, 1.0, 1.0 },
vec = { 2.0, 2.0, 2.0 },
segments = { 10, 20, 30 } }
}}
} -- tracking table
elements that has a certain property can also be tracked. This feature enables us to track boundary elements.
tracking = {
{ variable = { 'velocity' },
shape = { kind = 'property',
property = {'boundary'} },
}
}
} -- tracking table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_shape_type), | intent(out), | allocatable | :: | me(:) |
array of shape type defined in a lua file |
|
type(flu_State) | :: | conf |
lua config file to load shape from |
|||
integer, | intent(in), | optional | :: | parent |
optional parent handle |
|
character(len=*), | intent(in), | optional | :: | key |
optional key to load from |
|
integer, | intent(out), | optional | :: | iError |
error flag |
|
logical, | intent(in), | optional | :: | reqSegments |
Is true if use_get_point is true in output table |
subroutine tem_load_shapes( me, conf, parent, key, iError, reqSegments )
!---------------------------------------------------------------------------
!> array of shape type defined in a lua file
type(tem_shape_type), allocatable, intent(out) :: me(:)
!> lua config file to load shape from
type(flu_state) :: conf
!> optional parent handle
integer, optional, intent(in) :: parent
!> optional key to load from
character(len=*), optional, intent(in) :: key
!> error flag
integer, intent(out), optional :: iError
!> Is true if use_get_point is true in output table
logical, optional, intent(in) :: reqSegments
!---------------------------------------------------------------------------
character(len=32) :: localKey
integer :: nShapes ! number of shape table entries
integer :: iShape, shape_table, sub_table
!---------------------------------------------------------------------------
if( present( key )) then
localKey = key
else
localKey = 'shape'
endif
! open the table
! shape = {}
call aot_table_open( L = conf, &
& thandle = shape_table, &
& parent = parent, &
& key = trim( localKey ))
call aot_table_open( L = conf, &
& parent = shape_table, &
& thandle = sub_table, &
& pos = 1 )
! no shape table is defined return 0-sized array
if ( shape_table == 0 ) then
write(logUnit(2),*) ' Shape table is not defined'
write(logunit(2),*) ' ... using global mesh'
allocate(me(1))
me(1)%kind = 'all'
me(1)%shapeID = tem_global_shape
if(present(iError)) iError = ibset(0, aoterr_NonExistent)
else if ( sub_table == 0 ) then ! shape is a single table
! load table from parent shape_table
call aot_table_close(L=conf, thandle=sub_table)
allocate( me( 1 ))
call tem_load_shape_single( me = me(1), &
& conf = conf, &
& sub_table = shape_table, &
& iError = iError, &
& reqSegments = reqSegments )
else ! multiple table
call aot_table_close( L=conf, thandle=sub_table )
! open the first entry in the shape table
! shape = {{this entry}, {second entry}}
! get the number of entries in the shape table
nShapes = aot_table_length( L=conf, thandle=shape_table )
write(logUnit(1),*) 'Number of shapes defined: ', nShapes
allocate( me( nShapes ))
do iShape = 1, nShapes
call aot_table_open( L = conf, &
& thandle = sub_table, &
& parent = shape_table, &
& pos = iShape )
call tem_load_shape_single( me = me(iShape), &
& conf = conf, &
& sub_table = sub_table, &
& iError = iError, &
& reqSegments = reqSegments )
call aot_table_close( L = conf, thandle = sub_table )
end do
end if
call aot_table_close( L=conf, thandle=shape_table )
end subroutine tem_load_shapes