Chapter 3: The computational grid as seen by the AGRIF software¶
3.1 The computational grid¶
3.1.1 The reference grid¶

Coarse grid describes with interior nx cells and two ghost cells

Coarse grid and fine grid G1 with a refinement factor of 2
3.1.2 AGRIF_Fixed_Grids.in file¶
This file is used to define grids positions, space and time refinement factors. It also gives the informations about the number of child grid for each grid and define them.
Example: The file
- AGRIF_Fixed_Grids.in file for the definition of one grid with no child grid in 1D
1
6 2 2 # imin imax rhox rhot
0
- AGRIF_Fixed_Grids.in file for the definition of one grid with no child grid in 2D
1
3 6 4 8 3 2 3 # imin imax jmin jmax rhox rhoy rhot
0
Example: Description of grid hierarchy

Coarse grid G0 which has 2 fine grids G1 and G2

Coarse grid G0 with 2 fine grids G1 and G2 which have their own fine grids
3.2 Declaration of grid variables¶
3.2.1 Declaration of profiles¶
In order to use it for interpolation/update via procnames (see after).
1. Specification of variable and location¶
Agrif_Declare_Variable((/stag/),(/first_index/),(/’dim’/),(/ibegin/),(/iend/),variable_id)
Note
variable_id: is an integer (output)
stag : 1 (noncentered) or 2 (centered)
first_index: array index of the first point in the reference grid
dim: ‘x’, ‘y’, ‘z’ or ‘N’
‘N’ : no refinement in that direction
2. Examples¶
Centered variable (T)
Call Agrif_Declare_Variable((/2/),(/1/),(/'x'/),(/0/),(/nx+1/),T_id)

Centered variable T
Noncentered variable (U)
Call Agrif_Declare_Variable((/1/),(/0/),(/'x'/),(/0/),(/nx/),U_id)

Non-centered variable U
Note
- Agrif_Declare_Variable() is also called on the root grid.
3.2.2 Relative Positions on the grids¶
1. Index of the first coarse grid points inside the fine grid domain¶
index of the first variable
- Centered variable (T)

index of the first centered variable
- Noncentered variable (U)

index of the first non-centered variable
Note
imin is the one specified in the file AGRIF_Fixed_Grids.in
2. Algorithm to update T and U variables¶
! Update of U points (copy)
fpu = first_point(U)
I_parent_U = imin+fpu-1
Do i = fpu, fpu+nx_cells, rhox
U_parent(I_parent_U) = U(i)
I_parent_U = I_parent_U+1
EndDo
! Update of T points (average)
fpt = first_point(T)
I_parent_T = imin+fpt-1
Do i = fpt, fpt+nx_cells-rhox+1, rhox
T_parent(I_parent_T) = sum(T(i:i+rhox-1))/rhox
I_parent_T = I_parent_T+1
EndDo
3. Odd refinement factor (3)¶

Location of points for an odd refinement factor
A centered coarse point (T) is updated by either a copy or an average of fine points of the same mesh while a non-centered point (U) is updated by a copy of the matching fine point.
4. Even refinement factor (2)¶

Location of points for an even refinement factor
Here, centered coarse point (T) is update by an average while a copy is not possible because of no matching fine point. Non-centered coarse point (U) is updated by a copy of the corresponding fine point.