Adding codes to load grid generating condition¶
Adds codes to load grid generating conditions.
iRIC will output grid generating conditions according to the grid generating program definition file. So, the grid generating program have to load them to coincide with the description in the grid generating program definition file.
List 21 shows the source code with lines to load grid generating condition. The added lines are shown with highlight. Note that the arguments passed to load grid generating conditions are the same to the [name] attributes of Items defined in Defining grid generating conditions.
When it is compiled successfully, create a grid from iRIC in the procedure same to Adding codes to output a grid, and the grid will be created with the condition you specified on [Grid Creation] dialog.
Refer to Examples of calculation conditions, boundary conditions, and grid generating condition for the relation between definitions of grid generating condition and the iRIClib subroutines to load them. Refer to Reading calculation conditions for the detail of subroutines to load grid generating conditions.
1program SampleProgram
2 implicit none
3 include 'cgnslib_f.h'
4
5 integer:: fin, ier
6 integer:: icount, istatus
7 integer:: imax, jmax
8 integer:: elev_on
9 double precision:: elev_value
10 double precision, dimension(:,:), allocatable::grid_x, grid_y
11 double precision, dimension(:,:), elevation
12
13 character(200)::condFile
14
15 icount = nargs()
16 if ( icount.eq.2 ) then
17 call getarg(1, condFile, istatus)
18 else
19 stop "Input File not specified."
20 endif
21
22 ! Opens grid generating data file.
23 call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
24 if (ier /=0) stop "*** Open error of CGNS file ***"
25
26 ! Initializes iRIClib. ier will be 1, but that is not a problem.
27 call cg_iric_init_f(fin, ier)
28
29 ! Loads grid generating condition
30 ! To make it simple, no error handling codes are written.
31 call cg_iric_read_integer_f("imax", imax, ier)
32 call cg_iric_read_integer_f("jmax", jmax, ier)
33 call cg_iric_read_integer_f("elev_on", elev_on, ier)
34 call cg_iric_read_real_f("elev_value", elev_value, ier)
35
36 ! Allocate memory for creating grid
37 allocate(grid_x(imax,jmax), grid_y(imax,jmax)
38 allocate(elevation(imax,jmax))
39
40 ! Generate grid
41 do i = 1, isize
42 do j = 1, jsize
43 grid_x(i, j) = i
44 grid_y(i, j) = j
45 elevation(i, j) = elev_value
46 end do
47 end do
48
49 ! Outputs grid
50 cg_iric_writegridcoord2d_f(imax, jmax, grid_x, grid_y, ier)
51 if (elev_on == 1) then
52 cg_iric_write_grid_real_node_f("Elevation", elevation, ier);
53 end if
54
55 ! Closes grid generating data file.
56 call cg_close_f(fin, ier)
57end program SampleProgram