mesh_interface.F90 Source File


This file depends on

sourcefile~~mesh_interface.f90~~EfferentGraph sourcefile~mesh_interface.f90 mesh_interface.F90 sourcefile~core.f90 core.F90 sourcefile~mesh_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~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~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~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~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~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

Files dependent on this one

sourcefile~~mesh_interface.f90~~AfferentGraph sourcefile~mesh_interface.f90 mesh_interface.F90 sourcefile~element_interface.f90 element_interface.F90 sourcefile~element_interface.f90->sourcefile~mesh_interface.f90 sourcefile~mesh.f90 mesh.F90 sourcefile~mesh.f90->sourcefile~mesh_interface.f90 sourcefile~element.f90 element.F90 sourcefile~mesh.f90->sourcefile~element.f90 sourcefile~side.f90 side.F90 sourcefile~mesh.f90->sourcefile~side.f90 sourcefile~side_interface.f90 side_interface.F90 sourcefile~side_interface.f90->sourcefile~mesh_interface.f90 sourcefile~adjacency_element.f90 adjacency_element.F90 sourcefile~adjacency_element.f90->sourcefile~mesh.f90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~adjacency_node.f90->sourcefile~mesh.f90 sourcefile~adjacency_node_element.f90 adjacency_node_element.F90 sourcefile~adjacency_node_element.f90->sourcefile~mesh.f90 sourcefile~domain.f90 domain.F90 sourcefile~domain.f90->sourcefile~mesh.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~reordering.f90 reordering.F90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~adjacency.f90 adjacency.F90 sourcefile~domain.f90->sourcefile~adjacency.f90 sourcefile~multicoloring.f90 multicoloring.F90 sourcefile~domain.f90->sourcefile~multicoloring.f90 sourcefile~domain_manager.f90->sourcefile~mesh.f90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~domain_manager.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90->sourcefile~multicoloring.f90 sourcefile~element.f90->sourcefile~element_interface.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~element.f90->sourcefile~element_factory.f90 sourcefile~element_factory.f90->sourcefile~element_interface.f90 sourcefile~element_square_first.f90 element_square_first.F90 sourcefile~element_square_first.f90->sourcefile~element_interface.f90 sourcefile~element_square_second.f90 element_square_second.F90 sourcefile~element_square_second.f90->sourcefile~element_interface.f90 sourcefile~element_triangle_first.f90 element_triangle_first.F90 sourcefile~element_triangle_first.f90->sourcefile~element_interface.f90 sourcefile~element_triangle_second.f90 element_triangle_second.F90 sourcefile~element_triangle_second.f90->sourcefile~element_interface.f90 sourcefile~reordering.f90->sourcefile~mesh.f90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~side.f90->sourcefile~side_interface.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~side.f90->sourcefile~side_factory.f90 sourcefile~side_factory.f90->sourcefile~side_interface.f90 sourcefile~side_first.f90 side_first.F90 sourcefile~side_first.f90->sourcefile~side_interface.f90 sourcefile~side_second.f90 side_second.F90 sourcefile~side_second.f90->sourcefile~side_interface.f90 sourcefile~adjacency.f90->sourcefile~adjacency_element.f90 sourcefile~adjacency.f90->sourcefile~adjacency_node.f90 sourcefile~adjacency.f90->sourcefile~adjacency_node_element.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~methods.f90 methods.F90 sourcefile~methods.f90->sourcefile~reordering.f90 sourcefile~multicoloring.f90->sourcefile~adjacency_element.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~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.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~dsatur.f90 dsatur.F90 sourcefile~dsatur.f90->sourcefile~multicoloring.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~lfo.f90 lfo.F90 sourcefile~lfo.f90->sourcefile~multicoloring.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 sourcefile~welch_powell.f90 welch_powell.F90 sourcefile~welch_powell.f90->sourcefile~multicoloring.f90

Source Code

module domain_mesh
    use, intrinsic :: iso_fortran_env, only: int32, real64
    use :: stdlib_logger
    use :: module_core, only:type_dp_3d, type_dp_vector_3d, assignment(=), type_dp_pointer, allocate_array, deallocate_array
    implicit none
    private

    public :: abst_mesh

    type, abstract :: abst_mesh
        integer(int32), private :: id !! Element ID
        integer(int32), private :: type !! Element type (5: triangle 1st, 9: square 1st)
        integer(int32), private :: num_nodes !! Number of nodes in the element
        integer(int32), private :: group !! Element group number
        integer(int32), private :: dimension
        integer(int32), private :: order
        integer(int32), allocatable, private :: connectivity(:) !! connectivity information
        type(type_dp_pointer), allocatable, private :: x(:) !! X coordinate
        type(type_dp_pointer), allocatable, private :: y(:) !! Y coordinate
        type(type_dp_pointer), allocatable, private :: z(:) !! Z coordinate
        !----------------------------------------------------------------------------------
        ! Gauss Quadrature points and weights
        !  - Gauss Quadrature points are defined in the local coordinate system
        !  - The number of Gauss points is determined by the element type
        !  - The weights are used for numerical integration over the element
        !  - The Gauss points are used to evaluate the shape functions and their derivatives
        !----------------------------------------------------------------------------------
        integer(int32), private :: num_gauss !! Number of Gauss Quadrature points
        real(real64), allocatable, private :: weight(:) !! Gauss weight
        type(type_dp_vector_3d), allocatable, private :: gauss(:) !! Gauss Quadrature points Coordinate
    contains
        procedure, pass(self), public :: initialize => initialize_abst_mesh !&
        procedure, pass(self), public :: get_id !&
        procedure, pass(self), public :: get_type !&
        procedure, pass(self), public :: get_num_nodes !&
        procedure, pass(self), public :: get_group !&
        procedure, pass(self), public :: get_order !&
        procedure, pass(self), public :: get_dimension !&
        procedure, pass(self), public :: get_num_gauss !&
        procedure, pass(self), public :: get_weight !&
        procedure, pass(self), public :: get_gauss !&
        procedure, pass(self), public :: get_coordinate !&
        procedure, pass(self), public :: get_connectivity !&
        procedure, pass(self), public :: lerp !&
        procedure, pass(self), public :: dlerp !&

        procedure(abst_get_geometry), pass(self), public, deferred :: get_geometry
        procedure(abst_psi), pass(self), public, deferred :: psi
        procedure(abst_dpsi), pass(self), public, deferred :: dpsi
        procedure(abst_jacobian), pass(self), public, deferred :: jacobian
        procedure(abst_jacobian_det), pass(self), public, deferred :: jacobian_det

    end type

    abstract interface
        pure function abst_get_geometry(self) result(geometry)
            import :: abst_mesh, real64
            implicit none
            class(abst_mesh), intent(in) :: self
            real(real64) :: geometry
        end function

        pure elemental function abst_psi(self, i, r) result(psi)
            import :: abst_mesh, type_dp_vector_3d, int32, real64
            implicit none
            class(abst_mesh), intent(in) :: self
            integer(int32), intent(in) :: i
            type(type_dp_vector_3d), intent(in) :: r
            real(real64) :: psi
        end function abst_psi

        pure elemental function abst_dpsi(self, i, j, r) result(dpsi)
            import :: abst_mesh, type_dp_vector_3d, int32, real64
            implicit none
            class(abst_mesh), intent(in) :: self
            integer(int32), intent(in) :: i
            integer(int32), intent(in) :: j
            type(type_dp_vector_3d), intent(in) :: r
            real(real64) :: dpsi
        end function abst_dpsi

        pure elemental function abst_jacobian(self, i, j, r) result(jacobian)
            import :: abst_mesh, type_dp_vector_3d, int32, real64
            implicit none
            class(abst_mesh), intent(in) :: self
            integer(int32), intent(in) :: i
            integer(int32), intent(in) :: j
            type(type_dp_vector_3d), intent(in) :: r
            real(real64) :: jacobian
        end function abst_jacobian

        pure elemental function abst_jacobian_det(self, r) result(jacobian_det)
            import :: abst_mesh, type_dp_vector_3d, int32, real64
            implicit none
            class(abst_mesh), intent(in) :: self
            type(type_dp_vector_3d), intent(in) :: r
            real(real64) :: jacobian_det

        end function abst_jacobian_det

    end interface

contains
    subroutine initialize_abst_mesh(self, id, type, group, dimension, order, num_nodes, connectivity, &
                                    num_gauss, weight, gauss, global_coordinate)
        implicit none
        class(abst_mesh), intent(inout) :: self
        integer(int32), intent(in) :: id
        integer(int32), intent(in) :: type
        integer(int32), intent(in) :: group
        integer(int32), intent(in) :: dimension
        integer(int32), intent(in) :: order
        integer(int32), intent(in) :: num_nodes
        integer(int32), intent(in) :: connectivity(:)
        integer(int32), intent(in) :: num_gauss
        real(real64), intent(in) :: weight(:)
        real(real64), intent(in) :: gauss(:, :)
        type(type_dp_3d), pointer, intent(in) :: global_coordinate

        integer(int32) :: i

        self%id = id
        self%type = type
        self%group = group
        self%dimension = dimension
        self%order = order
        self%num_nodes = num_nodes
        self%num_gauss = num_gauss

        call allocate_array(self%connectivity, self%num_nodes)
        do i = 1, self%num_nodes
            self%connectivity(i) = connectivity(i)
        end do

        call allocate_array(self%weight, self%num_gauss)
        do i = 1, self%num_gauss
            self%weight(i) = weight(i)
        end do

        allocate (self%gauss(self%num_gauss))
        do i = 1, self%num_gauss
            call self%gauss(i)%set(gauss(1, i), gauss(2, i), gauss(3, i))
        end do

        allocate (self%x(self%num_nodes))
        allocate (self%y(self%num_nodes))
        allocate (self%z(self%num_nodes))
        do i = 1, self%num_nodes
            nullify (self%x(i)%val)
            nullify (self%y(i)%val)
            nullify (self%z(i)%val)
            self%x(i)%val => global_coordinate%x(self%connectivity(i))
            self%y(i)%val => global_coordinate%y(self%connectivity(i))
            self%z(i)%val => global_coordinate%z(self%connectivity(i))
        end do

    end subroutine initialize_abst_mesh

    pure function get_id(self) result(id)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: id

        id = self%id
    end function get_id

    pure function get_type(self) result(type)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: type

        type = self%type
    end function get_type

    pure function get_num_nodes(self) result(num_nodes)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: num_nodes

        num_nodes = self%num_nodes
    end function get_num_nodes

    pure function get_group(self) result(group)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: group

        group = self%group
    end function get_group

    pure function get_order(self) result(order)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: order

        order = self%order
    end function get_order

    pure function get_dimension(self) result(dimension)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: dimension

        dimension = self%dimension
    end function get_dimension

    pure function get_num_gauss(self) result(num_gauss)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32) :: num_gauss

        num_gauss = self%num_gauss
    end function get_num_gauss

    function get_weight(self) result(weight)
        implicit none
        class(abst_mesh), intent(in), target :: self
        real(real64), dimension(:), pointer :: weight

        weight => self%weight(:)
    end function get_weight

    function get_gauss(self) result(gauss)
        implicit none
        class(abst_mesh), intent(in), target :: self
        type(type_dp_vector_3d), dimension(:), pointer :: gauss

        gauss => self%gauss(:)
    end function get_gauss

    pure function get_coordinate(self, index) result(coordinate)
        implicit none
        class(abst_mesh), intent(in) :: self
        integer(int32), intent(in) :: index
        type(type_dp_vector_3d) :: coordinate

        coordinate%x = self%x(index)%val
        coordinate%y = self%y(index)%val
        coordinate%z = self%z(index)%val
    end function get_coordinate

    function get_connectivity(self) result(connectivity)
        implicit none
        class(abst_mesh), intent(in), target :: self
        integer(int32), dimension(:), pointer :: connectivity

        connectivity => self%connectivity(:)
    end function get_connectivity

    pure function lerp(self, r, value) result(val)
        implicit none
        class(abst_mesh), intent(in) :: self
        type(type_dp_vector_3d), intent(in) :: r
        real(real64), intent(in) :: value(:)
        real(real64) :: val

        integer(int32) :: i

        val = 0.0d0

        do i = 1, self%num_nodes
            val = val + self%psi(i, r) * value(self%connectivity(i))
        end do

    end function lerp

    pure function dlerp(self, r, value) result(val)
        implicit none
        class(abst_mesh), intent(in) :: self
        type(type_dp_vector_3d), intent(in) :: r
        real(real64), intent(in) :: value(:)
        type(type_dp_vector_3d) :: val

        integer(int32) :: i

        val%x = 0.0d0
        val%y = 0.0d0
        val%z = 0.0d0

        do i = 1, self%num_nodes
            if (self%dimension >= 1) val%x = val%x + self%dpsi(i, 1, r) * value(self%connectivity(i))
            if (self%dimension >= 2) val%y = val%y + self%dpsi(i, 2, r) * value(self%connectivity(i))
            if (self%dimension >= 3) val%z = val%z + self%dpsi(i, 3, r) * value(self%connectivity(i))
        end do

    end function dlerp

end module domain_mesh