Append a new state variable to the variable system.
Note that the actual data on how to access the state has to be encoded in the method_data pointer. The callers therefore have to ensure the consistency of those access definitions. nComponents has to be at least 1.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_varSys_type), | intent(inout) | :: | me |
Variable system to append the state variable to. |
||
character(len=*), | intent(in) | :: | varname |
Variable to append to the state. |
||
integer, | intent(in) | :: | nComponents |
Number of components in this variable. |
||
type(c_ptr), | intent(in) | :: | method_data |
Data that is required by the methods to obtain the variable. |
||
procedure(tem_varSys_proc_point), | pointer | :: | get_point |
Procedure which allows the retrieval of the variable at given points. |
||
procedure(tem_varSys_proc_element), | pointer | :: | get_element |
Procedure which allows the retrieval of the variable in an element. |
||
procedure(tem_varSys_proc_setParams), | optional, | pointer | :: | set_params |
Procedure which allows to set parameter in method_data |
|
procedure(tem_varSys_proc_getParams), | optional, | pointer | :: | get_params |
Procedure which allows to get parameter in method_data |
|
procedure(tem_varSys_proc_setupIndices), | pointer | :: | setup_indices |
Procedure to setup growing array of points, variable value in method_data and return index of points set |
||
procedure(tem_varSys_proc_getValOfIndex), | pointer | :: | get_valOfIndex |
Procedure which allows to retrieval of the variable at point or val array index |
||
integer, | intent(out), | optional | :: | pos |
Position of the variable in the system. |
|
logical, | intent(out), | optional | :: | wasAdded |
Indicator, if the variable was actually added to the system. |
subroutine tem_varSys_append_stateVar(me, varname, nComponents, method_data, & & get_point, get_element, set_params, & & get_params, setup_indices, & & get_valOfIndex, pos, wasAdded) ! --------------------------------------------------------------------------! !> Variable system to append the state variable to. type(tem_varSys_type), intent(inout) :: me !> Variable to append to the state. character(len=*), intent(in) :: varname !> Number of components in this variable. integer, intent(in) :: nComponents !> Data that is required by the methods to obtain the variable. type(c_ptr), intent(in) :: method_data !> Procedure which allows the retrieval of the variable at given points. procedure(tem_varSys_proc_point), pointer :: get_point !> Procedure which allows the retrieval of the variable in an element. procedure(tem_varSys_proc_element), pointer :: get_element !> Procedure which allows to set parameter in method_data procedure(tem_varSys_proc_setParams), optional, pointer :: set_params !> Procedure which allows to get parameter in method_data procedure(tem_varSys_proc_getParams), optional, pointer :: get_params !> Procedure to setup growing array of points, variable value !! in method_data and return index of points set procedure(tem_varSys_proc_setupIndices), pointer :: setup_indices !> Procedure which allows to retrieval of the variable at point or val !! array index procedure(tem_varSys_proc_getValOfIndex), pointer :: get_valOfIndex !> Position of the variable in the system. integer, optional, intent(out) :: pos !> Indicator, if the variable was actually added to the system. logical, optional, intent(out) :: wasAdded ! --------------------------------------------------------------------------! logical :: newVar type(tem_varSys_op_type) :: state_access integer :: iComp, varPos ! --------------------------------------------------------------------------! call append( me = me%varname, & & val = varname, & & pos = varPos, & & wasAdded = newVar ) if (newVar) then state_access%mypos = varPos state_access%operType = 'state' state_access%nInputs = 0 state_access%nComponents = nComponents allocate(state_access%state_varPos(nComponents)) do iComp = 1, nComponents state_access%state_varPos(iComp) = me%nScalars + iComp end do allocate(state_access%input_varPos(0)) state_access%method_data = method_data state_access%get_point => get_point state_access%get_element => get_element if (present(set_params)) then state_access%set_params => set_params else state_access%set_params => tem_varSys_setParams_dummy end if if (present(get_params)) then state_access%get_params => get_params else state_access%get_params => tem_varSys_getParams_dummy end if state_access%setup_indices => setup_indices state_access%get_valOfIndex => get_valOfIndex call append( me = me%method, & & val = state_access ) me%nStateVars = me%nStateVars+1 me%nScalars = me%nScalars + nComponents end if if (present(pos)) pos = varPos if (present(wasAdded)) wasAdded = newVar end subroutine tem_varSys_append_stateVar