Skip to content

Commit 59773f2

Browse files
authored
fix(prt): fix pass-to-bottom tracking method (#1918)
The pass-to-bottom method had a reference to an unused cell definition pointer which was moved some time ago to the Cell type. Depending on the platform and compiler, this could result in crashes due to divide by zero errors, or undefined behavior preventing detection of when a particle should exit a cell through its bottom face, leading to early termination. Autotests for PTB behavior to come in a separate PR. Some testing has been done manually on sample models.
1 parent edbb60a commit 59773f2

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

doc/ReleaseNotes/develop.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
\item Previously the PRT model's default behavior was to track particles until termination, as with MODPATH 7 stop time option 2 (extend). Under extended tracking, the program may not halt if particles enter a cycle in the flow system. This PR changes the default to the equivalent of MP7 stop time option 1 (final), terminating at simulation end unless a new Particle Release Point (PRP) package keyword option EXTEND\_TRACKING is provided. This is meant to provide a stronger guarantee that the program halts under default settings.
2828
\item A refactor of the energy storage and transfer (EST) package associated with the GWE model type results in different input requirements that breaks backward compatibility with what was required in version 6.5.0. The PACKAGEDATA block was removed from the EST package input. In its place, the heat capabity of water, the specified density of water, and the latent heat of vaporization are instead given default values that can be overridden by specifying alternative values in the OPTIONS block.
2929
\item The PRT model's cell face flows were improperly combined with boundary flows; for cell faces with active neighbors, the face flow replaced any boundary flows (likely a rare situation because IFLOWFACE is typically applied to faces on the boundary of the active domain). The face flow calculation has been corrected.
30+
\item A bad pointer reference has been fixed in the PRT model. Depending on the combination of platform and compiler used to build the program, this could result in crashes (e.g. divide by zero errors) or in silent failures to properly pass particles downward between vertically adjacent cells, leading to early termination. The latter could occur as a consequence of undefined behavior which prevented detection of situations when a particle should exit a cell through its bottom face.
3031
% \item xxx
3132
\end{itemize}
3233

src/Solution/ParticleTracker/MethodCellPassToBot.f90

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module MethodCellPassToBotModule
1717

1818
type, extends(MethodType) :: MethodCellPassToBotType
1919
private
20-
type(CellDefnType), pointer :: defn
2120
contains
2221
procedure, public :: apply => apply_ptb
2322
procedure, public :: deallocate
@@ -32,7 +31,6 @@ subroutine create_method_cell_ptb(method)
3231
allocate (method%type)
3332
method%type = "passtobottom"
3433
method%delegates = .false.
35-
call create_defn(method%defn)
3634
end subroutine create_method_cell_ptb
3735

3836
!> @brief Deallocate the pass-to-bottom tracking method
@@ -48,11 +46,11 @@ subroutine apply_ptb(this, particle, tmax)
4846
type(ParticleType), pointer, intent(inout) :: particle
4947
real(DP), intent(in) :: tmax
5048

51-
call this%update(particle, this%defn)
49+
call this%update(particle, this%cell%defn)
5250
if (.not. particle%advancing) return
53-
particle%z = this%defn%bot
54-
particle%iboundary(2) = this%defn%npolyverts + 2
55-
call this%save(particle, reason=1) ! reason=1: cell transition
51+
particle%z = this%cell%defn%bot
52+
particle%iboundary(2) = this%cell%defn%npolyverts + 2
53+
call this%save(particle, reason=1)
5654
end subroutine apply_ptb
5755

5856
end module MethodCellPassToBotModule

0 commit comments

Comments
 (0)