get the z component
read list of vertices for a single polygon me%npoly = 1
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_polygon_material_type), | intent(out) | :: | me |
Polygon data structure to fill with information provided by the user in config. |
||
type(flu_State) | :: | conf |
Handle to the Lua script containing the polygon definition |
|||
integer, | intent(in), | optional | :: | thandle |
Handle for the table containing the polygon definition. |
subroutine tem_polygon_material_single_load(me, conf, thandle) ! ---------------------------------------------------------------------- !> Polygon data structure to fill with information provided !! by the user in config. type(tem_polygon_material_type), intent(out) :: me !> Handle to the Lua script containing the polygon definition type(flu_state) :: conf !> Handle for the table containing the polygon definition. integer, intent(in), optional :: thandle ! ---------------------------------------------------------------------- real(kind=rk), allocatable :: defout(:) integer :: vertex_table, valtable, vertices_table integer :: movement_table, parameter_table integer :: iVertex integer :: iError integer, allocatable :: vError(:) integer :: iError_v(2) ! ---------------------------------------------------------------------- write(logUnit(1),*) 'Loading predefined function for single polygon:' valtable = 0 !> get the z component call aot_get_val( L = conf, & & thandle = thandle, & & key = 'zmin', & & val = me%zmin, & & default = 0.0_rk, & & ErrCode = iError ) if (btest(iError, aoterr_fatal)) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get a value for zmin!' write(logunit(1),*) ' This also applies if no inval is provided.' call tem_abort() end if call aot_get_val( L = conf, & & thandle = thandle, & & key = 'zmax', & & val = me%zmax, & & default = 0.0_rk, & & ErrCode = iError ) if (btest(iError, aoterr_fatal)) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get a value for zmax!' write(logunit(1),*) ' This also applies if no inval is provided.' call tem_abort() end if !> read list of vertices call aot_table_open( L = conf, & & parent = thandle, & & key = 'vertices', & & thandle = vertices_table ) if (vertices_table == 0) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: No vertices' write(logunit(1),*) ' defined, unable to set up a polynomial!' write(logunit(1),*) ' Please define vertices tables with lists of' write(logunit(1),*) ' 2D points.' call tem_abort() end if !> for a single polygon me%npoly = 1 call aot_table_open( L = conf, & & parent = vertices_table, & & pos = 1, & & thandle = vertex_table ) if (vertex_table == 0) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: No vertices' write(logunit(1),*) ' Please define vertex tables with lists of' write(logunit(1),*) ' 2D points.' call tem_abort() end if me%npoly = 1 allocate(me%poly_list(me%npoly)) me%poly_list(me%npoly)%nVertices = & & aot_table_length( L = conf, & & thandle = vertex_table ) allocate(me%poly_list(me%npoly)%vertex(me%poly_list(me%npoly)%nVertices, 2)) do iVertex=1,me%poly_list(me%npoly)%nVertices call aot_get_val( val = me%poly_list(me%npoly)%vertex(iVertex, :), & & ErrCode = iError_v, & & L = conf, & & thandle = vertex_table, & & pos = iVertex ) if (any(iError_v /= 0)) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' obtain vertex ', iVertex, '!' write(logunit(1),*) ' Vertices have to be vectors of length 2,' write(logunit(1),*) ' with real numbers as entries.' call tem_abort() end if end do call aot_table_close( L = conf, & & thandle = vertex_table ) call aot_table_close( L = conf, & & thandle = vertices_table ) call aot_table_open( L = conf, & & parent = thandle, & & key = 'movement', & & thandle = movement_table ) if (movement_table == 0) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: No movement' write(logunit(1),*) ' defined, unable to continue!' write(logunit(1),*) & & ' Please define movement table with a movement kind' call tem_abort() end if call aot_get_val( L = conf, & & thandle = movement_table, & & key = 'movement_kind', & & val = me%moving%movement_kind, & & default = 'NO Movement', & & ErrCode = iError ) call aot_table_close( L = conf, & & thandle = movement_table ) select case(me%moving%movement_kind) case( 'lin_movement_2d', 'lin_movement_3d') call aot_table_open( L = conf, & & parent = thandle, & & key = 'lin_parameter', & & thandle = parameter_table ) if (parameter_table == 0) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: lin_parameter' write(logunit(1),*) ' not defined, unable to set movement!' write(logunit(1),*) ' Please define lin_parameter table' call tem_abort() end if me%nComponents = aot_table_length( L = conf, & & thandle = parameter_table ) call aot_table_close( L = conf, & & thandle = parameter_table ) allocate(vError(me%nComponents)) allocate(me%moving%lin_parameter(me%nComponents)) call aot_get_val( L = conf, & & thandle = thandle, & & key = 'lin_parameter', & & val = me%moving%lin_parameter, & & maxlength = me%nComponents, & & ErrCode = VError ) if (any(btest(vError, aoterr_Fatal))) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: No movement' write(logunit(1),*) & & ' values defined, unable to set up the movement!' write(logunit(1),*) ' Please define lin_parameter!' write(logunit(1),*) & & ' For linear movement set velocity in X,Y for 2D!' call tem_abort() end if deallocate(vError) case( 'sin_movement_2d', 'sin_movement_3d') call aot_table_open( L = conf, & & parent = thandle, & & key = 'sin_parameter', & & thandle = parameter_table ) if (parameter_table == 0) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: sin_parameter' write(logunit(1),*) ' not defined, unable to set movement!' write(logunit(1),*) ' Please define sin_parameter table' call tem_abort() end if me%nComponents = aot_table_length( L = conf, & & thandle = parameter_table ) call aot_table_close( L = conf, & & thandle = parameter_table ) allocate(vError(me%nComponents)) allocate(me%moving%sin_parameter(me%nComponents)) call aot_get_val( L = conf, & & thandle = thandle, & & key = 'sin_parameter', & & val = me%moving%sin_parameter, & & maxlength = me%nComponents, & & ErrCode = VError ) if (any(btest(vError, aoterr_Fatal))) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: No movement' write(logunit(1),*) & &' values defined, unable to set up the movement!' write(logunit(1),*) ' Please define sin_parameter!' write(logunit(1),*) & & ' For sinefuction set amplitude and frequency in X,' write(logunit(1),*) ' than the information for the Y direction!' end if deallocate(vError) case( 'angleofAttack_2d', 'angleofAttack_3d') call aot_table_open( L = conf, & & parent = thandle, & & key = 'angle_parameter', & & thandle = parameter_table ) if (parameter_table == 0) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: angle_parameter' write(logunit(1),*) ' not defined, unable to set movement!' write(logunit(1),*) ' Please define sin_parameter table' call tem_abort() end if me%nComponents = aot_table_length( L = conf, & & thandle = parameter_table ) call aot_table_close( L = conf, & & thandle = parameter_table ) allocate(vError(me%nComponents)) allocate(me%moving%sin_parameter(me%nComponents)) call aot_get_val( L = conf, & & thandle = thandle, & & key = 'angle_parameter', & & val = me%moving%angle_parameter, & & maxlength = me%nComponents, & & ErrCode = VError ) if (any(btest(vError, aoterr_Fatal))) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: No' & & // ' movement for angle of attack' write(logunit(1),*) & & ' values defined, unable to set up the movement!' write(logunit(1),*) ' Please define sin_parameter!' write(logunit(1),*) & & ' For sinefunction set amplitude and frequency in X,' write(logunit(1),*) ' than the information for the Y direction!' end if deallocate(vError) case( 'rot_movement_2d', 'rot_movement_3d') call aot_table_open( L = conf, & & parent = thandle, & & key = 'rot_parameter', & & thandle = parameter_table ) if (parameter_table == 0) then write(logunit(1),*) & & 'ERROR in tem_polygon_material_load: rot_parameter' write(logunit(1),*) ' not defined, unable to set movement!' write(logunit(1),*) ' Please define rot_parameter table' call tem_abort() end if me%nComponents = aot_table_length( L = conf, & & thandle = parameter_table ) call aot_table_close( L = conf, & & thandle = parameter_table ) allocate(me%moving%sin_parameter(me%nComponents)) allocate(vError(me%nComponents)) call aot_get_val( L = conf, & & thandle = thandle, & & key = 'rot_parameter', & & val = me%moving%rot_parameter, & & maxlength = me%nComponents, & & ErrCode = VError ) if (any(btest(vError, aoterr_Fatal))) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: No movement' write(logunit(1),*) & & ' values defined, unable to set up the movement!' write(logunit(1),*) ' Please define rot_parameter!' write(logunit(1),*) & & ' For rotation provide the X and Y direction of the' write(logunit(1),*) ' rotation_point and the rotation speed! ' end if deallocate(vError) case default write(logUnit(1),*) 'NO movement prescribed for the polygon' end select write(logUnit(1),*) 'The single geometry movement is defined by: ', & & me%moving%movement_kind call aot_table_open( L = conf, & & parent = thandle, & & key = 'inval', & & thandle = valtable ) if (valtable == 0) then ! inval not provided as a table, try to read it as a scalar. allocate(me%inval(1)) call aot_get_val( L = conf, & & thandle = thandle, & & key = 'inval', & & val = me%inval(1), & & default = 1.0_rk, & & ErrCode = iError ) if (btest(iError, aoterr_Fatal)) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get value for inval!' call tem_abort() end if me%nComponents = 1 allocate(me%outval(me%nComponents)) allocate(vError(me%nComponents)) ! Outval needs to be consistent with the inval definition, if inval was ! defined as a scalar, outval also has to be a scalar! ! We do not check for tables with single entries in this case. call aot_get_val( L = conf, & & thandle = thandle, & & key = 'outval', & & val = me%outval(1), & & default = 0.0_rk, & & ErrCode = iError ) if (btest(iError, aoterr_fatal)) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get a value for outval!' write(logunit(1),*) ' Note, that outval needs be a scalar, as' write(logunit(1),*) ' inval is provided as a scalar.' write(logunit(1),*) ' This also applies if no inval is provided.' call tem_abort() end if else ! Intable is a table, close it an read it into an array. call aot_table_close(L = conf, thandle = valtable) ! Value to use inside the polygon call aot_get_val( L = conf, & & thandle = thandle, & & key = 'inval', & & val = me%inval, & & maxlength = 20, & & default = [1.0_rk], & & ErrCode = vError ) if (any(btest(vError, aoterr_Fatal))) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get values for inval!' call tem_abort() end if me%nComponents = size(me%inval) deallocate(vError) ! Definition of outval needs to be consistent with inval, it has to have ! the same number of components, and also needs to be a vector. ! However, we define a default of all zeroes, so if outval is 0 for all ! components, this definition can be omitted in the user definition. allocate(me%outval(me%nComponents)) allocate(vError(me%nComponents)) allocate(defout(me%nComponents)) defout = 0.0_rk ! Value to use outside the polygon call aot_get_val( L = conf, & & thandle = thandle, & & key = 'outval', & & val = me%outval, & & default = defout, & & ErrCode = vError ) if (any(btest(vError,aoterr_Fatal))) then write(logunit(1),*) 'ERROR in tem_polygon_material_load: Not able to' write(logunit(1),*) ' get a value for outval!' write(logunit(1),*) ' Note, that outval needs to have the same' write(logunit(1),*) ' length as inval.' call tem_abort() end if deallocate(vError) deallocate(defout) end if end subroutine tem_polygon_material_single_load