initialize_output_overall_vtu Module Subroutine

module subroutine initialize_output_overall_vtu(self, Input, Coordinate, Domain)

Arguments

Type IntentOptional 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

Calls

proc~~initialize_output_overall_vtu~~CallsGraph proc~initialize_output_overall_vtu initialize_output_overall_vtu interface~allocate_array allocate_array proc~initialize_output_overall_vtu->interface~allocate_array proc~type_dp_3d_initialize type_dp_3d%type_dp_3d_initialize proc~initialize_output_overall_vtu->proc~type_dp_3d_initialize proc~allocate_rank1_int16 allocate_rank1_int16 interface~allocate_array->proc~allocate_rank1_int16 proc~allocate_rank1_int32 allocate_rank1_int32 interface~allocate_array->proc~allocate_rank1_int32 proc~allocate_rank1_int64 allocate_rank1_int64 interface~allocate_array->proc~allocate_rank1_int64 proc~allocate_rank1_int8 allocate_rank1_int8 interface~allocate_array->proc~allocate_rank1_int8 proc~allocate_rank1_logical1 allocate_rank1_logical1 interface~allocate_array->proc~allocate_rank1_logical1 proc~allocate_rank1_logical4 allocate_rank1_logical4 interface~allocate_array->proc~allocate_rank1_logical4 proc~allocate_rank1_logical8 allocate_rank1_logical8 interface~allocate_array->proc~allocate_rank1_logical8 proc~allocate_rank1_real128 allocate_rank1_real128 interface~allocate_array->proc~allocate_rank1_real128 proc~allocate_rank1_real32 allocate_rank1_real32 interface~allocate_array->proc~allocate_rank1_real32 proc~allocate_rank1_real64 allocate_rank1_real64 interface~allocate_array->proc~allocate_rank1_real64 proc~allocate_rank2_int16 allocate_rank2_int16 interface~allocate_array->proc~allocate_rank2_int16 proc~allocate_rank2_int32 allocate_rank2_int32 interface~allocate_array->proc~allocate_rank2_int32 proc~allocate_rank2_int64 allocate_rank2_int64 interface~allocate_array->proc~allocate_rank2_int64 proc~allocate_rank2_int8 allocate_rank2_int8 interface~allocate_array->proc~allocate_rank2_int8 proc~allocate_rank2_logical1 allocate_rank2_logical1 interface~allocate_array->proc~allocate_rank2_logical1 proc~allocate_rank2_logical4 allocate_rank2_logical4 interface~allocate_array->proc~allocate_rank2_logical4 proc~allocate_rank2_logical8 allocate_rank2_logical8 interface~allocate_array->proc~allocate_rank2_logical8 proc~allocate_rank2_real128 allocate_rank2_real128 interface~allocate_array->proc~allocate_rank2_real128 proc~allocate_rank2_real32 allocate_rank2_real32 interface~allocate_array->proc~allocate_rank2_real32 proc~allocate_rank2_real64 allocate_rank2_real64 interface~allocate_array->proc~allocate_rank2_real64 proc~type_dp_3d_initialize->interface~allocate_array proc~error_message error_message proc~allocate_rank1_int16->proc~error_message proc~allocate_rank1_int32->proc~error_message proc~allocate_rank1_int64->proc~error_message proc~allocate_rank1_int8->proc~error_message proc~allocate_rank1_logical1->proc~error_message proc~allocate_rank1_logical4->proc~error_message proc~allocate_rank1_logical8->proc~error_message proc~allocate_rank1_real128->proc~error_message proc~allocate_rank1_real32->proc~error_message proc~allocate_rank1_real64->proc~error_message proc~allocate_rank2_int16->proc~error_message proc~allocate_rank2_int32->proc~error_message proc~allocate_rank2_int64->proc~error_message proc~allocate_rank2_int8->proc~error_message proc~allocate_rank2_logical1->proc~error_message proc~allocate_rank2_logical4->proc~error_message proc~allocate_rank2_logical8->proc~error_message proc~allocate_rank2_real128->proc~error_message proc~allocate_rank2_real32->proc~error_message proc~allocate_rank2_real64->proc~error_message log_error log_error proc~error_message->log_error

Called by

proc~~initialize_output_overall_vtu~~CalledByGraph proc~initialize_output_overall_vtu initialize_output_overall_vtu interface~initialize_output_overall_vtu type_output_overall%initialize_output_overall_vtu interface~initialize_output_overall_vtu->proc~initialize_output_overall_vtu proc~initialize_input_type_output_overall initialize_input_type_output_overall proc~initialize_input_type_output_overall->interface~initialize_output_overall_vtu interface~initialize_input_type_output_overall type_output_overall%initialize_input_type_output_overall interface~initialize_input_type_output_overall->proc~initialize_input_type_output_overall

Source Code

    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