Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(type_output_overall), | intent(inout) | :: | self | |||
type(type_input), | intent(in) | :: | Input | |||
type(type_dp_3d), | intent(in) | :: | Coordinate | |||
type(type_domain), | intent(inout) | :: | Domain |
module subroutine initialize_output_overall_vtu(self, Input, Coordinate, Domain) implicit none class(type_output_overall), intent(inout) :: self type(Type_Input), intent(in) :: Input type(type_dp_3d), intent(in) :: Coordinate type(type_domain), intent(inout) :: Domain integer(int32) :: i, j integer(int32) :: total_connectivity_size, current_offset, start_index self%vtk%num_points = input%geometry%vtk%num_points self%vtk%num_cells = input%geometry%vtk%num_total_cells call self%vtk%coordinate%initialize(self%vtk%num_points) self%vtk%coordinate = input%geometry%vtk%POINTS ! --- offset と CellType 配列を確保 --- call allocate_array(self%vtk%offsets, self%vtk%num_cells) call allocate_array(self%vtk%cell_types, self%vtk%num_cells) ! ★★★ 修正箇所: offset配列を累積和として正しく計算 ★★★ current_offset = 0 do i = 1, self%vtk%num_cells self%vtk%cell_types(i) = input%geometry%vtk%CELLS(i)%cell_type current_offset = current_offset + input%geometry%vtk%CELLS(i)%num_nodes_in_cell self%vtk%offsets(i) = current_offset end do ! --- connectivity配列を正しい合計サイズで確保 --- if (self%vtk%num_cells > 0) then total_connectivity_size = self%vtk%offsets(self%vtk%num_cells) else total_connectivity_size = 0 end if call allocate_array(self%VTK%connectivities, total_connectivity_size) ! ★★★ 修正箇所: 正しいオフセットを用いてconnectivity配列にデータを格納 ★★★ do i = 1, self%vtk%num_cells ! 各セルの書き込み開始インデックスを計算 if (i == 1) then start_index = 0 else start_index = self%vtk%offsets(i - 1) end if ! 各セルの接続情報をコピー (VTKは0-based indexなので-1する) do j = 1, input%geometry%vtk%CELLS(i)%num_nodes_in_cell self%VTK%connectivities(start_index + j) = input%geometry%vtk%CELLS(i)%connectivity(j) - 1 end do end do if (associated(self%write_fields)) nullify (self%write_fields) self%write_fields => output_overall_vtu_fields if (associated(self%write_cell)) nullify (self%write_cell) self%write_cell => output_overall_vtu_cell end subroutine initialize_output_overall_vtu