Skip to content

Commit

Permalink
fix(prt): fix pass-to-bottom tracking method (#1918)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wpbonelli authored Jun 28, 2024
1 parent edbb60a commit 59773f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/ReleaseNotes/develop.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
\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.
\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.
\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.
\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.
% \item xxx
\end{itemize}

Expand Down
10 changes: 4 additions & 6 deletions src/Solution/ParticleTracker/MethodCellPassToBot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module MethodCellPassToBotModule

type, extends(MethodType) :: MethodCellPassToBotType
private
type(CellDefnType), pointer :: defn
contains
procedure, public :: apply => apply_ptb
procedure, public :: deallocate
Expand All @@ -32,7 +31,6 @@ subroutine create_method_cell_ptb(method)
allocate (method%type)
method%type = "passtobottom"
method%delegates = .false.
call create_defn(method%defn)
end subroutine create_method_cell_ptb

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

call this%update(particle, this%defn)
call this%update(particle, this%cell%defn)
if (.not. particle%advancing) return
particle%z = this%defn%bot
particle%iboundary(2) = this%defn%npolyverts + 2
call this%save(particle, reason=1) ! reason=1: cell transition
particle%z = this%cell%defn%bot
particle%iboundary(2) = this%cell%defn%npolyverts + 2
call this%save(particle, reason=1)
end subroutine apply_ptb

end module MethodCellPassToBotModule

0 comments on commit 59773f2

Please sign in to comment.