Investigating grid

Open a handle to a grid, and investigate the grid, like calculate the area of cells in grid, find the cell that includes a certain coordinate. After investigating the grid, close the handle to the grid.

The functionis in this group can be used for both structured grids and unstructured grids. The procedure to investigate grid is as below:

  1. Open the grid contained in the CGNS file, and get the handle to the grid.

  2. Investigate the grid by calling the functions in the group, with then handle as an argument.

  3. After the investigation, close the grid with the handle.

Table 65 Subroutine to use

Subroutine

Remarks

cg_iric_read_grid2d_open

Opens the grid

cg_iric_read_sol_grid2d_open

Opens the grid in calculation result

cg_iric_read_grid2d_close

Closes the grid

cg_iric_read_grid2d_cellarea

Calculates and returns the area of a cell in the grid

cg_iric_read_grid2d_findcell

Find and returns the ID of the cell that includes the specified coordinates

cg_iric_read_grid2d_cellnodecount

Returns the number of nodes in the specified cell

cg_iric_read_grid2d_interpolate

Returns the information to interpolate the value at the specified coordinates, with the values defined at grid nodes

cg_iric_read_grid2d_interpolatewithcell

Returns the information to interpolate the value at the specified coordinates, with the values defined at grid nodes

List 97 shows an example of investigating the grid.

List 97 Example source code of investigating the grid
 1program TestX
 2  use iric
 3  implicit none
 4
 5  integer:: i, ok
 6  integer:: fin, g_handle, ier
 7  integer:: nodecount, cellnodecount,
 8  double precision: area
 9  double precision, dimension(:), allocatable:: depth
10  integer, dimension(4):: nodeid_arr
11  double precision:: depth_interpolated
12  double precision, dimension(4):: weights_arr
13
14  ! Opens CGNS file
15  call cg_iric_open("test.cgn", IRIC_MODE_MODIFY, fin, ier)
16  if (ier /=0) stop "*** Open error of CGNS file ***"
17
18  ! Opens the grid
19  call cg_iric_read_grid2d_open(fin, g_handle, ier)
20
21  ! Calculates the area of the cell
22  call cg_iric_read_grid2d_cellarea(g_handle, 1, area, ier)
23
24  ! Gets the number of nodes in the grid
25  call cg_iric_read_grid_nodecount(fin, nodecount, ier)
26
27  ! Allocate memory
28  allocate(depth(nodecount))
29
30  ! Gets the values of calculation result 'depth'
31  call cg_iric_read_sol_node_real(fin, 1, 'depth', depth, ier)
32
33  ! Gets the informationi to interpolate value at coordinates (10.8, 12.5)
34  call cg_iric_read_grid2d_interpolate(g_handle, 10.8, 12.5, ok, cellnodecount, nodeid_arr, weights_arr)
35
36  ! Calculates the interpolated value of depth at coordinates (10.8, 12.5)
37  depth_interpolated = 0
38  do i = 1, cellnodecount
39    depth_interpolated = depth_interpolated + depth(nodeid_arr(i)) * weights_arr(i)
40  end do
41
42  ! Closes the grid
43  call cg_iric_read_grid2d_close(g_handle, ier)
44
45  deallocate(depth)
46  stop
47end program TestX