tem_evaluate_normal_triangle Subroutine

public subroutine tem_evaluate_normal_triangle(triangle)

Compute, the outward normal of a triangle. To work nodes must be in counter-clockwise order. For STL this is the standard. It follows pg 136 of Jiri Blaze, CFD Principles and Applications

Arguments

Type IntentOptional Attributes Name
type(tem_triangle_type), intent(inout) :: triangle

Contents


Source Code

  subroutine tem_evaluate_normal_triangle(triangle)
    !--------------------------------------------------------------------------!
    type(tem_triangle_type), intent(inout) :: triangle
    !--------------------------------------------------------------------------!
    real(kind=rk) :: outward_vector(3), delta_x(3), delta_y(3), delta_z(3)
    real(kind=rk) :: magnitude_normal
    !--------------------------------------------------------------------------!

    ! Eq.s 5.8
    delta_x(1) = ( triangle%nodes(1,1) - triangle%nodes(1,2) ) * &
      &          ( triangle%nodes(2,1) + triangle%nodes(2,2) )
    delta_x(2) = ( triangle%nodes(1,2) - triangle%nodes(1,3) ) * &
      &          ( triangle%nodes(2,2) + triangle%nodes(2,3) )
    delta_x(3) = ( triangle%nodes(1,3) - triangle%nodes(1,1) ) * &
      &          ( triangle%nodes(2,3) + triangle%nodes(2,1) )
    delta_y(1) = ( triangle%nodes(2,1) - triangle%nodes(2,2) ) * &
      &          ( triangle%nodes(3,1) + triangle%nodes(3,2) )
    delta_y(2) = ( triangle%nodes(2,2) - triangle%nodes(2,3) ) * &
      &          ( triangle%nodes(3,2) + triangle%nodes(3,3) )
    delta_y(3) = ( triangle%nodes(2,3) - triangle%nodes(2,1) ) * &
      &          ( triangle%nodes(3,3) + triangle%nodes(3,1) )
    delta_z(1) = ( triangle%nodes(3,1) - triangle%nodes(3,2) ) * &
      &          ( triangle%nodes(1,1) + triangle%nodes(1,2) )
    delta_z(2) = ( triangle%nodes(3,2) - triangle%nodes(3,3) ) * &
      &          ( triangle%nodes(1,2) + triangle%nodes(1,3) )
    delta_z(3) = ( triangle%nodes(3,3) - triangle%nodes(3,1) ) * &
      &          ( triangle%nodes(1,3) + triangle%nodes(1,1) )

    ! Eq.s 5.9
    outward_vector(1) = 0.5_rk * ( delta_y(1) + delta_y(2) + delta_y(3) )
    outward_vector(2) = 0.5_rk * ( delta_z(1) + delta_z(2) + delta_z(3) )
    outward_vector(3) = 0.5_rk * ( delta_x(1) + delta_x(2) + delta_x(3) )

    ! Eq.s 5.12
    magnitude_normal = sqrt( outward_vector(1)**2 + outward_vector(2)**2 + outward_vector(3)**2 )

    ! normalization of the outward_vector
    triangle%normal(:) = outward_vector(:) / magnitude_normal

  end subroutine tem_evaluate_normal_triangle