process_element_hydraulic_linear_1 Subroutine

private subroutine process_element_hydraulic_linear_1(J, R, element, pressure, temperature, ice, porosity, properties, controls, actual_order)

Arguments

Type IntentOptional Attributes Name
type(type_crs), intent(inout) :: J
real(kind=real64), intent(inout) :: R(:)
class(abst_mesh), intent(in), pointer :: element
type(type_variable), intent(in) :: pressure
type(type_variable), intent(in) :: temperature
type(type_variable), intent(in) :: ice
type(type_variable), intent(in) :: porosity
type(type_properties_manager), intent(in) :: properties
type(type_controls), intent(in) :: controls
integer(kind=int32), intent(in) :: actual_order

Calls

proc~~process_element_hydraulic_linear_1~~CallsGraph proc~process_element_hydraulic_linear_1 process_element_hydraulic_linear_1 dpsi dpsi proc~process_element_hydraulic_linear_1->dpsi interface~allocate_array allocate_array proc~process_element_hydraulic_linear_1->interface~allocate_array interface~deallocate_array deallocate_array proc~process_element_hydraulic_linear_1->interface~deallocate_array interface~gemv gemv proc~process_element_hydraulic_linear_1->interface~gemv jacobian jacobian proc~process_element_hydraulic_linear_1->jacobian jacobian_det jacobian_det proc~process_element_hydraulic_linear_1->jacobian_det none~calc_hydraulic type_properties_manager%calc_hydraulic proc~process_element_hydraulic_linear_1->none~calc_hydraulic proc~add_dense type_dense%add_dense proc~process_element_hydraulic_linear_1->proc~add_dense proc~destroy_dense type_dense%destroy_dense proc~process_element_hydraulic_linear_1->proc~destroy_dense proc~get_connectivity abst_mesh%get_connectivity proc~process_element_hydraulic_linear_1->proc~get_connectivity proc~get_dt type_time%get_dt proc~process_element_hydraulic_linear_1->proc~get_dt proc~get_gauss abst_mesh%get_gauss proc~process_element_hydraulic_linear_1->proc~get_gauss proc~get_group abst_mesh%get_group proc~process_element_hydraulic_linear_1->proc~get_group proc~get_num_gauss abst_mesh%get_num_gauss proc~process_element_hydraulic_linear_1->proc~get_num_gauss proc~get_num_nodes~3 abst_mesh%get_num_nodes proc~process_element_hydraulic_linear_1->proc~get_num_nodes~3 proc~get_weight abst_mesh%get_weight proc~process_element_hydraulic_linear_1->proc~get_weight proc~initialize_type_dense_from_node type_dense%initialize_type_dense_from_node proc~process_element_hydraulic_linear_1->proc~initialize_type_dense_from_node proc~lerp abst_mesh%lerp proc~process_element_hydraulic_linear_1->proc~lerp proc~should_calculate_target type_controls%should_calculate_target proc~process_element_hydraulic_linear_1->proc~should_calculate_target psi psi proc~process_element_hydraulic_linear_1->psi proc~allocate_rank1_int16 allocate_rank1_int16 interface~allocate_array->proc~allocate_rank1_int16 proc~allocate_rank1_int32 allocate_rank1_int32 interface~allocate_array->proc~allocate_rank1_int32 proc~allocate_rank1_int64 allocate_rank1_int64 interface~allocate_array->proc~allocate_rank1_int64 proc~allocate_rank1_int8 allocate_rank1_int8 interface~allocate_array->proc~allocate_rank1_int8 proc~allocate_rank1_logical1 allocate_rank1_logical1 interface~allocate_array->proc~allocate_rank1_logical1 proc~allocate_rank1_logical4 allocate_rank1_logical4 interface~allocate_array->proc~allocate_rank1_logical4 proc~allocate_rank1_logical8 allocate_rank1_logical8 interface~allocate_array->proc~allocate_rank1_logical8 proc~allocate_rank1_real128 allocate_rank1_real128 interface~allocate_array->proc~allocate_rank1_real128 proc~allocate_rank1_real32 allocate_rank1_real32 interface~allocate_array->proc~allocate_rank1_real32 proc~allocate_rank1_real64 allocate_rank1_real64 interface~allocate_array->proc~allocate_rank1_real64 proc~allocate_rank2_int16 allocate_rank2_int16 interface~allocate_array->proc~allocate_rank2_int16 proc~allocate_rank2_int32 allocate_rank2_int32 interface~allocate_array->proc~allocate_rank2_int32 proc~allocate_rank2_int64 allocate_rank2_int64 interface~allocate_array->proc~allocate_rank2_int64 proc~allocate_rank2_int8 allocate_rank2_int8 interface~allocate_array->proc~allocate_rank2_int8 proc~allocate_rank2_logical1 allocate_rank2_logical1 interface~allocate_array->proc~allocate_rank2_logical1 proc~allocate_rank2_logical4 allocate_rank2_logical4 interface~allocate_array->proc~allocate_rank2_logical4 proc~allocate_rank2_logical8 allocate_rank2_logical8 interface~allocate_array->proc~allocate_rank2_logical8 proc~allocate_rank2_real128 allocate_rank2_real128 interface~allocate_array->proc~allocate_rank2_real128 proc~allocate_rank2_real32 allocate_rank2_real32 interface~allocate_array->proc~allocate_rank2_real32 proc~allocate_rank2_real64 allocate_rank2_real64 interface~allocate_array->proc~allocate_rank2_real64 proc~deallocate_rank1_int32 deallocate_rank1_int32 interface~deallocate_array->proc~deallocate_rank1_int32 proc~deallocate_rank1_int64 deallocate_rank1_int64 interface~deallocate_array->proc~deallocate_rank1_int64 proc~deallocate_rank1_int8 deallocate_rank1_int8 interface~deallocate_array->proc~deallocate_rank1_int8 proc~deallocate_rank1_logical1 deallocate_rank1_logical1 interface~deallocate_array->proc~deallocate_rank1_logical1 proc~deallocate_rank1_logical4 deallocate_rank1_logical4 interface~deallocate_array->proc~deallocate_rank1_logical4 proc~deallocate_rank1_logical8 deallocate_rank1_logical8 interface~deallocate_array->proc~deallocate_rank1_logical8 proc~deallocate_rank1_real128 deallocate_rank1_real128 interface~deallocate_array->proc~deallocate_rank1_real128 proc~deallocate_rank1_real32 deallocate_rank1_real32 interface~deallocate_array->proc~deallocate_rank1_real32 proc~deallocate_rank1_real64 deallocate_rank1_real64 interface~deallocate_array->proc~deallocate_rank1_real64 proc~deallocate_rank2_int32 deallocate_rank2_int32 interface~deallocate_array->proc~deallocate_rank2_int32 proc~deallocate_rank2_int64 deallocate_rank2_int64 interface~deallocate_array->proc~deallocate_rank2_int64 proc~deallocate_rank2_int8 deallocate_rank2_int8 interface~deallocate_array->proc~deallocate_rank2_int8 proc~deallocate_rank2_logical1 deallocate_rank2_logical1 interface~deallocate_array->proc~deallocate_rank2_logical1 proc~deallocate_rank2_logical4 deallocate_rank2_logical4 interface~deallocate_array->proc~deallocate_rank2_logical4 proc~deallocate_rank2_logical8 deallocate_rank2_logical8 interface~deallocate_array->proc~deallocate_rank2_logical8 proc~deallocate_rank2_real128 deallocate_rank2_real128 interface~deallocate_array->proc~deallocate_rank2_real128 proc~deallocate_rank2_real32 deallocate_rank2_real32 interface~deallocate_array->proc~deallocate_rank2_real32 proc~deallocate_rank2_real64 deallocate_rank2_real64 interface~deallocate_array->proc~deallocate_rank2_real64 proc~type_coo_gemv type_coo_gemv interface~gemv->proc~type_coo_gemv proc~type_crs_gemv type_crs_gemv interface~gemv->proc~type_crs_gemv proc~type_dense_gemv type_dense_gemv interface~gemv->proc~type_dense_gemv proc~calc_hydraulic_properties_array type_properties_manager%calc_hydraulic_properties_array none~calc_hydraulic->proc~calc_hydraulic_properties_array proc~calc_hydraulic_properties_scalar type_properties_manager%calc_hydraulic_properties_scalar none~calc_hydraulic->proc~calc_hydraulic_properties_scalar proc~destroy_dense->interface~deallocate_array proc~initialize_type_dense_from_node->interface~allocate_array proc~lerp->psi proc~error_message error_message proc~allocate_rank1_int16->proc~error_message proc~allocate_rank1_int32->proc~error_message proc~allocate_rank1_int64->proc~error_message proc~allocate_rank1_int8->proc~error_message proc~allocate_rank1_logical1->proc~error_message proc~allocate_rank1_logical4->proc~error_message proc~allocate_rank1_logical8->proc~error_message proc~allocate_rank1_real128->proc~error_message proc~allocate_rank1_real32->proc~error_message proc~allocate_rank1_real64->proc~error_message proc~allocate_rank2_int16->proc~error_message proc~allocate_rank2_int32->proc~error_message proc~allocate_rank2_int64->proc~error_message proc~allocate_rank2_int8->proc~error_message proc~allocate_rank2_logical1->proc~error_message proc~allocate_rank2_logical4->proc~error_message proc~allocate_rank2_logical8->proc~error_message proc~allocate_rank2_real128->proc~error_message proc~allocate_rank2_real32->proc~error_message proc~allocate_rank2_real64->proc~error_message proc~calc_hydraulic_properties_impl_array type_properties_manager%calc_hydraulic_properties_impl_array proc~calc_hydraulic_properties_array->proc~calc_hydraulic_properties_impl_array proc~get_pointers_for_region type_properties_manager%get_pointers_for_region proc~calc_hydraulic_properties_array->proc~get_pointers_for_region proc~calc_hydraulic_properties_impl_scalar type_properties_manager%calc_hydraulic_properties_impl_scalar proc~calc_hydraulic_properties_scalar->proc~calc_hydraulic_properties_impl_scalar proc~calc_hydraulic_properties_scalar->proc~get_pointers_for_region proc~deallocate_rank1_int32->proc~error_message proc~deallocate_rank1_int64->proc~error_message proc~deallocate_rank1_int8->proc~error_message proc~deallocate_rank1_logical1->proc~error_message proc~deallocate_rank1_logical4->proc~error_message proc~deallocate_rank1_logical8->proc~error_message proc~deallocate_rank1_real128->proc~error_message proc~deallocate_rank1_real32->proc~error_message proc~deallocate_rank1_real64->proc~error_message proc~deallocate_rank2_int32->proc~error_message proc~deallocate_rank2_int64->proc~error_message proc~deallocate_rank2_int8->proc~error_message proc~deallocate_rank2_logical1->proc~error_message proc~deallocate_rank2_logical4->proc~error_message proc~deallocate_rank2_logical8->proc~error_message proc~deallocate_rank2_real128->proc~error_message proc~deallocate_rank2_real32->proc~error_message proc~deallocate_rank2_real64->proc~error_message proc~multiply_matrix_vector multiply_matrix_vector proc~type_dense_gemv->proc~multiply_matrix_vector calc_kflh calc_kflh proc~calc_hydraulic_properties_impl_array->calc_kflh proc~calc_hydraulic_properties_impl_scalar->calc_kflh log_error log_error proc~error_message->log_error proc~get_den_ptr type_material_manager%get_den_ptr proc~get_pointers_for_region->proc~get_den_ptr proc~get_gcc_ptr type_material_manager%get_gcc_ptr proc~get_pointers_for_region->proc~get_gcc_ptr proc~get_hcf_ptr type_material_manager%get_hcf_ptr proc~get_pointers_for_region->proc~get_hcf_ptr proc~get_thc_ptr type_material_manager%get_thc_ptr proc~get_pointers_for_region->proc~get_thc_ptr proc~get_vhc_ptr type_material_manager%get_vhc_ptr proc~get_pointers_for_region->proc~get_vhc_ptr proc~get_wrf_ptr type_material_manager%get_wrf_ptr proc~get_pointers_for_region->proc~get_wrf_ptr

Called by

proc~~process_element_hydraulic_linear_1~~CalledByGraph proc~process_element_hydraulic_linear_1 process_element_hydraulic_linear_1 proc~hydraulic_assemble_system_linear_1 hydraulic_assemble_system_linear_1 proc~hydraulic_assemble_system_linear_1->proc~process_element_hydraulic_linear_1 proc~hydraulic_assemble_system_linear_1_parallel hydraulic_assemble_system_linear_1_parallel proc~hydraulic_assemble_system_linear_1_parallel->proc~process_element_hydraulic_linear_1

Source Code

    subroutine process_element_hydraulic_linear_1(J, R, element, pressure, temperature, ice, porosity, &
                                                  properties, controls, actual_order)
        implicit none
        ! --- arguments ---
        type(type_crs), intent(inout) :: J
        real(real64), intent(inout) :: R(:)
        class(abst_mesh), intent(in), pointer :: element
        type(type_variable), intent(in) :: pressure
        type(type_variable), intent(in) :: temperature
        type(type_variable), intent(in) :: ice
        type(type_variable), intent(in) :: porosity
        type(type_properties_manager), intent(in) :: properties
        type(type_controls), intent(in) :: controls
        integer(int32), intent(in) :: actual_order

        ! --- Local variables ---
        integer(int32) :: index, num_nodes, num_gauss, material_id, il, jl, iG, iO
        real(real64) :: weight, detJ
        real(real64) :: dNdx_i, dNdy_i, dNdx_j, dNdy_j
        real(real64) :: val, zeta
        real(real64) :: dt

        ! --- Workspace variables ---
        type(type_dense) :: CH_e
        type(type_dense) :: KH_e
        type(type_dense) :: J_e
        real(real64), allocatable :: R_e(:)

        ! --- Physical quantities at Gauss points ---
        type(type_state), allocatable :: state(:)
        real(real64), dimension(:), pointer :: p_weight => null()
        type(type_dp_vector_3d), dimension(:), pointer :: p_gauss => null()
        real(real64), allocatable :: kflh(:)
        real(real64), allocatable :: dot_ice(:)
        integer(int32), dimension(:), pointer :: p_conn => null()

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 0: Initialize and obtain sizes
        !---------------------------------------------------------------------------------------------------------------------------
        num_nodes   = element%get_num_nodes() !&
        num_gauss   = element%get_num_gauss() !&
        material_id = element%get_group() !&
        if (.not. controls%is_target(calc_hydraulic, material_id)) return

        call CH_e%initialize_local(num_nodes)
        call KH_e%initialize_local(num_nodes)
        call J_e%initialize_local(num_nodes)
        call allocate_array(R_e, num_nodes)
        allocate (state(num_gauss))
        call allocate_array(kflh, num_gauss)
        call allocate_array(dot_ice, num_nodes)

        dt = controls%time%get_dt()
        p_weight => element%get_weight()
        p_gauss => element%get_gauss()
        p_conn => element%get_connectivity()

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 1: Compute the physical quantities at all Gauss points
        !---------------------------------------------------------------------------------------------------------------------------
        do iG = 1, num_gauss
            state(iG)%temperature = element%lerp(p_gauss(iG), temperature%pre) !&
            state(iG)%pressure    = element%lerp(p_gauss(iG), pressure%pre) !&
            state(iG)%porosity    = element%lerp(p_gauss(iG), porosity%pre) !&
        end do
        call properties%calc_hydraulic(material_id, state, kflh)

        do il = 1, num_nodes
            dot_ice(il) = ice%dif(p_conn(il)) / dt
        end do

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 2: Compute the element matrices CH_e and KH_e
        !---------------------------------------------------------------------------------------------------------------------------
        do iG = 1, num_gauss
            weight = p_weight(iG) !&
            detJ   = element%jacobian_det(p_gauss(iG)) !&
            zeta   = state(iG)%density_ice / state(iG)%density_water - 1.0d0 !&
            do il = 1, num_nodes
                dNdx_i = ( element%jacobian(2, 2, p_gauss(iG)) * element%dpsi(il, 1, p_gauss(iG)) - & !&
                           element%jacobian(2, 1, p_gauss(iG)) * element%dpsi(il, 2, p_gauss(iG))) / detJ !&
                dNdy_i = (-element%jacobian(1, 2, p_gauss(iG)) * element%dpsi(il, 1, p_gauss(iG)) + & !&
                           element%jacobian(1, 1, p_gauss(iG)) * element%dpsi(il, 2, p_gauss(iG))) / detJ !&
                do jl = 1, num_nodes
                    dNdx_j = ( element%jacobian(2, 2, p_gauss(iG)) * element%dpsi(jl, 1, p_gauss(iG)) - & !&
                               element%jacobian(2, 1, p_gauss(iG)) * element%dpsi(jl, 2, p_gauss(iG))) / detJ !&
                    dNdy_j = (-element%jacobian(1, 2, p_gauss(iG)) * element%dpsi(jl, 1, p_gauss(iG)) + & !&
                               element%jacobian(1, 1, p_gauss(iG)) * element%dpsi(jl, 2, p_gauss(iG))) / detJ !&

                    val = element%psi(il, p_gauss(iG)) * element%psi(jl, p_gauss(iG)) * zeta * weight * detJ
                    call CH_e%add(il, jl, val)
                    val = (dNdx_i * dNdx_j + dNdy_i * dNdy_j) * kflh(iG) * weight * detJ
                    call KH_e%add(il, jl, val)
                end do
            end do
        end do

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 3: Build the final local matrix (J_e) and vector (R_e)
        !---------------------------------------------------------------------------------------------------------------------------
        call add(0.0d0, KH_e, CH_e, J_e)
        call gemv(-1.0d0, CH_e, dot_ice, 0.0d0, R_e)

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 4: Assemble the global matrix and vector
        !---------------------------------------------------------------------------------------------------------------------------
        do il = 1, num_nodes
            R(p_conn(il)) = R(p_conn(il)) + R_e(il)
            do jl = 1, num_nodes
                call J%add(p_conn(il), p_conn(jl), J_e%val(il, jl))
            end do
        end do

        !---------------------------------------------------------------------------------------------------------------------------
        ! STEP 5: Finalization
        !---------------------------------------------------------------------------------------------------------------------------
        call deallocate_array(kflh)
        call deallocate_array(R_e)
        call J_e%destroy()
        call KH_e%destroy()
        call CH_e%destroy()
        deallocate (state)

    end subroutine process_element_hydraulic_linear_1