34 integer(I4B) :: itopbotexit = -1, itrifaceexit = -1
47 integer(I4B),
public,
pointer :: zeromethod
65 method%subcell => subcell
66 method%name => method%subcell%type
67 method%delegates = .false.
73 deallocate (this%name)
80 real(DP),
intent(in) :: tmax
82 select type (subcell => this%subcell)
84 call this%track_subcell(subcell, particle, tmax)
96 real(DP),
intent(in) :: tmax
98 real(DP) :: dt, dtexit, texit
99 real(DP) :: t0, t, x, y, z0, z
100 integer(I4B) :: exit_face, exit_soln, event_code, i, isolv
105 if (particle%iexmeth == 0)
then
108 isolv = particle%iexmeth
116 call find_exits(particle, subcell, exit_solutions, z0)
118 exit_z = exit_solutions(1)
119 exit_lateral = exit_solutions(2)
123 if (exit_z%itopbotexit == 0 .and. &
124 exit_lateral%itrifaceexit == 0)
then
131 exit_face = exit_solutions(exit_soln)%iboundary
132 dtexit = exit_solutions(exit_soln)%dt
133 if (dtexit <
dzero)
then
143 call this%tracktimes%advance()
144 if (this%tracktimes%any())
then
145 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
146 t = this%tracktimes%times(i)
148 if (t > texit .or. t > tmax)
exit
151 exit_lateral%rxx, exit_lateral%rxy, &
152 exit_lateral%ryx, exit_lateral%ryy, &
153 exit_lateral%sxx, exit_lateral%sxy, &
154 exit_lateral%syy, exit_z%status, &
155 subcell%x0, subcell%y0, &
156 exit_z%dvdx, exit_z%v, &
157 subcell%vzbot, subcell%ztop, subcell%zbot, &
163 call this%usertime(particle)
170 if (texit .gt. tmax)
then
176 particle%advancing = .false.
186 exit_lateral%rxx, exit_lateral%rxy, &
187 exit_lateral%ryx, exit_lateral%ryy, &
188 exit_lateral%sxx, exit_lateral%sxy, &
189 exit_lateral%syy, exit_z%status, &
190 subcell%x0, subcell%y0, &
191 exit_z%dvdx, exit_z%v, &
192 subcell%vzbot, subcell%ztop, subcell%zbot, &
193 z0, x, y, z, exit_face)
201 call this%timestep(particle)
202 else if (event_code ==
featexit)
then
203 call this%subcellexit(particle)
211 integer(I4B) :: exit_soln
213 if (exit_solutions(1)%itopbotexit == 0)
then
215 else if (exit_solutions(2)%itrifaceexit == 0 .or. &
216 exit_solutions(1)%dt < exit_solutions(2)%dt)
then
226 type(particletype),
pointer,
intent(inout) :: particle
229 real(DP),
intent(out) :: z0
231 integer(I4B) :: ntmax
250 integer(I4B) :: isolv
251 integer(I4B) :: itrifaceenter
257 if (particle%iexmeth == 0)
then
260 isolv = particle%iexmeth
263 select type (subcell => domain)
276 subcell%x1, subcell%y1, &
277 subcell%x2, subcell%y2, &
278 subcell%v0x, subcell%v0y, &
279 subcell%v1x, subcell%v1y, &
280 subcell%v2x, subcell%v2y, &
281 particle%x, particle%y, &
282 rxx, rxy, ryx, ryy, &
284 alp0, bet0, alp1, bet1, alp2, bet2, alpi, beti)
295 zirel = (particle%z - subcell%zbot) / subcell%dz
296 if (zirel >
done)
then
298 else if (zirel <
dzero)
then
301 z0 = subcell%zbot + zirel * subcell%dz
307 if (itrifaceenter == -1) itrifaceenter = 999
312 exit_solutions(2)%rxx = rxx
313 exit_solutions(2)%rxy = rxy
314 exit_solutions(2)%ryx = ryx
315 exit_solutions(2)%ryy = ryy
316 exit_solutions(2)%sxx = sxx
317 exit_solutions(2)%sxy = sxy
318 exit_solutions(2)%syy = syy
321 if (exit_solutions(1)%itopbotexit /= 0)
then
322 if (exit_solutions(1)%itopbotexit == -1)
then
323 exit_solutions(1)%iboundary = 4
325 exit_solutions(1)%iboundary = 5
330 if (exit_solutions(2)%itrifaceexit /= 0) &
331 exit_solutions(2)%iboundary = exit_solutions(2)%itrifaceexit
337 alp1, bet1, alp2, bet2, alpi, beti) &
339 integer(I4B) :: isolv
341 integer(I4B) :: itrifaceenter
352 solution%dt, solution%alpexit, solution%betexit, &
353 itrifaceenter, solution%itrifaceexit, &
354 alp1, bet1, alp2, bet2, alpi, beti)
355 if (solution%itrifaceexit > 0) solution%status =
ok_exit
359 real(dp),
intent(in) :: v1
360 real(dp),
intent(in) :: v2
361 real(dp),
intent(in) :: dx
362 real(dp),
intent(in) :: xl
366 call calculate_dt(v1, v2, dx, xl, solution%v, solution%dvdx, &
367 solution%dt, solution%status, solution%itopbotexit)
378 dt, status, itopbotexit)
400 integer(I4B) :: status
401 integer(I4B) :: itopbotexit
402 logical(LGP) :: noOutflow
408 if (v2a .lt.
dzero) v2a = -v2a
410 if (v1a .lt.
dzero) v1a = -v1a
413 if (dva .lt.
dzero) dva = -dva
418 if ((v2a .lt. tol) .and. (v1a .lt. tol))
then
430 if (v2a .gt. vv) vv = v2a
432 if (vvv .lt. 1.0d-4)
then
437 if (v1 .gt. zro)
then
441 if (v1 .lt. zrom)
then
453 v = (
done - xl) * v1 + xl * v2
458 if (v1 .lt.
dzero) nooutflow = .false.
459 if (v2 .gt.
dzero) nooutflow = .false.
470 if ((v1 .le.
dzero) .and. (v2 .ge.
dzero))
then
471 if (abs(v) .le.
dzero)
then
473 if (v2 .le.
dzero) v = -v
483 if (vr .le.
dzero)
then
492 if (v1v2 .gt.
dzero)
then
493 if (v .gt.
dzero)
then
497 if (v .lt.
dzero)
then
504 dt = log(abs(vr)) / dvdx
510 izstatus, x0, y0, az, vzi, vzbot, &
511 ztop, zbot, zi, x, y, z, exitface)
521 integer(I4B) :: izstatus
533 integer(I4B),
optional :: exitface
535 integer(I4B) :: lexitface
536 real(DP) :: rot(2, 2), res(2), loc(2)
541 if (
present(exitface))
then
552 if (lexitface .eq. 1)
then
554 else if (lexitface .eq. 2)
then
556 else if (lexitface .eq. 3)
then
561 if (lexitface .eq. 4)
then
563 else if (lexitface .eq. 5)
then
567 if (izstatus .eq. 2)
then
570 else if (izstatus .eq. 1)
then
575 z = zbot + (vzi * dexp(az * dt) - vzbot) / az
581 loc =
skew(loc, (/sxx, sxy, syy/), invert=.true.)
582 rot = reshape((/rxx, rxy, ryx, ryy/), shape(rot))
583 res = matmul(rot, loc)
This module contains simulation constants.
real(dp), parameter dsame
real constant for values that are considered the same based on machine precision
real(dp), parameter dep3
real constant 1000
real(dp), parameter donethird
real constant 1/3
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
real(dp), parameter dtwo
real constant 2
real(dp), parameter done
real constant 1
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
@ ok_exit_constant
exit found, constant velocity
@ ok_exit
exit found using velocity interpolation
@ no_exit_stationary
no exit, zero velocity
@ no_exit_no_outflow
no exit, no outflow
subroutine, public clamp_bary(alpha, beta, gamma, pad)
Clamp barycentric coordinates to the interior of a triangle, with optional padding some minimum dista...
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.
pure logical function, public is_close(a, b, rtol, atol, symmetric)
Check if a real value is approximately equal to another.
Particle tracking strategies.
type(barycentricexitsolutiontype) function find_lateral_exit(isolv, tol, itrifaceenter, alp1, bet1, alp2, bet2, alpi, beti)
subroutine track_subcell(this, subcell, particle, tmax)
Track a particle across a triangular subcell.
subroutine apply_mst(this, particle, tmax)
Apply the ternary subcell tracking method.
subroutine calculate_xyz_position(dt, rxx, rxy, ryx, ryy, sxx, sxy, syy, izstatus, x0, y0, az, vzi, vzbot, ztop, zbot, zi, x, y, z, exitface)
Calculate the particle's local unscaled xyz coordinates after dt.
subroutine calculate_dt(v1, v2, dx, xl, v, dvdx, dt, status, itopbotexit)
Do calculations related to analytical z solution.
integer(i4b) function pick_exit(exit_solutions)
Determine earliest exit face.
subroutine, public create_method_subcell_ternary(method)
Create a new ternary subcell tracking method.
type(barycentricexitsolutiontype) function find_vertical_exit(v1, v2, dx, xl)
subroutine find_exits(particle, domain, exit_solutions, z0)
Calculate exit solutions for each coordinate direction.
@ usertime
user-specified tracking time
@ terminate
particle terminated
@ timestep
time step ended
@ featexit
particle exited a grid feature
@ term_no_exits_sub
terminated in a subcell with no exit face
subroutine, public create_subcell_tri(subcell)
Create a new triangular subcell.
subroutine, public traverse_triangle(isolv, tol, texit, alpexit, betexit, itrifaceenter, itrifaceexit, alp1, bet1, alp2, bet2, alpi, beti)
Traverse triangular cell.
subroutine, public step_analytical(t, alp, bet)
Step (evaluate) analytically 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.
Base type for grid cells of a concrete type. Contains a cell-definition which is information shared b...
Base type for exit solutions.
Linear velocity interpolation exit solution.
A generic heterogeneous doubly-linked list.
Abstract base type for subcell tracking methods.
Barycentric velocity interpolation exit solution. Inherit from LinearExitSolutionType to get around a...
Ternary triangular subcell tracking method.
Particle tracked by the PRT model.