Reading boundary conditions

Reads boundary conditions from CGNS file.

Table 64 Subroutine to use

Subroutine

Remarks

cg_iric_read_bc_count

Reads the number of boundary condition

cg_iric_read_bc_indicessize

Reads the number of nodes (or cells) where boundary condition is assigned.

cg_iric_read_bc_indices

Reads the indices of nodes (or cells) where boundary condition is assigned.

cg_iric_read_bc_integer

Reads a integer boundary condition value

cg_iric_read_bc_real

Reads a double-precision real boundary condition value

cg_iric_read_bc_realsingle

Reads a single-precision real boundary condition value

cg_iric_read_bc_string

Reads a string-type boundary condition value

cg_iric_read_bc_functionalsize

Reads a functional-type boundary condition value

cg_iric_read_bc_functional

Reads a functional-type boundary condition value

cg_iric_read_bc_functionalwithname

Reads a functional-type boundary condition value (with multiple values)

You can define multiple boundary conditions with the same type, to one grid. For example, you can define multiple inflows to a grid, and set discharge value for them independently.

List 96 shows an example to read boundary conditions. In this example the number of inflows is read by cg_iric_read_bc_count first, memories are allocated, and at last, the values are loaded.

The name of boundary condition user specifys on iRIC GUI can be loaded using cg_iric_read_bc_string. Please refer to 6.4.48 for detail.

List 96 Example of source code to read boundary conditions
 1program Sample8
 2  use iric
 3  implicit none
 4
 5  integer:: fin, ier, isize, jsize, ksize, i, j, k, aret
 6  integer:: condid, indexid
 7  integer:: condcount, indexlenmax, funcsizemax
 8  integer:: tmplen
 9  integer, dimension(:), allocatable:: condindexlen
10  integer, dimension(:,:,:), allocatable:: condindices
11  integer, dimension(:), allocatable:: intparam
12  double precision, dimension(:), allocatable:: realparam
13  character(len=200), dimension(:), allocatable:: stringparam
14  character(len=200):: tmpstr
15  integer, dimension(:), allocatable:: func_size
16  double precision, dimension(:,:), allocatable:: func_param;
17  double precision, dimension(:,:), allocatable:: func_value;
18
19  ! Opens CGNS file
20  call cg_iric_open('bctest.cgn', IRIC_MODE_MODIFY, fin, ier)
21  if (ier /=0) STOP "*** Open error of CGNS file ***"
22
23  ! Initializes iRIClib
24  call cg_iric_init(fin, ier)
25  if (ier /=0) STOP "*** Initialize error of CGNS file ***"
26
27  ! Reads the number of inflows
28  call cg_iric_read_bc_count(fin, 'inflow', condcount)
29  ! Allocate memory to load parameters
30  allocate(condindexlen(condcount), intparam(condcount), realparam(condcount))
31  allocate(stringparam(condcount), func_size(condcount))
32  print *, 'condcount ', condcount
33
34  ! Reads the number of grid node indices where boundary condition is assigned, and the size of functional-type condition.
35  indexlenmax = 0
36  funcsizemax = 0
37  do condid = 1, condcount
38    call cg_iric_read_bc_indicessize(fin, 'inflow', condid, condindexlen(condid), ier)
39    if (indexlenmax < condindexlen(condid)) then
40      indexlenmax = condindexlen(condid)
41    end if
42    call cg_iric_read_bc_functionalsize(fin, 'inflow', condid, 'funcparam', func_size(condid), ier);
43    if (funcsizemax < func_size(condid)) then
44      funcsizemax = func_size(condid)
45    end if
46  end do
47
48  ! Allocates memory to load grid node indices and functional-type boundary condition
49  allocate(condindices(condcount, 2, indexlenmax))
50  allocate(func_param(condcount, funcsizemax), func_value(condcount, funcsizemax))
51  ! Loads indices and boundary condition
52  do condid = 1, condcount
53    call cg_iric_read_bc_indices(fin, 'inflow', condid, condindices(condid:condid,:,:), ier)
54    call cg_iric_read_bc_integer(fin, 'inflow', condid, 'intparam', intparam(condid:condid), ier)
55    call cg_iric_read_bc_real(fin, 'inflow', condid, 'realparam', realparam(condid:condid), ier)
56    call cg_iric_read_bc_string(fin, 'inflow', condid, 'stringparam', tmpstr, ier)
57    stringparam(condid) = tmpstr
58    call cg_iric_read_bc_functional(fin, 'inflow', condid, 'funcparam', func_param(condid:condid,:), func_value(condid:condid,:), ier)
59  end do
60
61  ! Displays the boundary condition loaded.
62  do condid = 1, condcount
63    do indexid = 1, condindexlen(condid)
64      print *, 'condindices ', condindices(condid:condid,:,indexid:indexid)
65    end do
66    print *, 'intparam ', intparam(condid:condid)
67    print *, 'realparam ', realparam(condid:condid)
68    print *, 'stringparam ', stringparam(condid)
69    print *, 'funcparam X ', func_param(condid:condid, 1:func_size(condid))
70    print *, 'funcparam Y ', func_value(condid:condid, 1:func_size(condid))
71  end do
72
73  ! Closes CGNS file
74  call cg_iric_close(fin, ier)
75  stop
76end program Sample8