materials_manager.F90 Source File


This file depends on

sourcefile~~materials_manager.f90~~EfferentGraph sourcefile~materials_manager.f90 materials_manager.F90 sourcefile~calculate.f90 calculate.F90 sourcefile~materials_manager.f90->sourcefile~calculate.f90 sourcefile~input.f90 input.F90 sourcefile~materials_manager.f90->sourcefile~input.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~heat_capacity_interface.f90 heat_capacity_interface.F90 sourcefile~calculate.f90->sourcefile~heat_capacity_interface.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~input_interface.f90 input_interface.F90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~density_interface.f90->sourcefile~input.f90 sourcefile~core.f90 core.F90 sourcefile~density_interface.f90->sourcefile~core.f90 sourcefile~gcc_interface.f90->sourcefile~input.f90 sourcefile~heat_capacity_interface.f90->sourcefile~density_interface.f90 sourcefile~heat_capacity_interface.f90->sourcefile~input_interface.f90 sourcefile~heat_capacity_interface.f90->sourcefile~core.f90 sourcefile~input_interface.f90->sourcefile~core.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~specific_heat_interface.f90->sourcefile~input.f90 sourcefile~specific_heat_interface.f90->sourcefile~core.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~input.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~core.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~project_settings.f90->sourcefile~core.f90 sourcefile~allocate.f90->sourcefile~error.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~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~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~unique.f90 sourcefile~vtk.f90->sourcefile~vtk_constants.f90 sourcefile~vtk.f90->sourcefile~array.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~c_utils.f90 c_utils.F90 sourcefile~memory_stats_wrapper.f90->sourcefile~c_utils.f90 sourcefile~signal_flag.f90 signal_flag.F90 sourcefile~signal_flag_wrapper.f90->sourcefile~signal_flag.f90 sourcefile~system_info_wrapper.f90->sourcefile~c_utils.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

Files dependent on this one

sourcefile~~materials_manager.f90~~AfferentGraph sourcefile~materials_manager.f90 materials_manager.F90 sourcefile~properties.f90 properties.F90 sourcefile~properties.f90->sourcefile~materials_manager.f90 sourcefile~properties_manager.f90 properties_manager.F90 sourcefile~properties.f90->sourcefile~properties_manager.f90 sourcefile~properties_manager.f90->sourcefile~materials_manager.f90 sourcefile~ftdss.f90 ftdss.F90 sourcefile~ftdss.f90->sourcefile~properties.f90 sourcefile~thermal_interface.f90 thermal_interface.F90 sourcefile~ftdss.f90->sourcefile~thermal_interface.f90 sourcefile~output.f90 output.F90 sourcefile~ftdss.f90->sourcefile~output.f90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_interface.f90->sourcefile~properties.f90 sourcefile~thermal_interface.f90->sourcefile~properties.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~thermal.f90 thermal.F90 sourcefile~thermal.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_3phase.f90 thermal_3phase.F90 sourcefile~thermal_3phase.f90->sourcefile~thermal_interface.f90

Source Code

module properties_material_manager
    use, intrinsic :: iso_fortran_env, only: int32, real64
    use :: module_input, only:Type_input
    use :: module_calculate, only:holder_gccs, holder_wrfs, holder_dens, holder_sphs, holder_vhcs, holder_thcs, & !&
                                  abst_gcc, abst_wrf, abst_den, abst_sph, abst_vhc, abst_thc

    implicit none
    private

    public :: type_material_manager

    type :: type_material_manager
        private
        type(holder_thcs), allocatable :: thc(:)
        type(holder_dens), allocatable :: den(:)
        type(holder_sphs), allocatable :: sph(:)
        type(holder_vhcs), allocatable :: vhc(:)
        type(holder_gccs), allocatable :: gcc(:)
        type(holder_wrfs), allocatable :: wrf(:)

        integer(int32), allocatable :: region_id_map(:)
    contains
        procedure, public, pass(self) :: initialize

        procedure, private, pass(self) :: get_thc_holder
        procedure, private, pass(self) :: get_thc_ptr
        generic, public :: get_thc => get_thc_holder, get_thc_ptr

        procedure, private, pass(self) :: get_den_holder
        procedure, private, pass(self) :: get_den_ptr
        generic, public :: get_den => get_den_holder, get_den_ptr

        procedure, private, pass(self) :: get_sph_holder
        procedure, private, pass(self) :: get_sph_ptr
        generic, public :: get_sph => get_sph_holder, get_sph_ptr

        procedure, private, pass(self) :: get_vhc_holder
        procedure, private, pass(self) :: get_vhc_ptr
        generic, public :: get_vhc => get_vhc_holder, get_vhc_ptr

        procedure, private, pass(self) :: get_gcc_holder
        procedure, private, pass(self) :: get_gcc_ptr
        generic, public :: get_gcc => get_gcc_holder, get_gcc_ptr

        procedure, private, pass(self) :: get_wrf_holder
        procedure, private, pass(self) :: get_wrf_ptr
        generic, public :: get_wrf => get_wrf_holder, get_wrf_ptr

    end type

contains
    ! Managerを初期化するサブルーチン (シミュレーション開始時に一度だけ呼ぶ)
    subroutine initialize(self, input, ierr)
        class(type_material_manager), intent(inout) :: self
        type(type_input), intent(in) :: input
        integer(int32), intent(inout) :: ierr

        integer(int32) :: i, model_idx
        integer(int32) :: num_unique_regions, num_id
        integer(int32), allocatable :: unique_material_ids(:)

        integer(int32) :: current_material_id

        ierr = 0
        call input%geometry%vtk%get_active_region_info(unique_material_ids, ierr)
        num_unique_regions = input%basic%num_materials

        ! ステップ2: 配列を確保
        allocate (self%thc(num_unique_regions))
        allocate (self%den(num_unique_regions))
        allocate (self%sph(num_unique_regions))
        allocate (self%vhc(num_unique_regions))
        allocate (self%gcc(num_unique_regions))
        allocate (self%wrf(num_unique_regions))

        ! allocate (self%region_id_map(num_unique_regions))
        allocate (self%region_id_map, source=unique_material_ids)
        ! self%region_id_map = 0 ! 0は無効なインデックスとする

        ! ステップ3: 事前にあなたのFactoryを呼び出してモデルを生成し、マッピングする
        do model_idx = 1, num_unique_regions
            current_material_id = unique_material_ids(model_idx)

            call self%thc(model_idx)%initialize(input, current_material_id)
            call self%den(model_idx)%initialize(input, current_material_id)
            call self%sph(model_idx)%initialize(input, current_material_id)
            call self%vhc(model_idx)%initialize(input, current_material_id)
            call self%gcc(model_idx)%initialize(input, current_material_id)
            call self%wrf(model_idx)%initialize(input, current_material_id)

            self%region_id_map(current_material_id) = model_idx
        end do
    end subroutine initialize

    subroutine get_thc_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_thcs), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_thc:", region_id
            call exit(-1)
        end if

        model_holder = self%thc(model_index)

    end subroutine get_thc_holder

    !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ! THCオブジェクトへのポインタを返す高速なバージョン
    !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    subroutine get_thc_ptr(self, region_id, thc_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_thc), intent(inout), pointer :: thc_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_thc_ptr:", region_id
            nullify (thc_ptr)
            call exit(-1)
        end if

        thc_ptr => self%thc(model_index)%p

    end subroutine get_thc_ptr

    subroutine get_den_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_dens), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_den_holder:", region_id
            call exit(-1)
        end if

        model_holder = self%den(model_index)

    end subroutine get_den_holder

    subroutine get_den_ptr(self, region_id, den_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_den), intent(inout), pointer :: den_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_den_ptr:", region_id
            nullify (den_ptr)
            call exit(-1)
        end if

        den_ptr => self%den(model_index)%p

    end subroutine get_den_ptr

    subroutine get_sph_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_sphs), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_sph_holder:", region_id
            call exit(-1)
        end if

        model_holder = self%sph(model_index)

    end subroutine get_sph_holder

    subroutine get_sph_ptr(self, region_id, sph_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_sph), intent(inout), pointer :: sph_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_sph_ptr:", region_id
            nullify (sph_ptr)
            call exit(-1)
        end if

        sph_ptr => self%sph(model_index)%p

    end subroutine get_sph_ptr

    subroutine get_vhc_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_vhcs), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_vhc_holder:", region_id
            call exit(-1)
        end if

        model_holder = self%vhc(model_index)

    end subroutine get_vhc_holder

    subroutine get_vhc_ptr(self, region_id, vhc_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_vhc), intent(inout), pointer :: vhc_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_vhc_ptr:", region_id
            nullify (vhc_ptr)
            call exit(-1)
        end if

        vhc_ptr => self%vhc(model_index)%p

    end subroutine get_vhc_ptr

    subroutine get_gcc_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_gccs), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_gcc_holder:", region_id
            call exit(-1)
        end if

        model_holder = self%gcc(model_index)

    end subroutine get_gcc_holder

    subroutine get_gcc_ptr(self, region_id, gcc_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_gcc), intent(inout), pointer :: gcc_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_gcc_ptr:", region_id
            nullify (gcc_ptr)
            call exit(-1)
        end if

        gcc_ptr => self%gcc(model_index)%p

    end subroutine get_gcc_ptr

    subroutine get_wrf_holder(self, region_id, model_holder)
        class(type_material_manager), intent(inout) :: self
        integer(int32), intent(in) :: region_id
        type(holder_wrfs), intent(inout) :: model_holder
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_wrf_holder:", region_id
            call exit(-1)
        end if

        model_holder = self%wrf(model_index)

    end subroutine get_wrf_holder

    subroutine get_wrf_ptr(self, region_id, wrf_ptr)
        class(type_material_manager), intent(inout), target :: self
        integer(int32), intent(in) :: region_id
        class(abst_wrf), intent(inout), pointer :: wrf_ptr
        integer(int32) :: model_index

        model_index = self%region_id_map(region_id)

        if (model_index == 0) then
            print *, "Error: Invalid region_id in get_wrf_ptr:", region_id
            nullify (wrf_ptr)
            call exit(-1)
        end if

        wrf_ptr => self%wrf(model_index)%p

    end subroutine get_wrf_ptr

end module properties_material_manager