control.F90 Source File


This file depends on

sourcefile~~control.f90~~EfferentGraph sourcefile~control.f90 control.F90 sourcefile~core.f90 core.F90 sourcefile~control.f90->sourcefile~core.f90 sourcefile~input.f90 input.F90 sourcefile~control.f90->sourcefile~input.f90 sourcefile~iteration.f90 iteration.F90 sourcefile~control.f90->sourcefile~iteration.f90 sourcefile~openmp.f90 openmp.F90 sourcefile~control.f90->sourcefile~openmp.f90 sourcefile~time.f90 time.F90 sourcefile~control.f90->sourcefile~time.f90 sourcefile~allocate.f90 allocate.F90 sourcefile~core.f90->sourcefile~allocate.f90 sourcefile~check_range.f90 check_range.F90 sourcefile~core.f90->sourcefile~check_range.f90 sourcefile~deallocate.f90 deallocate.F90 sourcefile~core.f90->sourcefile~deallocate.f90 sourcefile~error.f90 error.F90 sourcefile~core.f90->sourcefile~error.f90 sourcefile~fortran_utils.f90 fortran_utils.F90 sourcefile~core.f90->sourcefile~fortran_utils.f90 sourcefile~string_utils.f90 string_utils.F90 sourcefile~core.f90->sourcefile~string_utils.f90 sourcefile~types.f90 types.F90 sourcefile~core.f90->sourcefile~types.f90 sourcefile~unique.f90 unique.F90 sourcefile~core.f90->sourcefile~unique.f90 sourcefile~vtk.f90 vtk.F90 sourcefile~core.f90->sourcefile~vtk.f90 sourcefile~vtk_constants.f90 vtk_constants.F90 sourcefile~core.f90->sourcefile~vtk_constants.f90 sourcefile~input_interface.f90 input_interface.F90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~iteration.f90->sourcefile~input.f90 sourcefile~calculate.f90 calculate.F90 sourcefile~iteration.f90->sourcefile~calculate.f90 sourcefile~openmp.f90->sourcefile~input.f90 sourcefile~time.f90->sourcefile~core.f90 sourcefile~time.f90->sourcefile~input.f90 sourcefile~allocate.f90->sourcefile~error.f90 sourcefile~density_interface.f90 density_interface.F90 sourcefile~calculate.f90->sourcefile~density_interface.f90 sourcefile~gcc_interface.f90 gcc_interface.F90 sourcefile~calculate.f90->sourcefile~gcc_interface.f90 sourcefile~hcf_interface.f90 hcf_interface.F90 sourcefile~calculate.f90->sourcefile~hcf_interface.f90 sourcefile~heat_capacity_interface.f90 heat_capacity_interface.F90 sourcefile~calculate.f90->sourcefile~heat_capacity_interface.f90 sourcefile~linalg.f90 linalg.F90 sourcefile~calculate.f90->sourcefile~linalg.f90 sourcefile~specific_heat_interface.f90 specific_heat_interface.F90 sourcefile~calculate.f90->sourcefile~specific_heat_interface.f90 sourcefile~thermal_conductivity_interface.f90 thermal_conductivity_interface.F90 sourcefile~calculate.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~deallocate.f90->sourcefile~error.f90 sourcefile~memory_stats_wrapper.f90 memory_stats_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~memory_stats_wrapper.f90 sourcefile~signal_flag_wrapper.f90 signal_flag_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~signal_flag_wrapper.f90 sourcefile~system_info_wrapper.f90 system_info_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~system_info_wrapper.f90 sourcefile~input_interface.f90->sourcefile~core.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~string_utils.f90->sourcefile~allocate.f90 sourcefile~array.f90 array.F90 sourcefile~types.f90->sourcefile~array.f90 sourcefile~gauss.f90 gauss.F90 sourcefile~types.f90->sourcefile~gauss.f90 sourcefile~matrix.f90 matrix.F90 sourcefile~types.f90->sourcefile~matrix.f90 sourcefile~pointer.f90 pointer.F90 sourcefile~types.f90->sourcefile~pointer.f90 sourcefile~variable.f90 variable.F90 sourcefile~types.f90->sourcefile~variable.f90 sourcefile~vector.f90 vector.F90 sourcefile~types.f90->sourcefile~vector.f90 sourcefile~unique.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~deallocate.f90 sourcefile~vtk.f90->sourcefile~types.f90 sourcefile~vtk.f90->sourcefile~unique.f90 sourcefile~vtk.f90->sourcefile~vtk_constants.f90 sourcefile~vtk_wrapper.f90 vtk_wrapper.F90 sourcefile~vtk.f90->sourcefile~vtk_wrapper.f90 sourcefile~vtu_wrapper.f90 vtu_wrapper.F90 sourcefile~vtk.f90->sourcefile~vtu_wrapper.f90 sourcefile~array.f90->sourcefile~allocate.f90 sourcefile~array.f90->sourcefile~deallocate.f90 sourcefile~density_interface.f90->sourcefile~core.f90 sourcefile~density_interface.f90->sourcefile~input.f90 sourcefile~gcc_interface.f90->sourcefile~core.f90 sourcefile~gcc_interface.f90->sourcefile~input.f90 sourcefile~hcf_interface.f90->sourcefile~core.f90 sourcefile~hcf_interface.f90->sourcefile~input.f90 sourcefile~heat_capacity_interface.f90->sourcefile~core.f90 sourcefile~heat_capacity_interface.f90->sourcefile~input_interface.f90 sourcefile~heat_capacity_interface.f90->sourcefile~density_interface.f90 sourcefile~matrix_ops.f90 matrix_ops.F90 sourcefile~linalg.f90->sourcefile~matrix_ops.f90 sourcefile~matvec.f90 matvec.F90 sourcefile~linalg.f90->sourcefile~matvec.f90 sourcefile~vector_ops.f90 vector_ops.F90 sourcefile~linalg.f90->sourcefile~vector_ops.f90 sourcefile~matrix_coo.f90 matrix_coo.F90 sourcefile~matrix.f90->sourcefile~matrix_coo.f90 sourcefile~matrix_crs.f90 matrix_crs.F90 sourcefile~matrix.f90->sourcefile~matrix_crs.f90 sourcefile~matrix_dense.f90 matrix_dense.F90 sourcefile~matrix.f90->sourcefile~matrix_dense.f90 sourcefile~matrix_interface.f90 matrix_interface.F90 sourcefile~matrix.f90->sourcefile~matrix_interface.f90 sourcefile~c_utils.f90 c_utils.F90 sourcefile~memory_stats_wrapper.f90->sourcefile~c_utils.f90 sourcefile~project_settings.f90->sourcefile~core.f90 sourcefile~signal_flag.f90 signal_flag.F90 sourcefile~signal_flag_wrapper.f90->sourcefile~signal_flag.f90 sourcefile~specific_heat_interface.f90->sourcefile~core.f90 sourcefile~specific_heat_interface.f90->sourcefile~input.f90 sourcefile~system_info_wrapper.f90->sourcefile~c_utils.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~core.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~input.f90 sourcefile~variable.f90->sourcefile~allocate.f90 sourcefile~c_utils.f90->sourcefile~signal_flag.f90 sourcefile~memory_stats.f90 memory_stats.F90 sourcefile~c_utils.f90->sourcefile~memory_stats.f90 sourcefile~system_info.f90 system_info.F90 sourcefile~c_utils.f90->sourcefile~system_info.f90 sourcefile~matrix_coo.f90->sourcefile~allocate.f90 sourcefile~matrix_coo.f90->sourcefile~deallocate.f90 sourcefile~matrix_coo.f90->sourcefile~matrix_interface.f90 sourcefile~matrix_crs.f90->sourcefile~allocate.f90 sourcefile~matrix_crs.f90->sourcefile~deallocate.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_interface.f90 sourcefile~matrix_dense.f90->sourcefile~allocate.f90 sourcefile~matrix_dense.f90->sourcefile~deallocate.f90 sourcefile~matrix_dense.f90->sourcefile~matrix_interface.f90 sourcefile~matrix_ops.f90->sourcefile~core.f90 sourcefile~matvec.f90->sourcefile~core.f90

Files dependent on this one

sourcefile~~control.f90~~AfferentGraph sourcefile~control.f90 control.F90 sourcefile~ftdss.f90 ftdss.F90 sourcefile~ftdss.f90->sourcefile~control.f90 sourcefile~hydraulic.f90 hydraulic.F90 sourcefile~ftdss.f90->sourcefile~hydraulic.f90 sourcefile~output.f90 output.F90 sourcefile~ftdss.f90->sourcefile~output.f90 sourcefile~properties.f90 properties.F90 sourcefile~ftdss.f90->sourcefile~properties.f90 sourcefile~thermal.f90 thermal.F90 sourcefile~ftdss.f90->sourcefile~thermal.f90 sourcefile~hydraulic_assemble.f90 hydraulic_assemble.F90 sourcefile~hydraulic_assemble.f90->sourcefile~control.f90 sourcefile~hydraulic_assemble.f90->sourcefile~properties.f90 sourcefile~hydraulic_interface.f90 hydraulic_interface.F90 sourcefile~hydraulic_interface.f90->sourcefile~control.f90 sourcefile~hydraulic_interface.f90->sourcefile~hydraulic_assemble.f90 sourcefile~hydraulic_interface.f90->sourcefile~properties.f90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_interface.f90->sourcefile~control.f90 sourcefile~output_interface.f90->sourcefile~properties.f90 sourcefile~properties_manager.f90 properties_manager.F90 sourcefile~properties_manager.f90->sourcefile~control.f90 sourcefile~thermal_interface.f90 thermal_interface.F90 sourcefile~thermal_interface.f90->sourcefile~control.f90 sourcefile~thermal_interface.f90->sourcefile~properties.f90 sourcefile~hydraulic.f90->sourcefile~hydraulic_interface.f90 sourcefile~hydraulic_crs.f90 hydraulic_crs.F90 sourcefile~hydraulic_crs.f90->sourcefile~hydraulic_interface.f90 sourcefile~output.f90->sourcefile~output_interface.f90 sourcefile~output_base.f90 output_base.F90 sourcefile~output_base.f90->sourcefile~output_interface.f90 sourcefile~output_observation.f90 output_observation.F90 sourcefile~output_observation.f90->sourcefile~output_interface.f90 sourcefile~output_overall_base.f90 output_overall_base.F90 sourcefile~output_overall_base.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtk.f90 output_overall_vtk.F90 sourcefile~output_overall_vtk.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtu.f90 output_overall_vtu.F90 sourcefile~output_overall_vtu.f90->sourcefile~output_interface.f90 sourcefile~output_system_logger.f90 output_system_logger.F90 sourcefile~output_system_logger.f90->sourcefile~output_interface.f90 sourcefile~properties.f90->sourcefile~properties_manager.f90 sourcefile~thermal.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_crs.f90 thermal_crs.F90 sourcefile~thermal_crs.f90->sourcefile~thermal_interface.f90

Source Code

module module_control
    use, intrinsic :: iso_fortran_env
    use :: module_core
    use :: control_time, only:type_time
    use :: control_iteration, only:type_iteration
    use :: control_openmp, only:initialize_openmp
    use :: module_input, only:type_input
    implicit none
    private

    public :: type_time
    public :: type_iteration
    public :: type_controls

    public :: calc_thermal, calc_hydraulic, calc_mechanical
    integer(int32), parameter :: calc_thermal = 1
    integer(int32), parameter :: calc_hydraulic = 2
    integer(int32), parameter :: calc_mechanical = 3

    type :: type_controls
        logical :: calculate_thermal
        logical :: calculate_hydraulic
        logical :: calculate_mechanical
        character(:), allocatable :: coupling_mode
        ! --- マテリアルごとのフラグ ---
        logical, allocatable :: thermal(:)
        logical, allocatable :: hydraulic(:)
        logical, allocatable :: mechanical(:)

        type(type_iteration) :: iteration
        type(type_time) :: time
    contains
        procedure :: initialize => initialize_type_controls
        procedure :: is_target => should_calculate_target
    end type type_controls

contains
    subroutine initialize_type_controls(self, input)
        implicit none
        class(type_controls), intent(inout) :: self
        class(type_input), intent(in) :: input

        integer(int32), allocatable :: unique_material_ids(:)
        integer(int32) :: ierr
        integer(int32) :: i, num_unique_regions, max_region_id
        integer(int32) :: current_material_id

        ierr = 0
        ! アクティブなマテリアル領域の情報を取得
        call input%geometry%vtk%get_active_region_info(unique_material_ids, ierr)
        if (ierr /= 0) return
        if (.not. allocated(unique_material_ids) .or. size(unique_material_ids) == 0) then
            ierr = -1 ! エラーコード
            print *, "Error: No active material regions found."
            stop 1
        end if

        num_unique_regions = size(unique_material_ids)
        max_region_id = maxval(unique_material_ids)

        ! 全体的な計算フラグを設定し、配列を割り当てて初期化
        if (input%basic%analysis_controls%calculate_thermal) then
            self%calculate_thermal = .true.
            allocate (self%thermal(max_region_id))
            self%thermal = .false. ! 配列全体を .false. で初期化
        else
            self%calculate_thermal = .false.
        end if

        if (input%basic%analysis_controls%calculate_hydraulic) then
            self%calculate_hydraulic = .true.
            allocate (self%hydraulic(max_region_id))
            self%hydraulic = .false.
        else
            self%calculate_hydraulic = .false.
        end if

        if (input%basic%analysis_controls%calculate_mechanical) then
            self%calculate_mechanical = .true.
            allocate (self%mechanical(max_region_id))
            self%mechanical = .false.
        else
            self%calculate_mechanical = .false.
        end if

        ! アクティブな各マテリアル領域に対してフラグを立てる
        do i = 1, num_unique_regions
            current_material_id = unique_material_ids(i)
            if (self%calculate_thermal) then
                ! materials配列の添え字として実際の材料IDを使用
                self%thermal(current_material_id) = input%basic%materials(i)%calculate_thermal
            end if

            if (self%calculate_hydraulic) then
                ! materials配列の添え字として実際の材料IDを使用
                self%hydraulic(current_material_id) = input%basic%materials(i)%calculate_hydraulic
            end if

            if (self%calculate_mechanical) then
                ! materials配列の添え字として実際の材料IDを使用
                self%mechanical(current_material_id) = input%basic%materials(i)%calculate_mechanical
            end if
        end do

        ! print *,

        ! coupling_modeの設定
        self%coupling_mode = input%basic%analysis_controls%coupling_mode

        ! call self%time%initialize(input)
        ! call self%iteration%initialize(input)

        call initialize_openmp(input)

        call deallocate_array(unique_material_ids)

    end subroutine initialize_type_controls

    ! -----------------------------------------------------------------
    ! <<< ここからが追加した関数 >>>
    ! 指定された物理現象と材料IDが計算対象かどうかを判定する
    ! -----------------------------------------------------------------
    pure function should_calculate_target(self, target_id, i_material) result(is_active)
        implicit none
        class(type_controls), intent(in) :: self
        integer, intent(in) :: target_id
        integer(int32), intent(in) :: i_material
        logical :: is_active

        is_active = .false.

        ! 高速な整数比較
        select case (target_id)
        case (calc_thermal)
#ifdef USE_DEBUG
            if (allocated(self%thermal)) then
                if (i_material <= ubound(self%thermal, 1)) then
#endif
                    is_active = self%thermal(i_material)
#ifdef USE_DEBUG
                end if
            end if
#endif

        case (calc_hydraulic)
#ifdef USE_DEBUG
            if (allocated(self%hydraulic)) then
                if (i_material <= ubound(self%hydraulic, 1)) then
#endif
                    is_active = self%hydraulic(i_material)
#ifdef USE_DEBUG
                end if
            end if
#endif

        case (calc_mechanical)
#ifdef USE_DEBUG
            if (allocated(self%mechanical)) then
                if (i_material <= ubound(self%mechanical, 1)) then
#endif
                    is_active = self%mechanical(i_material)
#ifdef USE_DEBUG
                end if
            end if
#endif
        end select
    end function should_calculate_target

end module module_control