Subroutine to calculate the characteristic length of an element, giving
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8), | intent(in) | :: | spdx | fluid velocity along axis |
||
real(kind=R8), | intent(in) | :: | spdy | fluid velocity along axis |
||
real(kind=R8), | intent(in), | dimension(4) | :: | x | corner abscissae |
|
real(kind=R8), | intent(in), | dimension(4) | :: | y | corner ordinates |
|
real(kind=R8), | intent(out) | :: | length | fluid element length |
||
real(kind=R8), | intent(out) | :: | width | fluid element width |
subroutine length_width_elem(spdx, spdy, x, y, length, width)
implicit none
real(kind=R8), intent(in ) :: spdx !! *fluid velocity along \(x\) axis*
real(kind=R8), intent(in ) :: spdy !! *fluid velocity along \(y\) axis*
real(kind=R8), intent(in ), dimension(4) :: x !! *corner abscissae*
real(kind=R8), intent(in ), dimension(4) :: y !! *corner ordinates*
real(kind=R8), intent(out) :: length !! *fluid element length*
real(kind=R8), intent(out) :: width !! *fluid element width*
real(kind=R8) :: abx, adx, cbx, cdx, &
aby, ady, cby, cdy, &
acx, bdx, acy, bdy, &
el_S, px, py, pm, spd, &
ac_dot_p, bd_dot_p, ab_dot_p, &
ad_dot_p, cb_dot_p, cd_dot_p, &
x1, x2, x3, x4, y1, y2, y3, y4
length = 0.
width = 0.
spd = sqrt(spdx**2 +spdy**2)
if (spd > EPS_R8) then
px = -spdy ! direction perpendicular to vector v
py = +spdx
pm = spd
x1 = x(1) ; y1 = y(1)
x2 = x(2) ; y2 = y(2)
x3 = x(3) ; y3 = y(3)
x4 = x(4) ; y4 = y(4)
acx = x3 -x1 ; acy = y3 -y1
bdx = x4 -x2 ; bdy = y4 -y2
abx = x2 -x1 ; aby = y2 -y1
adx = x4 -x1 ; ady = y4 -y1
cbx = x2 -x3 ; cby = y2 -y3
cdx = x4 -x3 ; cdy = y4 -y3
ac_dot_p = abs( px*acx +py*acy )
bd_dot_p = abs( px*bdx +py*bdy )
ab_dot_p = abs( px*abx +py*aby )
ad_dot_p = abs( px*adx +py*ady )
cb_dot_p = abs( px*cbx +py*cby )
cd_dot_p = abs( px*cdx +py*cdy )
! quadrangle projection on the perpendicular to v
width = max(ac_dot_p, bd_dot_p, ab_dot_p, &
ad_dot_p, cb_dot_p, cd_dot_p)/pm
! quadrangle area
el_S = 0.5*( abs(cbx*cdy -cdx*cby) +abs(abx*ady -adx*aby) )
! element length
length = el_S/width
endif
return
endsubroutine length_width_elem