MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
ternarysolveutils Module Reference

Functions/Subroutines

subroutine, public traverse_triangle (isolv, tol, texit, alpexit, betexit, itrifaceenter, itrifaceexit, alp1, bet1, alp2, bet2, alpi, beti)
 Traverse triangular cell.
subroutine exit_at_vertex (beti, texit, alpexit, betexit, itrifaceexit)
 Exit at a vertex when no face finds an exit.
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, public get_w (alp1, bet1, alp2, bet2, waa, wab, wba, wbb)
 Compute elements of W matrix.
subroutine, public solve_coefs (alpi, beti)
 Compute analytical solution coefficients depending on case.
subroutine, public step_analytical (t, alp, bet)
 Step (evaluate) analytically depending on case.
subroutine, public find_exit_bary (isolv, itriface, itrifaceenter, alpi, beti, tol, texit, alpexit, betexit)
 Find the exit time and location in barycentric coordinates.
real(dp) function fbary1 (bet)
 Brent's method applied to canonical face 1 (gamma = 0).
real(dp) function fbary2 (bet)
 Brent's method applied to canonical face 2 (alpha = 0).
subroutine, public get_t_alpt (bet, t, alp)
 Given beta evaluate t and alpha depending on case.
subroutine, public get_bet_outflow_bary (vn1, vn2, betoutlo, betouthi)
 Find outflow interval.
subroutine, public get_bet_soln_limits (beti, betsollo, betsolhi, ibettrend)
 Find trend of and limits on beta from beta{t} solution.
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 soln_chand (itriface, betlo, bethi, tol, texit, alpexit, betexit)
 Use Chandrupatla's method with initial bounds on beta of betlo and bethi.

Variables

real(dp) ca1
real(dp) ca2
real(dp) ca3
real(dp) cb1
real(dp) cb2
 Analytical solution coefficients.
real(dp) waa
real(dp) wab
real(dp) wba
real(dp) wbb
 Elements of the "velocity matrix," W.
real(dp), dimension(2) cv0
real(dp), dimension(2) cv1
real(dp), dimension(2) cv2
 "Canonical" velocity components at corners of triangular subcell
integer(i4b) icase
 Case index for analytical solution.

Function/Subroutine Documentation

◆ canonical()

subroutine, public ternarysolveutils::canonical ( real(dp), intent(in) x0,
real(dp), intent(in) y0,
real(dp), intent(in) x1,
real(dp), intent(in) y1,
real(dp), intent(in) x2,
real(dp), intent(in) y2,
real(dp), intent(in) v0x,
real(dp), intent(in) v0y,
real(dp), intent(in) v1x,
real(dp), intent(in) v1y,
real(dp), intent(in) v2x,
real(dp), intent(in) v2y,
real(dp), intent(in) xi,
real(dp), intent(in) yi,
real(dp), intent(out) rxx,
real(dp), intent(out) rxy,
real(dp), intent(out) ryx,
real(dp), intent(out) ryy,
real(dp), intent(out) sxx,
real(dp), intent(out) sxy,
real(dp), intent(out) syy,
real(dp), intent(out) alp0,
real(dp), intent(out) bet0,
real(dp), intent(out) alp1,
real(dp), intent(out) bet1,
real(dp), intent(out) alp2,
real(dp), intent(out) bet2,
real(dp), intent(out) alpi,
real(dp), intent(out) beti )
Parameters
[out]ryyrotation matrix
[out]syyskew matrix entries (top left, top right, bottom right)
[out]betialpha and beta coefficients

Definition at line 145 of file TernarySolveUtils.f90.

151 ! dummy
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 !< rotation matrix
170 real(DP), intent(out) :: sxx, sxy, syy !< skew matrix entries (top left, top right, bottom right)
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 !< alpha and beta coefficients
179 ! local
180 real(DP) :: baselen
181 real(DP) :: oobaselen
182 real(DP) :: sinomega
183 real(DP) :: cosomega
184 real(DP) :: x1diff
185 real(DP) :: y1diff
186 real(DP) :: x2diff
187 real(DP) :: y2diff
188 real(DP) :: xidiff
189 real(DP) :: yidiff
190 real(DP) :: rot(2, 2), res(2)
191
192 ! Translate and rotate coordinates to "canonical" configuration
193 x1diff = x1 - x0
194 y1diff = y1 - y0
195 x2diff = x2 - x0
196 y2diff = y2 - y0
197 baselen = dsqrt(x1diff * x1diff + y1diff * y1diff)
198 oobaselen = done / baselen
199 cosomega = x1diff * oobaselen
200 sinomega = y1diff * oobaselen
201 rxx = cosomega
202 rxy = sinomega
203 ryx = -sinomega
204 ryy = cosomega
205 alp0 = dzero
206 bet0 = dzero
207 alp1 = baselen
208 bet1 = dzero
209
210 rot = reshape((/rxx, ryx, rxy, ryy/), shape(rot))
211 res = matmul(rot, (/x2diff, y2diff/))
212 alp2 = res(1)
213 bet2 = res(2)
214
215 cv0 = matmul(rot, (/v0x, v0y/))
216 cv1 = matmul(rot, (/v1x, v1y/))
217 cv2 = matmul(rot, (/v2x, v2y/))
218
219 xidiff = xi - x0
220 yidiff = yi - y0
221 res = matmul(rot, (/xidiff, yidiff/))
222 alpi = res(1)
223 beti = res(2)
224
225 sxx = done / alp1
226 syy = done / bet2
227 sxy = -alp2 * sxx * syy
228 alp1 = done
229 alp2 = dzero
230 bet2 = done
231 cv0 = skew(cv0, (/sxx, sxy, syy/))
232 cv1 = skew(cv1, (/sxx, sxy, syy/))
233 cv2 = skew(cv2, (/sxx, sxy, syy/))
234 res = (/alpi, beti/)
235 res = skew(res, (/sxx, sxy, syy/))
236 alpi = res(1)
237 beti = res(2)
238
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exit_at_vertex()

subroutine ternarysolveutils::exit_at_vertex ( real(dp), intent(in) beti,
real(dp), intent(inout) texit,
real(dp), intent(inout) alpexit,
real(dp), intent(inout) betexit,
integer(i4b), intent(inout) itrifaceexit )
private

A trajectory that leaves the triangle crosses a face. When none reports a crossing, roundoff has put the crossing just past a vertex, where two faces meet. Beta is monotone along the trajectory, so if it reaches 0 the particle exits through face 0 (beta = 0) at that time, at the nearer end of it, and if it reaches 1 it exits at vertex 2 (beta = 1). If beta reaches neither, the particle approaches a stagnation point and no exit is set.

Definition at line 111 of file TernarySolveUtils.f90.

112 ! dummy
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
118 ! local
119 real(DP) :: betsollo
120 real(DP) :: betsolhi
121 real(DP) :: t
122 real(DP) :: alpt
123 integer(I4B) :: ibettrend
124
125 call get_bet_soln_limits(beti, betsollo, betsolhi, ibettrend)
126 if (ibettrend .lt. 0 .and. betsollo .lt. dzero) then
127 call get_t_alpt(dzero, t, alpt)
128 if (t .le. dzero) return
129 texit = t
130 alpexit = min(max(alpt, dzero), done)
131 betexit = dzero
132 itrifaceexit = 1
133 else if (ibettrend .gt. 0 .and. betsolhi .gt. done) then
134 call get_t_alpt(done, t, alpt)
135 if (t .le. dzero) return
136 texit = t
137 alpexit = dzero
138 betexit = done
139 itrifaceexit = 2
140 end if
141
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fbary1()

real(dp) function ternarysolveutils::fbary1 ( real(dp), intent(in) bet)
private

Definition at line 551 of file TernarySolveUtils.f90.

552 ! dummy
553 real(DP), intent(in) :: bet
554 real(DP) :: fb
555 ! local
556 real(DP) :: t
557 real(DP) :: alpt
558
559 ! Evaluate gamma{t{beta}} = 1. - alpha{t{beta}} - beta
560 call get_t_alpt(bet, t, alpt)
561 fb = done - alpt - bet
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fbary2()

real(dp) function ternarysolveutils::fbary2 ( real(dp), intent(in) bet)
private

Definition at line 565 of file TernarySolveUtils.f90.

566 ! dummy
567 real(DP), intent(in) :: bet
568 real(DP) :: fb
569 ! local
570 real(DP) :: t
571 real(DP) :: alpt
572
573 ! Evaluate alpha{t{beta}}
574 call get_t_alpt(bet, t, alpt)
575 fb = alpt
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_exit_bary()

subroutine, public ternarysolveutils::find_exit_bary ( integer(i4b) isolv,
integer(i4b) itriface,
integer(i4b) itrifaceenter,
real(dp) alpi,
real(dp) beti,
real(dp) tol,
real(dp) texit,
real(dp) alpexit,
real(dp) betexit )

Definition at line 371 of file TernarySolveUtils.f90.

374 ! dummy
375 integer(I4B) :: isolv
376 integer(I4B) :: itriface
377 integer(I4B) :: itrifaceenter
378 real(DP) :: alpi
379 real(DP) :: beti
380 real(DP) :: tol
381 real(DP) :: texit
382 real(DP) :: alpexit
383 real(DP) :: betexit
384 ! local
385 real(DP) :: alplo
386 real(DP) :: alphi
387 real(DP) :: alpt
388 real(DP) :: alplim
389 real(DP) :: fax
390 real(DP) :: fbx
391 real(DP) :: t
392 real(DP) :: tlo
393 real(DP) :: thi
394 real(DP) :: v0alpstar
395 real(DP) :: valpi
396 real(DP) :: v1n
397 real(DP) :: v2n
398 real(DP) :: vbeti
399 real(DP) :: betlo
400 real(DP) :: bethi
401 real(DP) :: betsollo
402 real(DP) :: betsolhi
403 real(DP) :: betoutlo
404 real(DP) :: betouthi
405 integer(I4B) :: ibettrend
406 real(DP) :: zerotol
407
408 zerotol = 1d-10 ! todo AMP: consider tolerance
409
410 ! Use iterative scheme or numerical integration indicated by isolv.
411 if (itriface .eq. 0) then
412 ! Checking for exit on canonical face 0 (beta = 0)
413 if (itrifaceenter .eq. 0) then
414 ! Entrance face, so no exit. (Normal velocity is uniform along face 0,
415 ! so it cannot be both an entrance and an exit.)
416 texit = huge(1d0)
417 else
418 ! Not the entrance face, so check for outflow
419 if (cv0(2) .ge. dzero) then ! check beta velocity along beta=0 face
420 ! Inflow or no flow, so no exit
421 texit = huge(done)
422 else
423 ! Outflow, so check beta-velocity at the initial location,
424 ! recognizing that it will never change sign along the
425 ! trajectory (and will not be blocked from zero by an asymptote)
426 vbeti = cv0(2) + wbb * beti
427 if (vbeti .ge. dzero) then
428 ! Can't exit along beta = 0
429 texit = huge(done)
430 else
431 ! get alpt and check it
432 call get_t_alpt(dzero, t, alpt)
433 if ((alpt .ge. dzero) .and. (alpt .le. done)) then
434 ! alpt within the edge, so exit found
435 texit = t
436 alpexit = alpt
437 betexit = dzero
438 else
439 ! alpt not within the edge, so not an exit
440 texit = huge(done)
441 end if
442 end if
443 end if
444 end if
445 ! End canonical face 0 (beta = 0)
446 else
447 ! Checking for exit on canonical face 1 (gamma = 0.) or 2 (alpha = 0.)
448 if (itriface .eq. 1) then
449 ! Normal velocities (gamma components) at ends of canonical face 1
450 v1n = -cv1(1) - cv1(2)
451 v2n = -cv2(1) - cv2(2)
452 else
453 ! Normal velocities (alpha components) at ends of canonical face 2
454 v1n = cv0(1)
455 v2n = cv2(1)
456 end if
457 if ((v1n .ge. dzero) .and. (v2n .ge. dzero)) then
458 ! No outflow at vn1 and vn2 corners; no outflow interval, so no exit.
459 texit = huge(done)
460 else
461 ! Find outflow interval
462 call get_bet_outflow_bary(v1n, v2n, betoutlo, betouthi)
463 ! Find trend of and limits on beta from beta{t} solution
464 call get_bet_soln_limits(beti, betsollo, betsolhi, ibettrend)
465 ! Look for exit
466 if (ibettrend .eq. 0) then
467 ! Beta is constant, so check if it's within the outflow interval;
468 ! if not, no exit; if so, solve for t and alpha
469 if ((beti .gt. betouthi) .or. (beti .lt. betoutlo)) then
470 texit = huge(1d0)
471 else
472 ! Check alpha-velocity at the initial location,
473 ! recognizing that it will never change sign along the
474 ! trajectory (and will not be blocked from zero by an asymptote)
475 ! in this special case
476 v0alpstar = cv0(1) + wab * beti
477 valpi = v0alpstar + waa * alpi
478 if ((itriface .eq. 1) .and. (valpi .le. dzero)) then
479 ! Can't exit along gamma = 0.
480 texit = huge(done)
481 else if ((itriface .eq. 2) .and. (valpi .ge. dzero)) then
482 ! Can't exit along alpha = 0.
483 texit = huge(done)
484 else
485 ! get exit
486 if (itriface .eq. 1) then
487 alpexit = done - beti
488 else
489 alpexit = dzero
490 end if
491 betexit = beti
492 if (dabs(waa) > zerotol) then
493 alplim = -v0alpstar / waa
494 texit = dlog(alpexit - alplim / (alpi - alplim)) / waa
495 else
496 texit = (alpexit - alpi) / v0alpstar
497 end if
498 end if
499 end if
500 ! End constant-beta case
501 else
502 ! Beta varies along trajectory; combine outflow and soln limits on beta
503 bethi = min(betouthi, betsolhi)
504 betlo = max(betoutlo, betsollo)
505 if (betlo .gt. bethi) then
506 ! If bounds on bet leave no feasible interval, no exit
507 texit = huge(done)
508 else
509 ! Check sign of function value at beta bounds
510 call get_t_alpt(bethi, thi, alphi)
511 call get_t_alpt(betlo, tlo, alplo)
512 if (itriface .eq. 1) then
513 fax = done - betlo - alplo
514 fbx = done - bethi - alphi
515 else
516 fax = alplo
517 fbx = alphi
518 end if
519 if (fax * fbx .gt. dzero) then
520 ! Root not bracketed; no exit
521 texit = huge(done)
522 else
523 if (isolv .eq. 1) then
524 ! Use Brent's method with initial bounds on beta of betlo and bethi,
525 ! assuming they bound the root
526 call soln_brent(itriface, betlo, bethi, tol, texit, &
527 alpexit, betexit)
528 else if (isolv .eq. 2) then
529 ! Use Chandrupatla's method with initial bounds on beta of betlo and bethi,
530 ! assuming they bound the root
531 call soln_chand(itriface, betlo, bethi, tol, texit, &
532 alpexit, betexit)
533 else
534 call pstop(1, "Invalid isolv, expected one of: 1, 2")
535 end if
536 end if
537 end if
538 ! End variable-beta case
539 end if
540 end if
541 ! End canonical face 1 (gamma = 0.) or 2 (alpha = 0.)
542 end if
543
544 if (texit .ne. huge(done) .and. texit .lt. dzero) then
545 call pstop(1, "texit is negative (unexpected)") ! shouldn't get here
546 end if
547
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_bet_outflow_bary()

subroutine, public ternarysolveutils::get_bet_outflow_bary ( real(dp) vn1,
real(dp) vn2,
real(dp) betoutlo,
real(dp) betouthi )

Definition at line 637 of file TernarySolveUtils.f90.

638 ! dummy
639 real(DP) :: vn1
640 real(DP) :: vn2
641 real(DP) :: betoutlo
642 real(DP) :: betouthi
643 ! local
644 real(DP) :: vndiff
645
646 vndiff = vn2 - vn1
647 if (vn1 .lt. dzero) then
648 ! Outflow at vn1 corner
649 betoutlo = dzero
650 if (vn2 .le. dzero) then
651 ! Outflow along entire edge (except possibly no-flow right at vn2 corner)
652 betouthi = done
653 else
654 ! Outflow along part of edge
655 betouthi = -vn1 / vndiff
656 end if
657 else
658 ! Outflow at vn2 corner
659 betouthi = done
660 if (vn1 .le. dzero) then
661 ! Outflow along entire edge (except possibly no-flow right at vn1 corner)
662 betoutlo = dzero
663 else
664 ! Outflow along part of edge
665 betoutlo = -vn1 / vndiff
666 end if
667 end if
668
Here is the caller graph for this function:

◆ get_bet_soln_limits()

subroutine, public ternarysolveutils::get_bet_soln_limits ( real(dp), intent(in) beti,
real(dp) betsollo,
real(dp) betsolhi,
integer(i4b), intent(inout) ibettrend )

Definition at line 672 of file TernarySolveUtils.f90.

673 ! dummy
674 real(DP), intent(in) :: beti
675 real(DP) :: betsollo
676 real(DP) :: betsolhi
677 integer(I4B), intent(inout) :: ibettrend
678 ! local
679 real(DP) :: betlim
680
681 if (icase > 2) then
682 if (cv0(2) .gt. dzero) then
683 betsolhi = huge(done)
684 betsollo = beti
685 ibettrend = 1
686 else if (cv0(2) .lt. dzero) then
687 betsolhi = beti
688 betsollo = -huge(done)
689 ibettrend = -1
690 else
691 betsolhi = beti
692 betsollo = beti
693 ibettrend = 0
694 end if
695 else if (wbb .gt. dzero) then
696 betlim = -cv0(2) / wbb
697 if (beti .gt. betlim) then
698 betsolhi = huge(done)
699 betsollo = beti
700 ibettrend = 1
701 else if (beti .lt. betlim) then
702 betsolhi = beti
703 betsollo = -huge(done)
704 ibettrend = -1
705 else
706 betsolhi = beti
707 betsollo = beti
708 ibettrend = 0
709 end if
710 else if (wbb .lt. dzero) then
711 betlim = -cv0(2) / wbb
712 if (beti .gt. betlim) then
713 betsolhi = beti
714 betsollo = betlim
715 ibettrend = -1
716 else if (beti .lt. betlim) then
717 betsolhi = betlim
718 betsollo = beti
719 ibettrend = 1
720 else
721 betsolhi = beti
722 betsollo = beti
723 ibettrend = 0
724 end if
725 end if
726
Here is the caller graph for this function:

◆ get_t_alpt()

subroutine, public ternarysolveutils::get_t_alpt ( real(dp), intent(in) bet,
real(dp) t,
real(dp) alp )

Definition at line 579 of file TernarySolveUtils.f90.

580 ! dummy
581 real(DP), intent(in) :: bet
582 real(DP) :: t
583 real(DP) :: alp
584 ! local
585 real(DP) :: term
586 real(DP) :: zerotol
587 real(DP) :: waat
588 real(DP) :: coef
589 real(DP) :: waatlim
590 real(DP) :: ewaatlim
591
592 ! assumes cb2<>0, wbb<>0
593 zerotol = 1d-10 ! todo AMP: consider tolerance
594 term = (bet - cb1) / cb2
595 waatlim = 50.0_dp
596 ewaatlim = 5d+21 ! approx. e^waatlim
597
598 if (icase .eq. 1) then
599 term = max(term, zerotol)
600 t = dlog(term) / wbb
601 waat = waa * t
602 if (waat > waatlim) then
603 alp = sign(ewaatlim, ca2)
604 else
605 alp = ca1 + ca2 * dexp(waat) + ca3 * term
606 end if
607 else if (icase .eq. -1) then
608 term = max(term, zerotol)
609 t = dlog(term) / wbb
610 waat = waa * t
611 coef = ca2 + ca3 * t
612 if (waat > waatlim) then
613 alp = sign(ewaatlim, coef)
614 else
615 alp = ca1 + coef * dexp(waat)
616 end if
617 else if (icase .eq. 2) then
618 term = max(term, zerotol)
619 t = dlog(term) / wbb
620 alp = ca1 + ca2 * t + ca3 * term
621 else if (icase .eq. 3) then
622 t = term
623 waat = waa * t
624 if (waat > waatlim) then
625 alp = sign(ewaatlim, ca3)
626 else
627 alp = ca1 + ca2 * t + ca3 * dexp(waat)
628 end if
629 else if (icase .eq. 4) then
630 t = term
631 alp = ca1 + (ca2 + ca3 * t) * t
632 end if
633
Here is the caller graph for this function:

◆ get_w()

subroutine, public ternarysolveutils::get_w ( real(dp) alp1,
real(dp) bet1,
real(dp) alp2,
real(dp) bet2,
real(dp) waa,
real(dp) wab,
real(dp) wba,
real(dp) wbb )
Parameters
bet2triangle face points
wbbw matrix

Definition at line 242 of file TernarySolveUtils.f90.

245 ! dummy
246 real(DP) :: alp1
247 real(DP) :: bet1
248 real(DP) :: alp2
249 real(DP) :: bet2 !< triangle face points
250 real(DP) :: waa
251 real(DP) :: wab
252 real(DP) :: wba
253 real(DP) :: wbb !< w matrix
254 ! local
255 real(DP) :: v1alpdiff
256 real(DP) :: v2alpdiff
257 real(DP) :: v2betdiff
258
259 ! Note: wab is the "alpha,beta" entry in matrix W
260 ! and the alpha component of the w^(beta) vector
261 v1alpdiff = cv1(1) - cv0(1)
262 v2alpdiff = cv2(1) - cv0(1)
263 v2betdiff = cv2(2) - cv0(2)
264 waa = v1alpdiff
265 wab = v2alpdiff
266 wba = dzero
267 wbb = v2betdiff
268
Here is the caller graph for this function:

◆ soln_brent()

subroutine, public ternarysolveutils::soln_brent ( integer(i4b), intent(in) itriface,
real(dp) betlo,
real(dp) bethi,
real(dp), intent(in) tol,
real(dp) texit,
real(dp) alpexit,
real(dp) betexit )

Definition at line 730 of file TernarySolveUtils.f90.

732 ! dummy
733 integer(I4B), intent(in) :: itriface
734 real(DP) :: betlo
735 real(DP) :: bethi
736 real(DP), intent(in) :: tol
737 real(DP) :: texit
738 real(DP) :: alpexit
739 real(DP) :: betexit
740 ! local
741 real(DP) :: blo
742 real(DP) :: bhi
743 procedure(f1d), pointer :: f
744
745 ! assuming betlo and bethi bracket the root
746 blo = betlo
747 bhi = bethi
748 if (itriface .eq. 1) then
749 f => fbary1
750 betexit = zero_br(blo, bhi, f, tol)
751 else
752 f => fbary2
753 betexit = zero_br(blo, bhi, f, tol)
754 end if
755 call get_t_alpt(betexit, texit, alpexit)
756
Here is the call graph for this function:
Here is the caller graph for this function:

◆ soln_chand()

subroutine, public ternarysolveutils::soln_chand ( integer(i4b), intent(in) itriface,
real(dp) betlo,
real(dp) bethi,
real(dp), intent(in) tol,
real(dp) texit,
real(dp) alpexit,
real(dp) betexit )

Definition at line 760 of file TernarySolveUtils.f90.

762 ! dummy
763 integer(I4B), intent(in) :: itriface
764 real(DP) :: betlo
765 real(DP) :: bethi
766 real(DP), intent(in) :: tol
767 real(DP) :: texit
768 real(DP) :: alpexit
769 real(DP) :: betexit
770 ! local
771 real(DP) :: blo
772 real(DP) :: bhi
773 procedure(f1d), pointer :: f
774
775 ! note: assuming betlo and bethi bracket the root
776 blo = betlo
777 bhi = bethi
778 if (itriface .eq. 1) then
779 f => fbary1
780 betexit = zero_ch(blo, bhi, f, tol)
781 else
782 f => fbary2
783 betexit = zero_ch(blo, bhi, f, tol)
784 end if
785 call get_t_alpt(betexit, texit, alpexit)
786
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve_coefs()

subroutine, public ternarysolveutils::solve_coefs ( real(dp) alpi,
real(dp) beti )

Definition at line 272 of file TernarySolveUtils.f90.

273 ! dummy
274 real(DP) :: alpi
275 real(DP) :: beti
276 ! local
277 real(DP) :: zerotol
278 real(DP) :: wratv
279 real(DP) :: acoef
280 real(DP) :: bcoef
281 real(DP) :: afact
282 real(DP) :: bfact
283 real(DP) :: vfact
284 real(DP) :: oowaa
285
286 zerotol = 1d-10 ! todo AMP: consider tolerance
287 if (dabs(wbb) .gt. zerotol) then
288 wratv = (wab / wbb) * cv0(2)
289 acoef = cv0(1) - wratv
290 bcoef = wratv + wab * beti
291 afact = acoef / waa
292 vfact = cv0(2) / wbb
293 ! Coefs for beta do not depend on whether waa = 0 or not
294 cb1 = -vfact ! const term in beta
295 cb2 = vfact + beti ! coef for e(wbb*t) term in beta
296 ! Coefs for alpha
297 if (dabs(waa) .gt. zerotol) then
298 ! Case waa <> 0, wbb <> 0
299 if (dabs(wbb - waa) .gt. zerotol) then
300 ! Subcase wbb <> waa
301 bfact = bcoef / (wbb - waa)
302 ca1 = -afact ! const term in alpha
303 ca2 = alpi + afact - bfact ! coef for exp(waa*t) term in alpha
304 ca3 = bfact ! coef for exp(wbb*t) term in alpha
305 icase = 1
306 else
307 ! Subcase wbb = waa
308 ca1 = -afact ! const term in alpha
309 ca2 = alpi + afact ! coef for exp(waa*t) term in alpha
310 ca3 = bcoef ! coef for t*exp(waa*t) term in alpha
311 icase = -1
312 end if
313 else
314 ! Case waa = 0, wbb <> 0
315 bfact = bcoef / wbb
316 ca1 = alpi - bfact ! const term in alpha
317 ca2 = acoef ! coef for t term in alpha
318 ca3 = bfact ! coef for exp(wbb*t) term in alpha
319 icase = 2
320 end if
321 else
322 ! Coefs for beta do not depend on whether waa = 0 or not
323 cb1 = beti ! const term in beta
324 cb2 = cv0(2) ! coef for t term in beta
325 if (dabs(waa) .gt. zerotol) then
326 ! Case waa <> 0, wbb = 0
327 oowaa = 1d0 / waa
328 vfact = (wab * oowaa) * cv0(2)
329 ca1 = -oowaa * (cv0(1) + wab * beti + vfact) ! const term in alpha
330 ca2 = -vfact ! coef for t term in alpha
331 ca3 = alpi - ca1 ! coef for exp(waa*t) term in alpha
332 icase = 3
333 else
334 ! Case waa = 0, wbb = 0
335 ca1 = alpi ! const term in alpha
336 ca2 = cv0(1) + wab * beti ! coef for t term in alpha
337 ca3 = 5d-1 * wab * cv0(2) ! coef for t^2 term in alpha
338 icase = 4
339 end if
340 end if
341
Here is the caller graph for this function:

◆ step_analytical()

subroutine, public ternarysolveutils::step_analytical ( real(dp), intent(in) t,
real(dp) alp,
real(dp) bet )

Definition at line 345 of file TernarySolveUtils.f90.

346 ! dummy
347 real(DP), intent(in) :: t
348 real(DP) :: alp
349 real(DP) :: bet
350
351 if (icase .eq. 1) then
352 alp = ca1 + ca2 * dexp(waa * t) + ca3 * dexp(wbb * t)
353 bet = cb1 + cb2 * dexp(wbb * t)
354 else if (icase .eq. -1) then
355 alp = ca1 + (ca2 + ca3 * t) * dexp(waa * t)
356 bet = cb1 + cb2 * dexp(wbb * t)
357 else if (icase .eq. 2) then
358 alp = ca1 + ca2 * t + ca3 * dexp(wbb * t)
359 bet = cb1 + cb2 * dexp(wbb * t)
360 else if (icase .eq. 3) then
361 alp = ca1 + ca2 * t + ca3 * dexp(waa * t)
362 bet = cb1 + cb2 * t
363 else if (icase .eq. 4) then
364 alp = ca1 + (ca2 + ca3 * t) * t
365 bet = cb1 + cb2 * t
366 end if
367
Here is the caller graph for this function:

◆ traverse_triangle()

subroutine, public ternarysolveutils::traverse_triangle ( integer(i4b), intent(in) isolv,
real(dp), intent(in) tol,
real(dp), intent(inout) texit,
real(dp), intent(inout) alpexit,
real(dp), intent(inout) betexit,
integer(i4b), intent(in) itrifaceenter,
integer(i4b), intent(inout) itrifaceexit,
real(dp), intent(in) alp1,
real(dp), intent(in) bet1,
real(dp), intent(in) alp2,
real(dp), intent(in) bet2,
real(dp), intent(in) alpi,
real(dp), intent(in) beti )
Parameters
[in]isolvsolution method
[in]tolsolution tolerance
[in,out]texittime particle exits the cell
[in,out]betexitalpha and beta coefficients
[in,out]itrifaceexitentry and exit faces
[in]betialpha and beta coefficients

Definition at line 32 of file TernarySolveUtils.f90.

36 ! dummy
37 integer(I4B), intent(in) :: isolv !< solution method
38 real(DP), intent(in) :: tol !< solution tolerance
39 real(DP), intent(inout) :: texit !< time particle exits the cell
40 real(DP), intent(inout) :: alpexit
41 real(DP), intent(inout) :: betexit !< alpha and beta coefficients
42 integer(I4B), intent(in) :: itrifaceenter
43 integer(I4B), intent(inout) :: itrifaceexit !< entry and exit faces
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 !< alpha and beta coefficients
50 ! local
51 real(DP) :: texit0
52 real(DP) :: alpexit0
53 real(DP) :: betexit0
54 real(DP) :: texit1
55 real(DP) :: alpexit1
56 real(DP) :: betexit1
57 real(DP) :: texit2
58 real(DP) :: alpexit2
59 real(DP) :: betexit2
60
61 ! Compute elements of matrix W
62 call get_w(alp1, bet1, alp2, bet2, waa, wab, wba, wbb)
63
64 ! Determine alpha and beta analytically as functions of time
65 call solve_coefs(alpi, beti)
66
67 ! Compute exit time (travel time to exit) and exit location
68 call find_exit_bary(isolv, 0, itrifaceenter, &
69 alpi, beti, tol, &
70 texit0, alpexit0, betexit0)
71 call find_exit_bary(isolv, 1, itrifaceenter, &
72 alpi, beti, tol, &
73 texit1, alpexit1, betexit1)
74 call find_exit_bary(isolv, 2, itrifaceenter, &
75 alpi, beti, tol, &
76 texit2, alpexit2, betexit2)
77 texit = min(texit0, texit1, texit2)
78
79 ! Note that while the numbering of triangle faces is generally zero-based
80 ! (0, 1, 2), itrifaceexit, which gets passed out, is one-based (1, 2, 3).
81 if (texit .eq. texit0) then
82 alpexit = alpexit0
83 betexit = betexit0
84 itrifaceexit = 1
85 else if (texit .eq. texit1) then
86 alpexit = alpexit1
87 betexit = betexit1
88 itrifaceexit = 2
89 else if (texit .eq. texit2) then
90 alpexit = alpexit2
91 betexit = betexit2
92 itrifaceexit = 3
93 end if
94 if (texit .eq. huge(1d0)) then
95 itrifaceexit = 0
96 call exit_at_vertex(beti, texit, alpexit, betexit, itrifaceexit)
97 end if
98
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ca1

real(dp) ternarysolveutils::ca1
private

Definition at line 24 of file TernarySolveUtils.f90.

24 real(DP) ca1, ca2, ca3, cb1, cb2 !< Analytical solution coefficients

◆ ca2

real(dp) ternarysolveutils::ca2
private

Definition at line 24 of file TernarySolveUtils.f90.

◆ ca3

real(dp) ternarysolveutils::ca3
private

Definition at line 24 of file TernarySolveUtils.f90.

◆ cb1

real(dp) ternarysolveutils::cb1
private

Definition at line 24 of file TernarySolveUtils.f90.

◆ cb2

real(dp) ternarysolveutils::cb2
private

Definition at line 24 of file TernarySolveUtils.f90.

◆ cv0

real(dp), dimension(2) ternarysolveutils::cv0
private

Definition at line 26 of file TernarySolveUtils.f90.

26 real(DP) :: cv0(2), cv1(2), cv2(2) !< "Canonical" velocity components at corners of triangular subcell

◆ cv1

real(dp), dimension(2) ternarysolveutils::cv1
private

Definition at line 26 of file TernarySolveUtils.f90.

◆ cv2

real(dp), dimension(2) ternarysolveutils::cv2
private

Definition at line 26 of file TernarySolveUtils.f90.

◆ icase

integer(i4b) ternarysolveutils::icase
private

Definition at line 27 of file TernarySolveUtils.f90.

27 integer(I4B) icase !< Case index for analytical solution

◆ waa

real(dp) ternarysolveutils::waa
private

Definition at line 25 of file TernarySolveUtils.f90.

25 real(DP) waa, wab, wba, wbb !< Elements of the "velocity matrix," W

◆ wab

real(dp) ternarysolveutils::wab
private

Definition at line 25 of file TernarySolveUtils.f90.

◆ wba

real(dp) ternarysolveutils::wba
private

Definition at line 25 of file TernarySolveUtils.f90.

◆ wbb

real(dp) ternarysolveutils::wbb
private

Definition at line 25 of file TernarySolveUtils.f90.