boundary_dirichlet.F90 Source File


This file depends on

sourcefile~~boundary_dirichlet.f90~~EfferentGraph sourcefile~boundary_dirichlet.f90 boundary_dirichlet.F90 sourcefile~boundary_interface.f90 boundary_interface.F90 sourcefile~boundary_dirichlet.f90->sourcefile~boundary_interface.f90 sourcefile~core.f90 core.F90 sourcefile~boundary_interface.f90->sourcefile~core.f90 sourcefile~domain.f90 domain.F90 sourcefile~boundary_interface.f90->sourcefile~domain.f90 sourcefile~input.f90 input.F90 sourcefile~boundary_interface.f90->sourcefile~input.f90 sourcefile~matrix.f90 matrix.F90 sourcefile~boundary_interface.f90->sourcefile~matrix.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~adjacency.f90 adjacency.F90 sourcefile~domain.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~element.f90 element.F90 sourcefile~domain.f90->sourcefile~element.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~domain.f90->sourcefile~element_factory.f90 sourcefile~multicoloring.f90 multicoloring.F90 sourcefile~domain.f90->sourcefile~multicoloring.f90 sourcefile~reordering.f90 reordering.F90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~side.f90 side.F90 sourcefile~domain.f90->sourcefile~side.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~domain.f90->sourcefile~side_factory.f90 sourcefile~input_interface.f90 input_interface.F90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~matrix_base.f90 matrix_base.F90 sourcefile~matrix.f90->sourcefile~matrix_base.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~adjacency_element.f90 adjacency_element.F90 sourcefile~adjacency.f90->sourcefile~adjacency_element.f90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~adjacency.f90->sourcefile~adjacency_node.f90 sourcefile~allocate.f90->sourcefile~error.f90 sourcefile~deallocate.f90->sourcefile~error.f90 sourcefile~domain_manager.f90->sourcefile~core.f90 sourcefile~domain_manager.f90->sourcefile~input.f90 sourcefile~domain_manager.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90->sourcefile~element.f90 sourcefile~domain_manager.f90->sourcefile~element_factory.f90 sourcefile~domain_manager.f90->sourcefile~multicoloring.f90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~domain_manager.f90->sourcefile~side.f90 sourcefile~domain_manager.f90->sourcefile~side_factory.f90 sourcefile~element.f90->sourcefile~core.f90 sourcefile~element.f90->sourcefile~input.f90 sourcefile~element_factory.f90->sourcefile~core.f90 sourcefile~element_factory.f90->sourcefile~input.f90 sourcefile~element_factory.f90->sourcefile~element.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~matrix_base.f90->sourcefile~domain.f90 sourcefile~matrix_coo.f90->sourcefile~core.f90 sourcefile~matrix_coo.f90->sourcefile~domain.f90 sourcefile~matrix_coo.f90->sourcefile~matrix_base.f90 sourcefile~matrix_crs.f90->sourcefile~core.f90 sourcefile~matrix_crs.f90->sourcefile~domain.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_base.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_coo.f90 sourcefile~matrix_dense.f90->sourcefile~core.f90 sourcefile~matrix_dense.f90->sourcefile~domain.f90 sourcefile~matrix_dense.f90->sourcefile~matrix_base.f90 sourcefile~multicoloring.f90->sourcefile~core.f90 sourcefile~multicoloring.f90->sourcefile~adjacency_element.f90 sourcefile~reordering.f90->sourcefile~core.f90 sourcefile~reordering.f90->sourcefile~element.f90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~side.f90->sourcefile~core.f90 sourcefile~side.f90->sourcefile~input.f90 sourcefile~side_factory.f90->sourcefile~core.f90 sourcefile~side_factory.f90->sourcefile~input.f90 sourcefile~side_factory.f90->sourcefile~side.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~adjacency_element.f90->sourcefile~core.f90 sourcefile~adjacency_element.f90->sourcefile~element.f90 sourcefile~adjacency_node.f90->sourcefile~core.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~project_settings.f90->sourcefile~core.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

Source Code

submodule(conditions_boundary) conditions_boundary_dirichlet
    implicit none
contains

    module subroutine initialize_type_bc_thermal_dirichlet(self, input, domain, id, i_material, time_conv)
        implicit none
        class(type_bc_thermal_dirichlet), intent(inout) :: self
        type(type_input), intent(in) :: input
        type(type_domain), intent(in) :: domain
        integer(int32), intent(in) :: id
        integer(int32), intent(in) :: i_material
        real(real64), intent(in) :: time_conv

        integer(int32) :: i
        integer(int32), allocatable :: tmp_indices(:)

        self%material_id = input%conditions%boundary_conditions(id)%id
        self%boundary_name = input%conditions%boundary_conditions(id)%thermal%type
        self%is_uniform = input%conditions%boundary_conditions(id)%thermal%is_uniform

        !! Time settings
        if (allocated(self%time_points)) deallocate (self%time_points)
        allocate (self%time_points, source=input%conditions%time_control%boundary_time_points)
        self%time_points = self%time_points * time_conv

        if (allocated(self%values)) deallocate (self%values)
        allocate (self%values, source=input%conditions%boundary_conditions(id)%thermal%values)

        call find_target_edges_by_group(domain, i_material, self%target_edges)
        self%num_target_edges = size(self%target_edges, 2)

        select case (input%basic%solver_settings%reordering)
        case ("cm", "rcm")
            call allocate_array(tmp_indices, 2_int32)
            do i = 1, self%num_target_edges
                call domain%reordering%to_reordered(self%target_edges(:, i), tmp_indices)
                self%target_edges(:, i) = tmp_indices(:)
            end do
            call deallocate_array(tmp_indices)
        end select

    end subroutine initialize_type_bc_thermal_dirichlet

    module subroutine apply_dense_thermal_dirichlet(self, current_time, A, b, domain, mode)
        implicit none
        class(type_bc_thermal_dirichlet), intent(in) :: self
        real(real64), intent(in) :: current_time
        real(real64), intent(inout), optional :: A(:, :)
        real(real64), intent(inout) :: b(:)
        type(type_domain), intent(in) :: domain
        integer(int32), intent(in), optional :: mode

    end subroutine apply_dense_thermal_dirichlet

    module subroutine apply_crs_thermal_dirichlet(self, current_time, A, b, domain, mode)
        implicit none
        class(type_bc_thermal_dirichlet), intent(in) :: self
        real(real64), intent(in) :: current_time
        type(type_crs), intent(inout), optional :: A
        real(real64), intent(inout) :: b(:)
        type(type_domain), intent(in) :: domain
        integer(int32), intent(in), optional :: mode

        real(real64) :: value_dirichlet, timeCoe
        integer(int32) :: idx, iEdge

        ! print *, "apply_crs_thermal_dirichlet"
        ! print *, "current_time = ", current_time
        ! print *, present(A), present(mode)

        if (present(A)) then
            if (.not. present(mode)) then
                call calculate_time_coefficient(current_time, self%time_points, timeCoe, idx)
                value_dirichlet = (self%values(idx) * (1.0d0 - timeCoe) + self%values(idx + 1) * timeCoe)

                do iEdge = 1, self%num_target_edges
                    call apply_crs_dirichlet_base(A=A, &
                                                  b=b, &
                                                  is_uniform=self%is_uniform, &
                                                  edge=self%target_edges(:, iEdge), &
                                                  value_dirichlet=value_dirichlet)
                end do
            else
                select case (mode)
                case (1)
                    call calculate_time_coefficient(current_time, self%time_points, timeCoe, idx)
                    value_dirichlet = (self%values(idx) * (1.0d0 - timeCoe) + self%values(idx + 1) * timeCoe)
                    ! print *, value_dirichlet
                case (0)
                    !! Newton-Raphson step
                    value_dirichlet = 0.0d0
                case (-1)
                    !! initial condition
                    value_dirichlet = self%values(1)
                end select

                do iEdge = 1, self%num_target_edges
                    call apply_crs_dirichlet_base(A=A, &
                                                  b=b, &
                                                  is_uniform=self%is_uniform, &
                                                  edge=self%target_edges(:, iEdge), &
                                                  value_dirichlet=value_dirichlet)
                end do
            end if
        else
            if (.not. present(mode)) then
                call calculate_time_coefficient(current_time, self%time_points, timeCoe, idx)
                value_dirichlet = (self%values(idx) * (1.0d0 - timeCoe) + self%values(idx + 1) * timeCoe)

                do iEdge = 1, self%num_target_edges
                    call apply_crs_dirichlet_base(b=b, &
                                                  is_uniform=self%is_uniform, &
                                                  edge=self%target_edges(:, iEdge), &
                                                  value_dirichlet=value_dirichlet)
                end do
            else
                select case (mode)
                case (1)
                    call calculate_time_coefficient(current_time, self%time_points, timeCoe, idx)
                    value_dirichlet = (self%values(idx) * (1.0d0 - timeCoe) + self%values(idx + 1) * timeCoe)
                    ! print *, value_dirichlet
                case (0)
                !! Newton-Raphson step
                    value_dirichlet = 0.0d0
                case (-1)
                !! initial condition
                    value_dirichlet = self%values(1)
                end select

                do iEdge = 1, self%num_target_edges
                    call apply_crs_dirichlet_base(b=b, &
                                                  is_uniform=self%is_uniform, &
                                                  edge=self%target_edges(:, iEdge), &
                                                  value_dirichlet=value_dirichlet)
                end do
            end if
        end if

    end subroutine apply_crs_thermal_dirichlet

    subroutine apply_crs_dirichlet_base(A, b, is_uniform, edge, value_dirichlet)
        implicit none
        type(type_crs), intent(inout), optional :: A
        real(real64), intent(inout) :: b(:)
        logical, intent(in) :: is_uniform
        integer(int32), intent(in) :: edge(2)
        real(real64), intent(in) :: value_dirichlet

        integer(int32) :: i, j, k, p, N
        integer(int32) :: p_idx
        integer(int32) :: ps, pe
        real(real64) :: Aij
        logical, allocatable :: is_dirichlet_node(:)
        integer(int32) :: ind, p1, p2

        if (.not. is_uniform) return

        if (present(A)) then
            N = size(b)

            p1 = Edge(1)
            p2 = Edge(2)

            if (present(A)) then
                call A%find(p1, p1, ind)
                ps = A%ptr(p1)
                pe = A%ptr(p1 + 1) - 1
                A%val(ps:pe) = 0.0d0
                A%val(ind) = 1.0d0

                call A%find(p2, p2, ind)
                ps = A%ptr(p2)
                pe = A%ptr(p2 + 1) - 1
                A%val(ps:pe) = 0.0d0
                A%val(ind) = 1.0d0
            end if

            b(p1) = value_dirichlet
            b(p2) = value_dirichlet
        else
            ! 行列 A がない場合は、b のみを変更
            b(edge(1)) = value_dirichlet
            b(edge(2)) = value_dirichlet
        end if

    end subroutine apply_crs_dirichlet_base

    subroutine apply_Dense_Dirichlet_base(A, b, is_uniform, edge, value_dirichlet)
        implicit none
        real(real64), intent(inout), optional :: A(:, :)
        real(real64), intent(inout) :: b(:)
        logical, intent(in) :: is_uniform
        integer(int32), intent(in) :: edge(2)
        real(real64), intent(in) :: value_dirichlet

        integer(int32) :: i, ind, ps, pe
        integer(int32) :: p1, p2

        ! if (is_uniform) then
        !     ! ! --- ここからデバッグ用コード ---
        !     ! print *, 'Debug: edge = ', edge(1), edge(2)
        !     ! print *, 'Debug: size(perm) = ', size(perm)
        !     ! if (present(A)) then
        !     !     print *, 'Debug: shape(A) = ', shape(A)
        !     ! end if
        !     ! print *, 'Debug: size(b) = ', size(b)
        !     ! ! --- ここまでデバッグ用コード ---
        !     p1 = edge(1)
        !     p2 = edge(2)

        !     if (present(A)) then
        !         A(p1, :) = 0.0d0
        !         A(p1, p1) = 1.0d0

        !         A(p2, :) = 0.0d0
        !         A(p2, p2) = 1.0d0
        !     end if

        !     b(p1) = value_dirichlet
        !     b(p2) = value_dirichlet
        ! end if

    end subroutine apply_Dense_Dirichlet_base

end submodule conditions_boundary_Dirichlet