Chapter 6: Adaptive grid refinement¶
6.1 Parameters of adaptive refinement¶
Example
Call Agrif_Set_Regridding(30)
Call Agrif_Set_Minwidth(18)
Call Agrif_Set_Rafmax(3)
6.2 Refinement Criterion¶
Agrif_Detect¶
Agrif_Detect(taberr,size_taberr)
is a users subroutine.
taberr = 1
Where error is detected, taberr values are located at grid cell corners of the reference grid (including boundaries)
Example:
SUBROUTINE Agrif_Detect(taberr,sizexy)
implicit none
# include "ocean2d.h"
Integer, Dimension(2) :: sizexy
Integer,Dimension(sizexy(1),sizexy(2)) :: taberr
real vort(GLOBAL_2D_ARRAY)
do j=1,Mm+1
do i=1,Lm+1
vort(i,j) = (v(i,j)-v(i-1,j))-(u(i,j)-u(i,j-1))
enddo
enddo
crit = maxval(abs(vort))
taberr=0
where abs(vort)>0.8*crit
taberr=1
end where
End Subroutine Agrif_detect
Note
- Agrif_Detect() has to be written even without adaptive mesh refinement
6.3 Variable restoring¶
Restoring of grid variable from one grid hierarchy to another
1. Declaration¶
Call Agrif_Declare_Variable(...,variable_id,restore=.true.)
2. Specify what to restore¶
Agrif_Before_Regridding() , Agrif_Save_ForRestore()
Example: Call Agrif_Declare_Variable(...,zeta_id,restore=.true.)
Subroutine Agrif_Before_Regridding()
#include "ocean2d.h"
Call Agrif_Save_ForRestore(Zt_avg1,zeta_id)
End Subroutine Agrif_Before_Regridding
Note
- Agrif_Before_Regridding() has to be written even without adaptive mesh refinement.