tem_createBox Subroutine

public subroutine tem_createBox(me, origin, vecA, vecB, vecC, only_surface)

This routine creates box from canoND definition i.en origin and three vectors. If only_surface is defined then box is converted further to plane and then to triangles. \verbatim vecB_vecC /\ - | | - | | - | | - | |- | |------------>| origin vecA \endverbatim

Arguments

Type IntentOptional Attributes Name
type(tem_box_type), intent(out) :: me
real(kind=rk), intent(in) :: origin(3)
real(kind=rk), intent(in) :: vecA(3)
real(kind=rk), intent(in) :: vecB(3)
real(kind=rk), intent(in) :: vecC(3)
logical, intent(in) :: only_surface

Calls

proc~~tem_createbox~~CallsGraph proc~tem_createbox tem_createBox proc~tem_createplane tem_createPlane proc~tem_createbox->proc~tem_createplane proc~cross_product3d cross_product3D proc~tem_createplane->proc~cross_product3d

Called by

proc~~tem_createbox~~CalledByGraph proc~tem_createbox tem_createBox proc~tem_load_onecanonicalnd tem_load_oneCanonicalND proc~tem_load_onecanonicalnd->proc~tem_createbox interface~tem_load_canonicalnd tem_load_canonicalND interface~tem_load_canonicalnd->proc~tem_load_onecanonicalnd proc~tem_load_canonicalnd_vec tem_load_canonicalND_vec interface~tem_load_canonicalnd->proc~tem_load_canonicalnd_vec proc~tem_load_canonicalnd_vec->proc~tem_load_onecanonicalnd proc~tem_load_shape_single tem_load_shape_single proc~tem_load_shape_single->interface~tem_load_canonicalnd interface~tem_load_shape tem_load_shape interface~tem_load_shape->proc~tem_load_shape_single proc~tem_load_shapes tem_load_shapes proc~tem_load_shapes->proc~tem_load_shape_single

Source Code

  subroutine tem_createBox(me, origin, vecA, vecB, vecC, only_surface)
    !--------------------------------------------------------------------------!
    type(tem_box_type), intent(out) :: me !< plane to return
    real(kind=rk), intent(in) :: origin(3) !< plane origin
    real(kind=rk), intent(in) :: vecA(3) !< 1st vector
    real(kind=rk), intent(in) :: vecB(3) !< 2nd vector
    real(kind=rk), intent(in) :: vecC(3) !< 3nd vector
    logical, intent(in) :: only_surface
    !--------------------------------------------------------------------------!
    real(kind=rk) :: extent
    real(kind=rk) :: secondOrigin(3)
    ! -------------------------------------------------------------------------!
    me%only_surface = only_surface
    if (only_surface) then
      ! convert box to planes
      ! planes 1,2,3
      call tem_createPlane(me = me%plane(1), origin = origin, &
        &                  vecA = vecA, vecB = vecB           )

      call tem_createPlane(me = me%plane(2), origin = origin, &
        &                  vecA = vecA, vecB = vecC           )

      call tem_createPlane(me = me%plane(3), origin = origin, &
        &                  vecA = vecB, vecB = vecC           )

      ! planes 4,5,6
      secondOrigin = origin + vecA + vecB + vecC
      call tem_createPlane(me = me%plane(4), origin = secondOrigin, &
        &                  vecA = -vecA, vecB = -vecB               )

      call tem_createPlane(me = me%plane(5), origin = secondOrigin, &
        &                  vecA = -vecA, vecB = -vecC               )

      call tem_createPlane(me = me%plane(6), origin = secondOrigin, &
        &                  vecA = -vecB, vecB = -vecC               )

    else ! convert me to box
      !vector is normalized first and then converted to half vector
      !length of the vector
      extent = sqrt(dot_product(vecA(:),vecA(:)))
      !normal of the vector(unitNormal)
      me%normal(:,1) = vecA(:)/extent
      !halfwidth of the vector
      me%halfwidth(1) = extent*0.5_rk
      !halfvector
      me%halfvec(:,1) = 0.5_rk*vecA(:)

      !length of the vector
      extent = sqrt(dot_product(vecB(:),vecB(:)))
      !normal of the vector(unitNormal)
      me%normal(:,2) = vecB(:)/extent
      !halfwidth of the vector
      me%halfwidth(2) = extent*0.5_rk
      !halfvector
      me%halfvec(:,2) = 0.5_rk*vecB(:)

      !length of the vector
      extent = sqrt(dot_product(vecC(:),vecC(:)))
      !normal of the vector(unitNormal)
      me%normal(:,3) = vecC(:)/extent
      !halfwidth of the vector
      me%halfwidth(3) = extent*0.5_rk
      !halfvector
      me%halfvec(:,3) = 0.5_rk*vecC(:)

      me%center = origin          &
        &       + me%halfvec(:,1) &
        &       + me%halfvec(:,2) &
        &       + me%halfvec(:,3)

    end if

  end subroutine tem_createBox