reordering.F90 Source File


This file depends on

sourcefile~~reordering.f90~~EfferentGraph sourcefile~reordering.f90 reordering.F90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~core.f90 core.F90 sourcefile~reordering.f90->sourcefile~core.f90 sourcefile~mesh.f90 mesh.F90 sourcefile~reordering.f90->sourcefile~mesh.f90 sourcefile~adjacency_node.f90->sourcefile~core.f90 sourcefile~adjacency_node.f90->sourcefile~mesh.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~element.f90 element.F90 sourcefile~mesh.f90->sourcefile~element.f90 sourcefile~mesh_interface.f90 mesh_interface.F90 sourcefile~mesh.f90->sourcefile~mesh_interface.f90 sourcefile~side.f90 side.F90 sourcefile~mesh.f90->sourcefile~side.f90 sourcefile~allocate.f90->sourcefile~error.f90 sourcefile~deallocate.f90->sourcefile~error.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~element.f90->sourcefile~element_factory.f90 sourcefile~element_interface.f90 element_interface.F90 sourcefile~element.f90->sourcefile~element_interface.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~mesh_interface.f90->sourcefile~core.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~side.f90->sourcefile~side_factory.f90 sourcefile~side_interface.f90 side_interface.F90 sourcefile~side.f90->sourcefile~side_interface.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~element_factory.f90->sourcefile~core.f90 sourcefile~element_factory.f90->sourcefile~element_interface.f90 sourcefile~input.f90 input.F90 sourcefile~element_factory.f90->sourcefile~input.f90 sourcefile~element_interface.f90->sourcefile~core.f90 sourcefile~element_interface.f90->sourcefile~mesh_interface.f90 sourcefile~element_interface.f90->sourcefile~input.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~side_factory.f90->sourcefile~core.f90 sourcefile~side_factory.f90->sourcefile~side_interface.f90 sourcefile~side_factory.f90->sourcefile~input.f90 sourcefile~side_interface.f90->sourcefile~core.f90 sourcefile~side_interface.f90->sourcefile~mesh_interface.f90 sourcefile~side_interface.f90->sourcefile~input.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 sourcefile~input_interface.f90 input_interface.F90 sourcefile~input.f90->sourcefile~input_interface.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~input_interface.f90->sourcefile~core.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~project_settings.f90->sourcefile~core.f90

Files dependent on this one

sourcefile~~reordering.f90~~AfferentGraph sourcefile~reordering.f90 reordering.F90 sourcefile~domain.f90 domain.F90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~methods.f90 methods.F90 sourcefile~methods.f90->sourcefile~reordering.f90 sourcefile~to_original.f90 to_original.F90 sourcefile~to_original.f90->sourcefile~reordering.f90 sourcefile~to_reordered.f90 to_reordered.F90 sourcefile~to_reordered.f90->sourcefile~reordering.f90 sourcefile~boundary_interface.f90 boundary_interface.F90 sourcefile~boundary_interface.f90->sourcefile~domain.f90 sourcefile~boundary_manager.f90 boundary_manager.F90 sourcefile~boundary_manager.f90->sourcefile~domain.f90 sourcefile~boundary_manager.f90->sourcefile~boundary_interface.f90 sourcefile~ftdss.f90 ftdss.F90 sourcefile~ftdss.f90->sourcefile~domain.f90 sourcefile~boundary.f90 boundary.F90 sourcefile~ftdss.f90->sourcefile~boundary.f90 sourcefile~hydraulic.f90 hydraulic.F90 sourcefile~ftdss.f90->sourcefile~hydraulic.f90 sourcefile~initial.f90 initial.F90 sourcefile~ftdss.f90->sourcefile~initial.f90 sourcefile~output.f90 output.F90 sourcefile~ftdss.f90->sourcefile~output.f90 sourcefile~thermal.f90 thermal.F90 sourcefile~ftdss.f90->sourcefile~thermal.f90 sourcefile~hydraulic_assemble.f90 hydraulic_assemble.F90 sourcefile~hydraulic_assemble.f90->sourcefile~domain.f90 sourcefile~hydraulic_interface.f90 hydraulic_interface.F90 sourcefile~hydraulic_interface.f90->sourcefile~domain.f90 sourcefile~hydraulic_interface.f90->sourcefile~hydraulic_assemble.f90 sourcefile~hydraulic_interface.f90->sourcefile~boundary.f90 sourcefile~initial_interface.f90 initial_interface.F90 sourcefile~initial_interface.f90->sourcefile~domain.f90 sourcefile~initial_interface.f90->sourcefile~boundary.f90 sourcefile~initial_manager.f90 initial_manager.F90 sourcefile~initial_manager.f90->sourcefile~domain.f90 sourcefile~initial_manager.f90->sourcefile~initial_interface.f90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_interface.f90->sourcefile~domain.f90 sourcefile~thermal_interface.f90 thermal_interface.F90 sourcefile~thermal_interface.f90->sourcefile~domain.f90 sourcefile~thermal_interface.f90->sourcefile~boundary.f90 sourcefile~boundary.f90->sourcefile~boundary_interface.f90 sourcefile~boundary.f90->sourcefile~boundary_manager.f90 sourcefile~boundary_adiabatic.f90 boundary_adiabatic.F90 sourcefile~boundary_adiabatic.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_base.f90 boundary_base.F90 sourcefile~boundary_base.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_dirichlet.f90 boundary_dirichlet.F90 sourcefile~boundary_dirichlet.f90->sourcefile~boundary_interface.f90 sourcefile~hydraulic.f90->sourcefile~hydraulic_interface.f90 sourcefile~hydraulic_crs.f90 hydraulic_crs.F90 sourcefile~hydraulic_crs.f90->sourcefile~hydraulic_interface.f90 sourcefile~initial.f90->sourcefile~initial_interface.f90 sourcefile~initial.f90->sourcefile~initial_manager.f90 sourcefile~initial_laplace.f90 initial_laplace.F90 sourcefile~initial_laplace.f90->sourcefile~initial_interface.f90 sourcefile~initial_uniform.f90 initial_uniform.F90 sourcefile~initial_uniform.f90->sourcefile~initial_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~thermal.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_crs.f90 thermal_crs.F90 sourcefile~thermal_crs.f90->sourcefile~thermal_interface.f90

Source Code

module domain_reordering
    use, intrinsic :: iso_fortran_env, only: int32, real64
    use :: stdlib_sorting, only:sort, sort_index
    use :: module_core, only:allocate_array, deallocate_array, error_message
    use :: module_mesh, only:holder_elements, holder_sides
    use :: domain_adjacency_adjacency_node, only:type_node_adjacency

    implicit none
    private
    public :: type_reordering

    type :: type_reordering
        private
        character(:), allocatable :: algorithm_name
        integer(int32) :: num_nodes = 0
        integer(int32), allocatable :: perm(:) ! CM/RCM indices -> original indices
        integer(int32), allocatable :: iperm(:) ! Original indices -> CM/RCM indices
        logical :: is_reordered_perm = .false.
        logical :: is_reordered_iperm = .false.
    contains
        procedure, public, pass(self) :: initialize => initialize_type_reordering

        procedure, private, pass(self) :: rcm_reorder_method
        procedure, private, pass(self) :: cm_reorder_method
        procedure, private, pass(self) :: create_inverse_permutation

        ! CM/RCM ordering -> original ordering
        procedure, private, pass(self) :: to_original_values_int32
        procedure, private, pass(self) :: to_original_values_real64
        generic, public :: to_original_value => to_original_values_int32, & !&
                                                to_original_values_real64 !&
        procedure, private, pass(self) :: to_original_index
        procedure, private, pass(self) :: to_original_indices
        generic, public :: to_original => to_original_index, & !&
                                          to_original_indices !&

        !  original ordering -> CM/RCM ordering
        procedure, private, pass(self) :: to_reordered_values_int32
        procedure, private, pass(self) :: to_reordered_values_real64
        generic, public :: to_reordered_value => to_reordered_values_int32, & !&
                                                 to_reordered_values_real64 !&
        procedure, private, pass(self) :: to_reordered_index
        procedure, private, pass(self) :: to_reordered_indices
        generic, public :: to_reordered => to_reordered_index, & !&
                                           to_reordered_indices !&

        procedure, public :: get_algorithm_name

        final :: finalize_type_reordering
    end type type_reordering

    interface
        module subroutine rcm_reorder_method(self, node_adj)
            import :: type_reordering, type_node_adjacency
            implicit none
            class(type_reordering), intent(inout) :: self
            class(type_node_adjacency), intent(in) :: node_adj
        end subroutine rcm_reorder_method

        module subroutine cm_reorder_method(self, node_adj)
            import :: type_reordering, type_node_adjacency
            implicit none
            class(type_reordering), intent(inout) :: self
            class(type_node_adjacency), intent(in) :: node_adj
        end subroutine cm_reorder_method

        module subroutine create_inverse_permutation(self)
            import :: type_reordering
            implicit none
            class(type_reordering), intent(inout) :: self
        end subroutine create_inverse_permutation
    end interface

    interface
        module subroutine to_original_values_int32(self, vector_reordered, vector_original)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: vector_reordered(:)
            integer(int32), intent(inout) :: vector_original(:)

        end subroutine to_original_values_int32

        module subroutine to_original_values_real64(self, vector_reordered, vector_original)
            implicit none
            class(type_reordering), intent(in) :: self
            real(real64), intent(in) :: vector_reordered(:)
            real(real64), intent(inout) :: vector_original(:)

        end subroutine to_original_values_real64

        module subroutine to_original_index(self, index_reordered, index_original)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: index_reordered
            integer(int32), intent(inout) :: index_original

        end subroutine to_original_index

        module subroutine to_original_indices(self, indices_reordered, indices_original)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: indices_reordered(:)
            integer(int32), intent(inout) :: indices_original(:)

        end subroutine to_original_indices

    end interface

    interface
        module subroutine to_reordered_values_int32(self, vector_original, vector_reordered)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: vector_original(:)
            integer(int32), intent(inout) :: vector_reordered(:)

        end subroutine to_reordered_values_int32

        module subroutine to_reordered_values_real64(self, vector_original, vector_reordered)
            implicit none
            class(type_reordering), intent(in) :: self
            real(real64), intent(in) :: vector_original(:)
            real(real64), intent(inout) :: vector_reordered(:)

        end subroutine to_reordered_values_real64

        module subroutine to_reordered_index(self, index_original, index_reordered)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: index_original
            integer(int32), intent(inout) :: index_reordered

        end subroutine to_reordered_index

        module subroutine to_reordered_indices(self, indices_original, indices_reordered)
            implicit none
            class(type_reordering), intent(in) :: self
            integer(int32), intent(in) :: indices_original(:)
            integer(int32), intent(inout) :: indices_reordered(:)

        end subroutine to_reordered_indices
    end interface

contains

    subroutine initialize_type_reordering(self, algorithm_name, node_adj)
        implicit none
        class(type_reordering), intent(inout) :: self
        character(*), intent(in) :: algorithm_name
        class(type_node_adjacency), intent(in) :: node_adj

        if (allocated(self%algorithm_name)) deallocate (self%algorithm_name)
        allocate (character(len=len_trim(algorithm_name)) :: self%algorithm_name)
        self%algorithm_name = trim(adjustl(algorithm_name))

        select case (self%algorithm_name)
        case ("rcm")
            call self%rcm_reorder_method(node_adj)
            call self%create_inverse_permutation()
        case ("cm")
            call self%cm_reorder_method(node_adj)
            call self%create_inverse_permutation()
        case default
            ! No reordering
        end select
    end subroutine initialize_type_reordering

    function get_algorithm_name(self) result(name)
        implicit none
        class(type_reordering), intent(in) :: self
        character(:), allocatable :: name

        if (allocated(self%algorithm_name)) then
            name = self%algorithm_name
        else
            name = "none"
        end if

    end function get_algorithm_name

    !================================================================!
    ! finalizer
    !================================================================!
    subroutine finalize_type_reordering(self)
        implicit none
        type(type_reordering), intent(inout) :: self

        call deallocate_array(self%perm)
        call deallocate_array(self%iperm)
    end subroutine finalize_type_reordering

end module domain_reordering