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.
88 class(MethodSubcellPollockType),
intent(inout) :: this
89 class(SubcellRectType),
intent(in) :: subcell
90 type(ParticleType),
pointer,
intent(inout) :: particle
91 real(DP),
intent(in) :: tmax
110 integer(I4B) :: statusVX
111 integer(I4B) :: statusVY
112 integer(I4B) :: statusVZ
117 integer(I4B) :: exitFace
118 integer(I4B) :: reason
123 initialx = particle%x / subcell%dx
124 initialy = particle%y / subcell%dy
125 initialz = particle%z / subcell%dz
128 statusvx = calculate_dt(subcell%vx1, subcell%vx2, subcell%dx, &
129 initialx, vx, dvxdx, dtexitx)
130 statusvy = calculate_dt(subcell%vy1, subcell%vy2, subcell%dy, &
131 initialy, vy, dvydy, dtexity)
132 statusvz = calculate_dt(subcell%vz1, subcell%vz2, subcell%dz, &
133 initialz, vz, dvzdz, dtexitz)
137 if ((statusvx .eq. 3) .and. (statusvy .eq. 3) .and. (statusvz .eq. 3))
then
139 particle%advancing = .false.
140 call this%save(particle, reason=3)
147 if ((statusvx .lt. 2) .or. (statusvy .lt. 2) .or. (statusvz .lt. 2))
then
150 if (vx .lt. dzero)
then
152 else if (vx .gt. 0)
then
156 if (dtexity .lt. dtexit)
then
158 if (vy .lt. dzero)
then
160 else if (vy .gt. dzero)
then
165 if (dtexitz .lt. dtexit)
then
167 if (vz .lt. dzero)
then
169 else if (vz .gt. dzero)
then
177 texit = particle%ttrack + dtexit
184 call this%tracktimes%advance()
185 if (this%tracktimes%any())
then
186 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
187 t = this%tracktimes%times(i)
188 if (t < particle%ttrack) cycle
189 if (t >= texit .or. t >= tmax)
exit
191 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
192 dt, initialx, subcell%dx, statusvx == 1)
193 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
194 dt, initialy, subcell%dy, statusvy == 1)
195 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
196 dt, initialz, subcell%dz, statusvz == 1)
197 particle%x = x * subcell%dx
198 particle%y = y * subcell%dy
199 particle%z = z * subcell%dz
202 call this%save(particle, reason=5)
206 if (texit .gt. tmax)
then
212 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
213 dt, initialx, subcell%dx, statusvx == 1)
214 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
215 dt, initialy, subcell%dy, statusvy == 1)
216 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
217 dt, initialz, subcell%dz, statusvz == 1)
220 particle%advancing = .false.
228 if ((exitface .eq. 1) .or. (exitface .eq. 2))
then
230 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
231 dt, initialy, subcell%dy, statusvy == 1)
232 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
233 dt, initialz, subcell%dz, statusvz == 1)
234 if (exitface .eq. 2) x = done
235 else if ((exitface .eq. 3) .or. (exitface .eq. 4))
then
236 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, dt, &
237 initialx, subcell%dx, statusvx == 1)
239 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, dt, &
240 initialz, subcell%dz, statusvz == 1)
241 if (exitface .eq. 4) y = done
242 else if ((exitface .eq. 5) .or. (exitface .eq. 6))
then
243 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
244 dt, initialx, subcell%dx, statusvx == 1)
245 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
246 dt, initialy, subcell%dy, statusvy == 1)
248 if (exitface .eq. 6) z = done
250 print *,
"programmer error, invalid exit face", exitface
258 particle%x = x * subcell%dx
259 particle%y = y * subcell%dy
260 particle%z = z * subcell%dz
262 particle%iboundary(3) = exitface
265 if (reason >= 0)
call this%save(particle, reason=reason)