This subroutine consists partly of code written by David W. Pollock of the USGS for MODPATH 7. PRT's authors take responsibility for its application in this context and for any modifications or errors.
89 class(MethodSubcellPollockType),
intent(inout) :: this
90 class(SubcellRectType),
intent(in) :: subcell
91 type(ParticleType),
pointer,
intent(inout) :: particle
92 real(DP),
intent(in) :: tmax
111 integer(I4B) :: statusVX
112 integer(I4B) :: statusVY
113 integer(I4B) :: statusVZ
118 integer(I4B) :: exitFace
119 integer(I4B) :: reason
124 initialx = particle%x / subcell%dx
125 initialy = particle%y / subcell%dy
126 initialz = particle%z / subcell%dz
129 statusvx = calculate_dt(subcell%vx1, subcell%vx2, subcell%dx, &
130 initialx, vx, dvxdx, dtexitx)
131 statusvy = calculate_dt(subcell%vy1, subcell%vy2, subcell%dy, &
132 initialy, vy, dvydy, dtexity)
133 statusvz = calculate_dt(subcell%vz1, subcell%vz2, subcell%dz, &
134 initialz, vz, dvzdz, dtexitz)
138 if ((statusvx .eq. 3) .and. (statusvy .eq. 3) .and. (statusvz .eq. 3))
then
140 particle%advancing = .false.
141 call this%save(particle, reason=3)
148 if ((statusvx .lt. 2) .or. (statusvy .lt. 2) .or. (statusvz .lt. 2))
then
151 if (vx .lt. dzero)
then
153 else if (vx .gt. 0)
then
157 if (dtexity .lt. dtexit)
then
159 if (vy .lt. dzero)
then
161 else if (vy .gt. dzero)
then
166 if (dtexitz .lt. dtexit)
then
168 if (vz .lt. dzero)
then
170 else if (vz .gt. dzero)
then
178 texit = particle%ttrack + dtexit
185 call this%tracktimes%advance()
186 if (this%tracktimes%any())
then
187 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
188 t = this%tracktimes%times(i)
189 if (t < particle%ttrack) cycle
190 if (t >= texit .or. t >= tmax)
exit
192 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
193 dt, initialx, subcell%dx, statusvx == 1)
194 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
195 dt, initialy, subcell%dy, statusvy == 1)
196 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
197 dt, initialz, subcell%dz, statusvz == 1)
198 particle%x = x * subcell%dx
199 particle%y = y * subcell%dy
200 particle%z = z * subcell%dz
203 call this%save(particle, reason=5)
207 if (texit .gt. tmax)
then
213 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
214 dt, initialx, subcell%dx, statusvx == 1)
215 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
216 dt, initialy, subcell%dy, statusvy == 1)
217 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
218 dt, initialz, subcell%dz, statusvz == 1)
221 particle%advancing = .false.
229 if ((exitface .eq. 1) .or. (exitface .eq. 2))
then
231 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
232 dt, initialy, subcell%dy, statusvy == 1)
233 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
234 dt, initialz, subcell%dz, statusvz == 1)
235 if (exitface .eq. 2) x = done
236 else if ((exitface .eq. 3) .or. (exitface .eq. 4))
then
237 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, dt, &
238 initialx, subcell%dx, statusvx == 1)
240 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, dt, &
241 initialz, subcell%dz, statusvz == 1)
242 if (exitface .eq. 4) y = done
243 else if ((exitface .eq. 5) .or. (exitface .eq. 6))
then
244 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
245 dt, initialx, subcell%dx, statusvx == 1)
246 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
247 dt, initialy, subcell%dy, statusvy == 1)
249 if (exitface .eq. 6) z = done
251 print *,
"programmer error, invalid exit face", exitface
259 particle%x = x * subcell%dx
260 particle%y = y * subcell%dy
261 particle%z = z * subcell%dz
263 particle%iboundary(3) = exitface
266 if (reason >= 0)
call this%save(particle, reason=reason)