From 59773f2184c0f100769055bb66e64dbc365a8c8b Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Fri, 28 Jun 2024 14:58:53 -0400 Subject: [PATCH] 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. --- doc/ReleaseNotes/develop.tex | 1 + src/Solution/ParticleTracker/MethodCellPassToBot.f90 | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/ReleaseNotes/develop.tex b/doc/ReleaseNotes/develop.tex index 2a33fc88bc3..a5e188bf987 100644 --- a/doc/ReleaseNotes/develop.tex +++ b/doc/ReleaseNotes/develop.tex @@ -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} diff --git a/src/Solution/ParticleTracker/MethodCellPassToBot.f90 b/src/Solution/ParticleTracker/MethodCellPassToBot.f90 index 3132611a5a2..109491528cf 100644 --- a/src/Solution/ParticleTracker/MethodCellPassToBot.f90 +++ b/src/Solution/ParticleTracker/MethodCellPassToBot.f90 @@ -17,7 +17,6 @@ module MethodCellPassToBotModule type, extends(MethodType) :: MethodCellPassToBotType private - type(CellDefnType), pointer :: defn contains procedure, public :: apply => apply_ptb procedure, public :: deallocate @@ -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 @@ -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