Complex type

Abstract

A complex type is a combination of several of the conditions described before, such as string, integer, and real number.

Definition

List 96 Example of a complex type condition definition
 1<Item name="fish" caption="Fishes">
 2  <Definition valueType="complex" >
 3    <Item name="type" caption="Type">
 4      <Definition valueType="integer" option="true" default="1">
 5        <Enumerations>
 6          <Enumeration value="1" caption="Fish"/>
 7          <Enumeration value="2" caption="Crub"/>
 8          <Enumeration value="3" caption="Shrimp"/>
 9        </Enumerations>
10      </Definition>
11    </Item>
12    <Item name="size" caption="Size">
13      <Definition valueType="real" default="0.13" />
14    </Item>
15    <Item name="remarks" caption="Remarks">
16      <Definition valueType="string" default="" />
17    </Item>
18  </Definition>
19</Item>

Example of widget

../_images/widget_example_complex.png

Figure 59 Widget example of Complex type

Example code to read data

Calculation condition, Grid generating condition

FORTRAN

List 97 Code example to load complex type condition (for calculation conditions and grid generating conditions) FORTRAN
 1integer:: ier, fish_count
 2integer, dimension(:), allocatable:: fish_type
 3double precision, dimension(:), allocatable:: fish_size
 4character(200), dimension(:), allocatable:: fish_remarks
 5integer:: i
 6
 7! Read size
 8call cg_iRIC_Read_Complex_Count(fid, "fish", fish_count, ier)
 9! Allocate memory
10allocate(fish_type(fish_count))
11allocate(fish_size(fish_count))
12allocate(fish_remarks(fish_count))
13! Load values into the allocated memory
14do i = 1, fish_count
15  call cg_iRIC_Read_Complex_Integer(fid, "fish", i, "type", fish_type(i), ier)
16  call cg_iRIC_Read_Complex_Real(fid, "fish", i, "size", fish_size(i), ier)
17  call cg_iRIC_Read_Complex_String(fid, "fish", i, "remarks", fish_remarks(i), ier)
18end do

C/C++

List 98 Code example to load complex type condition (for calculation conditions and grid generating conditions) C++
 1int ier, fish_count;
 2std::vector<int> fish_type;
 3std::vector<double> fish_size;
 4int strlen;
 5std::vector<std::vector<char> > fish_remarks;
 6
 7// Read size
 8ier = cg_iRIC_Read_Complex_Count(fid, "fish", &fish_count)
 9// Allocate memory
10fish_type.assign(fish_count, 0);
11fish_size.assign(fish_count, 0);
12fish_remarks.assign(fish_count, "");
13// Load values into the allocated memory
14for (int i = 0; i < fish_count; ++i) {
15  ier = cg_iRIC_Read_Complex_Integer(fid, "fish", i + 1, "type", &fish_type[i]);
16  call cg_iRIC_Read_Complex_Real(fid, "fish", i + 1, "size", &fish_size[i]);
17  auto& remarks = fish_remarks[i];
18  call cg_iRIC_Read_Complex_StringLen(fid, "fish", i + 1, "remarks", &strlen);
19  remarks.assign(strlen + 1, 0);
20  call cg_iRIC_Read_Complex_String(fid, "fish", i + 1, "remarks", remarks.data());
21}

Python

List 99 Code example to load complex type condition (for calculation conditions and grid generating conditions) Python
 1# Read size
 2fish_count = cg_iRIC_Read_Complex_Count(fid, "fish")
 3# Prepare list
 4fish_type = list()
 5fish_size = list()
 6fish_remarks = list()
 7
 8for i in range(fish_count):
 9  fish_type.append(cg_iRIC_Read_Complex_Integer(fid, "fish", i + 1, "type"))
10  fish_size.append(cg_iRIC_Read_Complex_Real(fid, "fish", i + 1, "size"))
11  fish_remarks.append(cg_iRIC_Read_Complex_String(fid, "fish", i + 1, "remarks"))

Reading name

Name of items of Complex type (for example, “Item2” in case of Figure 59) can be read using cg_iRIC_Read_Complex_String, specifying “_caption” as argument “name”.

Please refer to cg_iRIC_Read_Complex_String for detailed description about arguments.