Adding codes to output a grid

Adds codes to output grid.

First, add codes to output a very simple grid, to check whether the program works together with iRIC successfully.

List 20 shows the source code with lines to output grid. The added lines are shown with highlight.

List 20 The source code with lines to output grid
 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
program SampleProgram
  implicit none
  include 'cgnslib_f.h'

  integer:: fin, ier
  integer:: icount, istatus
  integer:: imax, jmax
  double precision, dimension(:,:), allocatable::grid_x, grid_y
  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)

  imax = 10
  jmax = 10

  ! Allocate memory for creating grid
  allocate(grid_x(imax,jmax), grid_y(imax,jmax)

  ! Generate grid
  do i = 1, imax
    do j = 1, jmax
      grid_x(i, j) = i
      grid_y(i, j) = j
    end do
  end do

  ! Outputs grid
  cg_iric_writegridcoord2d_f(imax, jmax, grid_x, grid_y, ier)

  ! Closes grid generating data file.
  call cg_close_f(fin, ier)
end program SampleProgram

When it was compiled successfully, copy the executable file to the folder you created in Creating a folder, and rename it into the name you specified as [executable] attribute in Defining basic information. This time, rename into “generator.exe”. Copy the DLL files into that folder, that is need to run the grid generating program.

Now check whether the grid generating program can be launched from iRIC successfully.

Starts a new project with solver “Nays2DH”, and select “Sample Grid Creator” as the grid generating algorithm like in Defining basic information. The [Grid Creation] dialog (Figure 36) will open.

../_images/gridgen_cond_dialog_for_testing.png

Figure 36 The [Grid Creation] dialog

Click on [Create Grid], and a 10 x 10 grid will be created and loaded on the pre-processing window (Figure 37).

../_images/preprocessor_after_gridgen.png

Figure 37 The pre-processing window after creating grid

Refer to Outputting calculation grids for the detail of subroutines to output grids. Note that in Outputting calculation grids the subroutines to output three-dimensional grids are listed, but they can not be used in grid generating programs. In grid generating programs, only subroutines to output two-dimensional grids can be used.