92
93 class(MethodSubcellTernaryType), intent(inout) :: this
94 class(SubcellTriType), intent(in) :: subcell
95 type(ParticleType), pointer, intent(inout) :: particle
96 real(DP), intent(in) :: tmax
97
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
101 type(BarycentricExitSolutionType) :: exit_solutions(2)
102 type(BarycentricExitSolutionType) :: exit_z, exit_lateral
103
104 event_code = -1
105 if (particle%iexmeth == 0) then
106 isolv = 1
107 else
108 isolv = particle%iexmeth
109 end if
110 t0 = particle%ttrack
111
112
113
114
115
116 call find_exits(particle, subcell, exit_solutions, z0)
117
118 exit_z = exit_solutions(1)
119 exit_lateral = exit_solutions(2)
120
121
122
123 if (exit_z%itopbotexit == 0 .and. &
124 exit_lateral%itrifaceexit == 0) then
126 return
127 end if
128
129
130 exit_soln = pick_exit(exit_solutions)
131 exit_face = exit_solutions(exit_soln)%iboundary
132 dtexit = exit_solutions(exit_soln)%dt
133 if (dtexit < dzero) then
135 return
136 end if
137 texit = t0 + dtexit
138
139
140
141
142
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)
147 if (t < t0) cycle
148 if (t > texit .or. t > tmax) exit
149 dt = t - t0
150 call calculate_xyz_position(dt, &
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, &
158 z0, x, y, z)
159 particle%x = x
160 particle%y = y
161 particle%z = z
162 particle%ttrack = t
164 call this%usertime(particle)
165 end do
166 end if
167
168
169
170
171 if (texit .gt. tmax) then
172
173
174 t = tmax
175 dt = t - t0
176 exit_face = 0
178 particle%advancing = .false.
180 else
181
182
183 t = texit
184 dt = dtexit
186 end if
187 call calculate_xyz_position(dt, &
188 exit_lateral%rxx, exit_lateral%rxy, &
189 exit_lateral%ryx, exit_lateral%ryy, &
190 exit_lateral%sxx, exit_lateral%sxy, &
191 exit_lateral%syy, exit_z%status, &
192 subcell%x0, subcell%y0, &
193 exit_z%dvdx, exit_z%v, &
194 subcell%vzbot, subcell%ztop, subcell%zbot, &
195 z0, x, y, z, exit_face)
196 particle%x = x
197 particle%y = y
198 particle%z = z
199 particle%ttrack = t
200 particle%iboundary(level_subfeature) = exit_face
201
203 call this%timestep(particle)
204 else if (event_code ==
featexit)
then
205 call this%subcellexit(particle)
206 end if
207
@ 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