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.
92 class(MethodSubcellPollockType),
intent(inout) :: this
93 class(SubcellRectType),
intent(in) :: subcell
94 type(ParticleType),
pointer,
intent(inout) :: particle
95 real(DP),
intent(in) :: tmax
114 integer(I4B) :: statusVX
115 integer(I4B) :: statusVY
116 integer(I4B) :: statusVZ
121 integer(I4B) :: exitFace
122 integer(I4B) :: event_code
127 initialx = particle%x / subcell%dx
128 initialy = particle%y / subcell%dy
129 initialz = particle%z / subcell%dz
132 statusvx = calculate_dt(subcell%vx1, subcell%vx2, subcell%dx, &
133 initialx, vx, dvxdx, dtexitx)
134 statusvy = calculate_dt(subcell%vy1, subcell%vy2, subcell%dy, &
135 initialy, vy, dvydy, dtexity)
136 statusvz = calculate_dt(subcell%vz1, subcell%vz2, subcell%dz, &
137 initialz, vz, dvzdz, dtexitz)
141 if ((statusvx .eq. 3) .and. (statusvy .eq. 3) .and. (statusvz .eq. 3))
then
152 if ((statusvx .eq. 2) .and. (statusvy .eq. 2) .and. (statusvz .eq. 2) .and. &
161 if ((statusvx .lt. 2) .or. (statusvy .lt. 2) .or. (statusvz .lt. 2))
then
164 if (vx .lt. dzero)
then
166 else if (vx .gt. 0)
then
170 if (dtexity .lt. dtexit)
then
172 if (vy .lt. dzero)
then
174 else if (vy .gt. dzero)
then
179 if (dtexitz .lt. dtexit)
then
181 if (vz .lt. dzero)
then
183 else if (vz .gt. dzero)
then
191 texit = particle%ttrack + dtexit
198 call this%tracktimes%advance()
199 if (this%tracktimes%any())
then
200 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
201 t = this%tracktimes%times(i)
202 if (t < particle%ttrack) cycle
203 if (t >= texit .or. t >= tmax)
exit
205 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
206 dt, initialx, subcell%dx, statusvx == 1)
207 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
208 dt, initialy, subcell%dy, statusvy == 1)
209 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
210 dt, initialz, subcell%dz, statusvz == 1)
211 particle%x = x * subcell%dx
212 particle%y = y * subcell%dy
213 particle%z = z * subcell%dz
216 call this%usertime(particle)
220 if (texit .gt. tmax)
then
226 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
227 dt, initialx, subcell%dx, statusvx == 1)
228 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
229 dt, initialy, subcell%dy, statusvy == 1)
230 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
231 dt, initialz, subcell%dz, statusvz == 1)
234 particle%advancing = .false.
242 if ((exitface .eq. 1) .or. (exitface .eq. 2))
then
244 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
245 dt, initialy, subcell%dy, statusvy == 1)
246 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, &
247 dt, initialz, subcell%dz, statusvz == 1)
248 if (exitface .eq. 2) x = done
249 else if ((exitface .eq. 3) .or. (exitface .eq. 4))
then
250 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, dt, &
251 initialx, subcell%dx, statusvx == 1)
253 z = new_x(vz, dvzdz, subcell%vz1, subcell%vz2, dt, &
254 initialz, subcell%dz, statusvz == 1)
255 if (exitface .eq. 4) y = done
256 else if ((exitface .eq. 5) .or. (exitface .eq. 6))
then
257 x = new_x(vx, dvxdx, subcell%vx1, subcell%vx2, &
258 dt, initialx, subcell%dx, statusvx == 1)
259 y = new_x(vy, dvydy, subcell%vy1, subcell%vy2, &
260 dt, initialy, subcell%dy, statusvy == 1)
262 if (exitface .eq. 6) z = done
264 print *,
"programmer error, invalid exit face", exitface
272 particle%x = x * subcell%dx
273 particle%y = y * subcell%dy
274 particle%z = z * subcell%dz
276 particle%iboundary(level_subfeature) = exitface
280 call this%timestep(particle)
281 else if (event_code ==
featexit)
then
282 call this%subcellexit(particle)
@, public featexit
particle exited a grid feature
@, public timestep
time step ended
@ term_timeout
terminated at stop time or end of simulation
@ term_no_exits_sub
terminated in a subcell with no exit face
logical(lgp), pointer, public endofsimulation
flag indicating end of simulation