地形データの読み込み

プロジェクトでインポートして格子生成に利用した地形データを読み込みます。 ソルバーで、河川測量データやポリゴンを直接読み込んで解析に使用したい場合に行います。 地形データを読み込む場合の手順は、以下の通りになります。

  1. CGNS ファイルから、プロジェクトで使用した地形データのファイル名などを読み込みます。

  2. 地形データファイルを開き、地形データを読み込みます。

表 64 利用する関数

関数

備考

cg_iric_read_geo_count_f

地形データの数を返す

cg_iric_read_geo_filename_f

地形データのファイル名と種類を返す

iric_geo_polygon_open_f

ポリゴンファイルを開く

iric_geo_polygon_read_integervalue_f

ポリゴンの値を整数で返す

iric_geo_polygon_read_realvalue_f

ポリゴンの値を実数で返す

iric_geo_polygon_read_pointcount_f

ポリゴンの頂点の数を返す

iric_geo_polygon_read_points_f

ポリゴンの頂点の座標を返す

iric_geo_polygon_read_holecount_f

ポリゴンに開いた穴の数を返す

iric_geo_polygon_read_holepointcount_f

ポリゴンの穴の頂点の数を返す

iric_geo_polygon_read_holepoints_f

ポリゴンの穴の頂点の座標を返す

iric_geo_polygon_close_f

ポリゴンファイルを閉じる

iric_geo_riversurvey_open_f

河川測量データを開く

iric_geo_riversurvey_read_count_f

河川横断線の数を返す

iric_geo_riversurvey_read_position_f

横断線の中心点の座標を返す

iric_geo_riversurvey_read_direction_f

横断線の向きを返す

iric_geo_riversurvey_read_name_f

横断線の名前を文字列として返す

iric_geo_riversurvey_read_realname_f

横断線の名前を実数値として返す

iric_geo_riversurvey_read_leftshift_f

横断線の標高データのシフト量を返す

iric_geo_riversurvey_read_altitudecount_f

横断線の標高データの数を返す

iric_geo_riversurvey_read_altitudes_f

横断線の標高データを返す

iric_geo_riversurvey_read_fixedpointl_f

横断線の左岸延長線のデータを返す

iric_geo_riversurvey_read_fixedpointr_f

横断線の右岸延長線のデータを返す

iric_geo_riversurvey_read_watersurfaceelevation_f

横断線での水面標高のデータを返す

iric_geo_riversurvey_close_f

河川測量データを閉じる

地形データのうち、ポリゴンを読み込む処理の記述例を リスト 97 に、 河川測量データを読み込む処理の記述例を リスト 98 にそれぞれ示します。

リスト 97 ポリゴンを読み込む処理の記述例
 1program TestPolygon
 2  implicit none
 3  include 'cgnslib_f.h'
 4  include 'iriclib_f.h'
 5  integer:: fin, ier
 6  integer:: icount, istatus
 7
 8  integer:: geoid
 9  integer:: elevation_geo_count
10  character(len=1000):: filename
11  integer:: geotype
12  integer:: polygonid
13  double precision:: polygon_value
14  integer:: region_pointcount
15  double precision, dimension(:), allocatable:: region_pointx
16  double precision, dimension(:), allocatable:: region_pointy
17  integer:: hole_id
18  integer:: hole_count
19  integer:: hole_pointcount
20  double precision, dimension(:), allocatable:: hole_pointx
21  double precision, dimension(:), allocatable:: hole_pointy
22
23
24  ! 計算データファイルを開く
25  call cg_open_f("test.cgn", CG_MODE_MODIFY, fin, ier)
26  if (ier /=0) stop "*** Open error of CGNS file ***"
27
28  ! iRIClib の初期化
29  call cg_iric_init_f(fin, ier)
30
31  ! 地形データの数を取得
32  call cg_iric_read_geo_count_f("Elevation", elevation_geo_count, ier)
33
34  do geoid = 1, elevation_geo_count
35    call cg_iric_read_geo_filename_f('Elevation', geoid, &
36      filename, geotype, ier)
37    if (geotype .eq. iRIC_GEO_POLYGON) then
38      call iric_geo_polygon_open_f(filename, polygonid, ier)
39      call iric_geo_polygon_read_realvalue_f(polygonid, polygon_value, ier)
40      print *, polygon_value
41      call iric_geo_polygon_read_pointcount_f(polygonid, region_pointcount, ier)
42      allocate(region_pointx(region_pointcount))
43      allocate(region_pointy(region_pointcount))
44      call iric_geo_polygon_read_points_f(polygonid, region_pointx, region_pointy, ier)
45      print *, 'region_x: ', region_pointx
46      print *, 'region_y: ', region_pointy
47      deallocate(region_pointx)
48      deallocate(region_pointy)
49      call iric_geo_polygon_read_holecount_f(polygonid, hole_count, ier)
50      print *, 'hole count: ', hole_count
51      do hole_id = 1, hole_count
52        print *, 'hole ', hole_id
53        call iric_geo_polygon_read_holepointcount_f(polygonid, hole_id, hole_pointcount, ier)
54        print *, 'hole pointcount: ', hole_pointcount
55        allocate(hole_pointx(hole_pointcount))
56        allocate(hole_pointy(hole_pointcount))
57        call iric_geo_polygon_read_holepoints_f(polygonid, hole_id, hole_pointx, hole_pointy, ier)
58        print *, 'hole_x: ', hole_pointx
59        print *, 'hole_y: ', hole_pointy
60        deallocate(hole_pointx)
61        deallocate(hole_pointy)
62      end do
63      call iric_geo_polygon_close_f(polygonid, ier)
64    end if
65  end do
66
67  ! 計算データファイルを閉じる
68  call cg_close_f(fin, ier)
69  stop
70end program TestPolygon
リスト 98 河川測量データを読み込む処理の記述例
 1program TestRiverSurvey
 2  implicit none
 3  include 'cgnslib_f.h'
 4  include 'iriclib_f.h'
 5  integer:: fin, ier
 6  integer:: icount, istatus
 7
 8  integer:: geoid
 9  integer:: elevation_geo_count
10  character(len=1000):: filename
11  integer:: geotype
12  integer:: rsid
13  integer:: xsec_count
14  integer:: xsec_id
15  character(len=20):: xsec_name
16  double precision:: xsec_x
17  double precision:: xsec_y
18  integer:: xsec_set
19  integer:: xsec_index
20  double precision:: xsec_leftshift
21  integer:: xsec_altid
22  integer:: xsec_altcount
23  double precision, dimension(:), allocatable:: xsec_altpos
24  double precision, dimension(:), allocatable:: xsec_altheight
25  integer, dimension(:), allocatable:: xsec_altactive
26  double precision:: xsec_wse
27
28  ! 計算データファイルを開く
29  call cg_open_f("test.cgn", CG_MODE_MODIFY, fin, ier)
30  if (ier /=0) stop "*** Open error of CGNS file ***"
31
32  ! iRIClib の初期化
33  call cg_iric_init_f(fin, ier)
34
35  ! 地形データの数を取得
36  call cg_iric_read_geo_count_f("Elevation", elevation_geo_count, ier)
37
38  do geoid = 1, elevation_geo_count
39    call cg_iric_read_geo_filename_f('Elevation', geoid, &
40      filename, geotype, ier)
41    if (geotype .eq. iRIC_GEO_RIVERSURVEY) then
42      call iric_geo_riversurvey_open_f(filename, rsid, ier)
43      call iric_geo_riversurvey_read_count_f(rsid, xsec_count, ier)
44      do xsec_id = 1, xsec_count
45        call iric_geo_riversurvey_read_name_f(rsid, xsec_id, xsec_name, ier)
46        print *, 'xsec ', xsec_name
47        call iric_geo_riversurvey_read_position_f(rsid, xsec_id, xsec_x, xsec_y, ier)
48        print *, 'position: ', xsec_x, xsec_y
49        call iric_geo_riversurvey_read_direction_f(rsid, xsec_id, xsec_x, xsec_y, ier)
50        print *, 'direction: ', xsec_x, xsec_y
51        call iric_geo_riversurvey_read_leftshift_f(rsid, xsec_id, xsec_leftshift, ier)
52        print *, 'leftshift: ', xsec_leftshift
53        call iric_geo_riversurvey_read_altitudecount_f(rsid, xsec_id, xsec_altcount, ier)
54        print *, 'altitude count: ', xsec_altcount
55        allocate(xsec_altpos(xsec_altcount))
56        allocate(xsec_altheight(xsec_altcount))
57        allocate(xsec_altactive(xsec_altcount))
58        call iric_geo_riversurvey_read_altitudes_f( &
59          rsid, xsec_id, xsec_altpos, xsec_altheight, xsec_altactive, ier)
60        do xsec_altid = 1, xsec_altcount
61          print *, 'Altitude ', xsec_altid, ': ', &
62            xsec_altpos(xsec_altid:xsec_altid), ', ', &
63            xsec_altheight(xsec_altid:xsec_altid), ', ', &
64            xsec_altactive(xsec_altid:xsec_altid)
65        end do
66        deallocate(xsec_altpos, xsec_altheight, xsec_altactive)
67        call iric_geo_riversurvey_read_fixedpointl_f( &
68          rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
69        print *, 'FixedPointL: ', xsec_set, xsec_x, xsec_y, xsec_index
70        call iric_geo_riversurvey_read_fixedpointr_f( &
71          rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
72        print *, 'FixedPointR: ', xsec_set, xsec_x, xsec_y, xsec_index
73        call iric_geo_riversurvey_read_watersurfaceelevation_f( &
74          rsid, xsec_id, xsec_set, xsec_wse, ier)
75        print *, 'WaterSurfaceElevation: ', xsec_set, xsec_wse
76      end do
77      call iric_geo_riversurvey_close_f(rsid, ier)
78    end if
79  end do
80
81  ! 計算データファイルを閉じる
82  call cg_close_f(fin, ier)
83  stop
84end program TestRiverSurvey