34 itrifaceenter, itrifaceexit, &
35 alp1, bet1, alp2, bet2, alpi, beti)
37 integer(I4B),
intent(in) :: isolv
38 real(dp),
intent(in) :: tol
39 real(dp),
intent(inout) :: texit
40 real(dp),
intent(inout) :: alpexit
41 real(dp),
intent(inout) :: betexit
42 integer(I4B),
intent(in) :: itrifaceenter
43 integer(I4B),
intent(inout) :: itrifaceexit
44 real(dp),
intent(in) :: alp1
45 real(dp),
intent(in) :: bet1
46 real(dp),
intent(in) :: alp2
47 real(dp),
intent(in) :: bet2
48 real(dp),
intent(in) :: alpi
49 real(dp),
intent(in) :: beti
70 texit0, alpexit0, betexit0)
73 texit1, alpexit1, betexit1)
76 texit2, alpexit2, betexit2)
77 texit = min(texit0, texit1, texit2)
81 if (texit .eq. texit0)
then
85 else if (texit .eq. texit1)
then
89 else if (texit .eq. texit2)
then
94 if (texit .eq. huge(1d0))
then
113 real(DP),
intent(in) :: beti
114 real(DP),
intent(inout) :: texit
115 real(DP),
intent(inout) :: alpexit
116 real(DP),
intent(inout) :: betexit
117 integer(I4B),
intent(inout) :: itrifaceexit
123 integer(I4B) :: ibettrend
126 if (ibettrend .lt. 0 .and. betsollo .lt.
dzero)
then
128 if (t .le.
dzero)
return
133 else if (ibettrend .gt. 0 .and. betsolhi .gt.
done)
then
135 if (t .le.
dzero)
return
146 v0x, v0y, v1x, v1y, v2x, v2y, &
148 rxx, rxy, ryx, ryy, &
150 alp0, bet0, alp1, bet1, alp2, bet2, alpi, beti)
152 real(dp),
intent(in) :: x0
153 real(dp),
intent(in) :: y0
154 real(dp),
intent(in) :: x1
155 real(dp),
intent(in) :: y1
156 real(dp),
intent(in) :: x2
157 real(dp),
intent(in) :: y2
158 real(dp),
intent(in) :: v0x
159 real(dp),
intent(in) :: v0y
160 real(dp),
intent(in) :: v1x
161 real(dp),
intent(in) :: v1y
162 real(dp),
intent(in) :: v2x
163 real(dp),
intent(in) :: v2y
164 real(dp),
intent(in) :: xi
165 real(dp),
intent(in) :: yi
166 real(dp),
intent(out) :: rxx
167 real(dp),
intent(out) :: rxy
168 real(dp),
intent(out) :: ryx
169 real(dp),
intent(out) :: ryy
170 real(dp),
intent(out) :: sxx, sxy, syy
171 real(dp),
intent(out) :: alp0
172 real(dp),
intent(out) :: bet0
173 real(dp),
intent(out) :: alp1
174 real(dp),
intent(out) :: bet1
175 real(dp),
intent(out) :: alp2
176 real(dp),
intent(out) :: bet2
177 real(dp),
intent(out) :: alpi
178 real(dp),
intent(out) :: beti
181 real(dp) :: oobaselen
190 real(dp) :: rot(2, 2), res(2)
197 baselen = dsqrt(x1diff * x1diff + y1diff * y1diff)
198 oobaselen =
done / baselen
199 cosomega = x1diff * oobaselen
200 sinomega = y1diff * oobaselen
210 rot = reshape((/rxx, ryx, rxy, ryy/), shape(rot))
211 res = matmul(rot, (/x2diff, y2diff/))
215 cv0 = matmul(rot, (/v0x, v0y/))
216 cv1 = matmul(rot, (/v1x, v1y/))
217 cv2 = matmul(rot, (/v2x, v2y/))
221 res = matmul(rot, (/xidiff, yidiff/))
227 sxy = -alp2 * sxx * syy
235 res =
skew(res, (/sxx, sxy, syy/))
243 alp1, bet1, alp2, bet2, &
255 real(dp) :: v1alpdiff
256 real(dp) :: v2alpdiff
257 real(dp) :: v2betdiff
261 v1alpdiff =
cv1(1) -
cv0(1)
262 v2alpdiff =
cv2(1) -
cv0(1)
263 v2betdiff =
cv2(2) -
cv0(2)
287 if (dabs(
wbb) .gt. zerotol)
then
289 acoef =
cv0(1) - wratv
290 bcoef = wratv +
wab * beti
297 if (dabs(
waa) .gt. zerotol)
then
299 if (dabs(
wbb -
waa) .gt. zerotol)
then
301 bfact = bcoef / (
wbb -
waa)
303 ca2 = alpi + afact - bfact
325 if (dabs(
waa) .gt. zerotol)
then
328 vfact = (
wab * oowaa) *
cv0(2)
329 ca1 = -oowaa * (
cv0(1) +
wab * beti + vfact)
347 real(dp),
intent(in) :: t
351 if (
icase .eq. 1)
then
354 else if (
icase .eq. -1)
then
357 else if (
icase .eq. 2)
then
360 else if (
icase .eq. 3)
then
363 else if (
icase .eq. 4)
then
373 texit, alpexit, betexit)
375 integer(I4B) :: isolv
376 integer(I4B) :: itriface
377 integer(I4B) :: itrifaceenter
394 real(dp) :: v0alpstar
405 integer(I4B) :: ibettrend
411 if (itriface .eq. 0)
then
413 if (itrifaceenter .eq. 0)
then
426 vbeti =
cv0(2) +
wbb * beti
427 if (vbeti .ge.
dzero)
then
433 if ((alpt .ge.
dzero) .and. (alpt .le.
done))
then
448 if (itriface .eq. 1)
then
457 if ((v1n .ge.
dzero) .and. (v2n .ge.
dzero))
then
466 if (ibettrend .eq. 0)
then
469 if ((beti .gt. betouthi) .or. (beti .lt. betoutlo))
then
476 v0alpstar =
cv0(1) +
wab * beti
477 valpi = v0alpstar +
waa * alpi
478 if ((itriface .eq. 1) .and. (valpi .le.
dzero))
then
481 else if ((itriface .eq. 2) .and. (valpi .ge.
dzero))
then
486 if (itriface .eq. 1)
then
487 alpexit =
done - beti
492 if (dabs(
waa) > zerotol)
then
493 alplim = -v0alpstar /
waa
494 texit = dlog(alpexit - alplim / (alpi - alplim)) /
waa
496 texit = (alpexit - alpi) / v0alpstar
503 bethi = min(betouthi, betsolhi)
504 betlo = max(betoutlo, betsollo)
505 if (betlo .gt. bethi)
then
512 if (itriface .eq. 1)
then
513 fax =
done - betlo - alplo
514 fbx =
done - bethi - alphi
519 if (fax * fbx .gt.
dzero)
then
523 if (isolv .eq. 1)
then
526 call soln_brent(itriface, betlo, bethi, tol, texit, &
528 else if (isolv .eq. 2)
then
531 call soln_chand(itriface, betlo, bethi, tol, texit, &
534 call pstop(1,
"Invalid isolv, expected one of: 1, 2")
544 if (texit .ne. huge(
done) .and. texit .lt.
dzero)
then
545 call pstop(1,
"texit is negative (unexpected)")
553 real(dp),
intent(in) :: bet
561 fb =
done - alpt - bet
567 real(dp),
intent(in) :: bet
581 real(dp),
intent(in) :: bet
598 if (
icase .eq. 1)
then
599 term = max(term, zerotol)
602 if (waat > waatlim)
then
603 alp = sign(ewaatlim,
ca2)
605 alp =
ca1 +
ca2 * dexp(waat) +
ca3 * term
607 else if (
icase .eq. -1)
then
608 term = max(term, zerotol)
612 if (waat > waatlim)
then
613 alp = sign(ewaatlim, coef)
615 alp =
ca1 + coef * dexp(waat)
617 else if (
icase .eq. 2)
then
618 term = max(term, zerotol)
621 else if (
icase .eq. 3)
then
624 if (waat > waatlim)
then
625 alp = sign(ewaatlim,
ca3)
629 else if (
icase .eq. 4)
then
647 if (vn1 .lt.
dzero)
then
650 if (vn2 .le.
dzero)
then
655 betouthi = -vn1 / vndiff
660 if (vn1 .le.
dzero)
then
665 betoutlo = -vn1 / vndiff
674 real(dp),
intent(in) :: beti
677 integer(I4B),
intent(inout) :: ibettrend
683 betsolhi = huge(
done)
688 betsollo = -huge(
done)
697 if (beti .gt. betlim)
then
698 betsolhi = huge(
done)
701 else if (beti .lt. betlim)
then
703 betsollo = -huge(
done)
712 if (beti .gt. betlim)
then
716 else if (beti .lt. betlim)
then
731 texit, alpexit, betexit)
733 integer(I4B),
intent(in) :: itriface
736 real(dp),
intent(in) :: tol
743 procedure(
f1d),
pointer :: f
748 if (itriface .eq. 1)
then
750 betexit =
zero_br(blo, bhi, f, tol)
753 betexit =
zero_br(blo, bhi, f, tol)
761 texit, alpexit, betexit)
763 integer(I4B),
intent(in) :: itriface
766 real(dp),
intent(in) :: tol
773 procedure(
f1d),
pointer :: f
778 if (itriface .eq. 1)
then
780 betexit =
zero_ch(blo, bhi, f, tol)
783 betexit =
zero_ch(blo, bhi, f, tol)
This module contains simulation constants.
real(dp), parameter dzero
real constant zero
real(dp), parameter dprec
real constant machine precision
real(dp), parameter done
real constant 1
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
pure real(dp) function, dimension(2), public skew(v, s, invert)
Skew a 2D vector along the x-axis.
This module defines variable data types.
real(dp) function, public zero_ch(x0, x1, f, epsa)
Compute zeros on an interval using Chadrupatla's method.
real(dp) function, public zero_br(ax, bx, f, tol)
Compute a zero of the function f(x) in the interval (x0, x1).
subroutine, public traverse_triangle(isolv, tol, texit, alpexit, betexit, itrifaceenter, itrifaceexit, alp1, bet1, alp2, bet2, alpi, beti)
Traverse triangular cell.
subroutine, public get_w(alp1, bet1, alp2, bet2, waa, wab, wba, wbb)
Compute elements of W matrix.
integer(i4b) icase
Case index for analytical solution.
real(dp) cb2
Analytical solution coefficients.
real(dp) function fbary2(bet)
Brent's method applied to canonical face 2 (alpha = 0).
real(dp) function fbary1(bet)
Brent's method applied to canonical face 1 (gamma = 0).
real(dp), dimension(2) cv0
subroutine, public step_analytical(t, alp, bet)
Step (evaluate) analytically depending on case.
subroutine, public solve_coefs(alpi, beti)
Compute analytical solution coefficients depending on case.
subroutine, public get_t_alpt(bet, t, alp)
Given beta evaluate t and alpha depending on case.
subroutine, public canonical(x0, y0, x1, y1, x2, y2, v0x, v0y, v1x, v1y, v2x, v2y, xi, yi, rxx, rxy, ryx, ryy, sxx, sxy, syy, alp0, bet0, alp1, bet1, alp2, bet2, alpi, beti)
Set coordinates to "canonical" configuration.
subroutine exit_at_vertex(beti, texit, alpexit, betexit, itrifaceexit)
Exit at a vertex when no face finds an exit.
real(dp) wbb
Elements of the "velocity matrix," W.
real(dp), dimension(2) cv1
real(dp), dimension(2) cv2
"Canonical" velocity components at corners of triangular subcell
subroutine, public get_bet_soln_limits(beti, betsollo, betsolhi, ibettrend)
Find trend of and limits on beta from beta{t} solution.
subroutine, public find_exit_bary(isolv, itriface, itrifaceenter, alpi, beti, tol, texit, alpexit, betexit)
Find the exit time and location in barycentric coordinates.
subroutine, public soln_chand(itriface, betlo, bethi, tol, texit, alpexit, betexit)
Use Chandrupatla's method with initial bounds on beta of betlo and bethi.
subroutine, public soln_brent(itriface, betlo, bethi, tol, texit, alpexit, betexit)
Use Brent's method with initial bounds on beta of betlo and bethi.
subroutine, public get_bet_outflow_bary(vn1, vn2, betoutlo, betouthi)
Find outflow interval.