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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | program SampleProgram implicit none include 'cgnslib_f.h' integer:: fin, ier integer:: icount, istatus integer:: imax, jmax integer:: elev_on double precision:: elev_value double precision, dimension(:,:), allocatable::grid_x, grid_y double precision, dimension(:,:), elevation character(200)::condFile icount = nargs() if ( icount.eq.2 ) then call getarg(1, condFile, istatus) else stop "Input File not specified." endif ! Opens grid generating data file. call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier) if (ier /=0) stop "*** Open error of CGNS file ***" ! Initializes iRIClib. ier will be 1, but that is not a problem. call cg_iric_init_f(fin, ier) ! Loads grid generating condition ! To make it simple, no error handling codes are written. call cg_iric_read_integer_f("imax", imax, ier) call cg_iric_read_integer_f("jmax", jmax, ier) call cg_iric_read_integer_f("elev_on", elev_on, ier) call cg_iric_read_real_f("elev_value", elev_value, ier) ! Allocate memory for creating grid allocate(grid_x(imax,jmax), grid_y(imax,jmax) allocate(elevation(imax,jmax)) ! Generate grid do i = 1, isize do j = 1, jsize grid_x(i, j) = i grid_y(i, j) = j elevation(i, j) = elev_value end do end do ! Outputs grid cg_iric_writegridcoord2d_f(imax, jmax, grid_x, grid_y, ier) if (elev_on == 1) then cg_iric_write_grid_real_node_f("Elevation", elevation, ier); end if ! Closes grid generating data file. call cg_close_f(fin, ier) end program SampleProgram |