Average the solution over an average grid.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
subroutine average_solution()
!---------------------------------------------------------------------------------------------------------------------------------
!< Average the solution over an average grid.
!---------------------------------------------------------------------------------------------------------------------------------
integer(I_P):: i, ii, i1, i2 !< Counters.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if ((av_Ni>0).and.(av_Ni/=Ni)) then
if (allocated(av_state)) deallocate(av_state) ; allocate(av_state(1:Np, 1:av_Ni))
do i=1, av_Ni
i1 = minloc(array=xcenter, dim=1, mask=(xcenter>=av_xnode(i-1)))
i2 = maxloc(array=xcenter, dim=1, mask=(xcenter<=av_xnode(i)))
av_state(:, i) = 0._R_P
do ii=i1, i2
av_state(:, i) = av_state(:, i) + final_state(:, ii)
enddo
av_state(:, i) = av_state(:, i) / (i2-i1+1)
enddo
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine average_solution