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.
106
107 class(MethodSubcellPollockType), intent(inout) :: this
108 class(SubcellRectType), intent(in) :: subcell
109 type(ParticleType), pointer, intent(inout) :: particle
110 real(DP), intent(in) :: tmax
111
112 real(DP) :: dt, dtexit, texit
113 real(DP) :: t, x, y, z
114 real(DP) :: t0, x0, y0, z0
115 integer(I4B) :: i, exit_face, exit_soln
116 type(LinearExitSolutionType) :: exit_solutions(3)
117 type(LinearExitSolutionType) :: exit_x, exit_y, exit_z
118
119 t0 = particle%ttrack
120
121
122
123 call find_exits(particle, subcell, exit_solutions, x0, y0, z0)
124 exit_x = exit_solutions(1)
125 exit_y = exit_solutions(2)
126 exit_z = exit_solutions(3)
127
128
129 exit_soln = pick_exit(exit_solutions)
130 if (exit_soln == 0) then
131 exit_face = 0
132 dtexit = 1.0d+30
133 else
134 exit_face = exit_solutions(exit_soln)%iboundary
135 dtexit = exit_solutions(exit_soln)%dt
136 end if
137 texit = particle%ttrack + dtexit
138
139
140
141
142
143
144
145
146
147
148
149
150 if (all([exit_solutions%status] >= no_exit_stationary)) then
152 return
153 end if
154
155
156
157
158
159 call this%tracktimes%advance()
160 if (this%tracktimes%any()) then
161 do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
162 t = this%tracktimes%times(i)
163 if (t <= particle%tusertime) cycle
164 if (t < particle%ttrack) cycle
165 if (t > texit .or. t > tmax) exit
166 dt = t - t0
167 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
168 dt, x0, subcell%dx, exit_x%status == 1)
169 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
170 dt, y0, subcell%dy, exit_y%status == 1)
171 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
172 dt, z0, subcell%dz, exit_z%status == 1)
173 particle%x = x * subcell%dx
174 particle%y = y * subcell%dy
175 particle%z = z * subcell%dz
176 particle%ttrack = t
177 call this%usertime(particle)
178 end do
179 end if
180
181
182
183 if (texit .gt. tmax) then
184 t = tmax
185 dt = t - t0
186 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
187 dt, x0, subcell%dx, exit_x%status == 1)
188 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
189 dt, y0, subcell%dy, exit_y%status == 1)
190 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
191 dt, z0, subcell%dz, exit_z%status == 1)
192 exit_face = 0
193 particle%advancing = .false.
194 particle%x = x * subcell%dx
195 particle%y = y * subcell%dy
196 particle%z = z * subcell%dz
197 particle%ttrack = t
198 particle%iboundary(level_subfeature) = exit_face
199 call this%timestep(particle)
200 return
201 end if
202
203
204
205
206 t = texit
207 dt = dtexit
208 if ((exit_face .eq. 1) .or. (exit_face .eq. 2)) then
209 x = dzero
210 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
211 dt, y0, subcell%dy, exit_y%status == 1)
212 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, &
213 dt, z0, subcell%dz, exit_z%status == 1)
214 if (exit_face .eq. 2) x = done
215 else if ((exit_face .eq. 3) .or. (exit_face .eq. 4)) then
216 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, dt, &
217 x0, subcell%dx, exit_x%status == 1)
218 y = dzero
219 z = new_x(exit_z%v, exit_z%dvdx, subcell%vz1, subcell%vz2, dt, &
220 z0, subcell%dz, exit_z%status == 1)
221 if (exit_face .eq. 4) y = done
222 else if ((exit_face .eq. 5) .or. (exit_face .eq. 6)) then
223 x = new_x(exit_x%v, exit_x%dvdx, subcell%vx1, subcell%vx2, &
224 dt, x0, subcell%dx, exit_x%status == 1)
225 y = new_x(exit_y%v, exit_y%dvdx, subcell%vy1, subcell%vy2, &
226 dt, y0, subcell%dy, exit_y%status == 1)
227 z = dzero
228 if (exit_face .eq. 6) z = done
229 else
230 print *, "programmer error, invalid exit face", exit_face
231 call pstop(1)
232 end if
233 particle%x = x * subcell%dx
234 particle%y = y * subcell%dy
235 particle%z = z * subcell%dz
236 particle%ttrack = t
237 particle%iboundary(level_subfeature) = exit_face
238 call this%subcellexit(particle, tmax)
239
@ timestep
time step ended
@ featexit
particle exited a grid feature
@ term_no_exits_sub
terminated in a subcell with no exit face