Prepare the reduction data type
Todo
HK: what is going on here? This stuff reads, as if we have a reduction per variable? However above, we read a set of reduction objects from the configuration, thus it seems to be independent of the number of variables? Somehow there is a missing link between the reduction and the variable it should act on? How is this supposed to work? Please clarify, document or change the code! MH: Ok, the current way it is intended to work is the following you define a tracking object with a given set of variables and define a number of reduction operations. The reduction operations work on the variables starting from the first up to the number of defined reductions example: tracking = { variable = {'density', 'velocity'}, reduction = 'average', ... } Here the number of reductions is smaller than the number of variables which results in that only the density is taken an average.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_reduction_spatial_type), | intent(inout) | :: | me(:) |
The reduction type to work on. All definitions should be present in here |
||
type(tem_varSys_type), | intent(in) | :: | varSys |
global variable system defined in solver |
||
integer, | intent(in) | :: | varPos(:) |
subroutine tem_reduction_spatial_open(me, varSys, varPos) ! --------------------------------------------------------------------------- !> The reduction type to work on. All definitions should be !! present in here type( tem_reduction_spatial_type ), intent(inout) :: me(:) !> global variable system defined in solver type( tem_varSys_type ), intent(in) :: varSys integer, intent(in) :: varPos(:) ! --------------------------------------------------------------------------- integer :: iReduce ! --------------------------------------------------------------------------- do iReduce = 1, size( me ) ! Reset the number of treated elements. ! Must be counted up during _append me( iReduce )%nElems = 0 ! Take the components of the connected variable system me( iReduce )%nComponents = varSys%method%val(varPos(iReduce))%nComponents if( .not. allocated( me( iReduce )%val )) & & allocate( me( iReduce )%val( me(iReduce)%nComponents )) select case( trim(me( iReduce )%reduceType) ) case('max') me( iReduce )%val(:) = -huge(1._rk) case('min') me( iReduce )%val(:) = huge(1._rk) case default ! ('sum', 'average', 'l2norm', 'none', ... me( iReduce )%val(:) = 0._rk end select end do end subroutine tem_reduction_spatial_open