-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(prt): introduce cell method type/module (#2203)
Introduce CellMethodType and move the check() routine there from the base MethodType. These checks occur immediately before tracking begins across a cell, so this is the proper scope — they didn't belong in the base method type.
- Loading branch information
Showing
9 changed files
with
189 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
module MethodCellModule | ||
|
||
use KindModule, only: DP, I4B, LGP | ||
use ConstantsModule, only: DONE, DZERO | ||
use MethodModule, only: MethodType | ||
use ParticleModule, only: ParticleType | ||
use CellDefnModule, only: CellDefnType | ||
implicit none | ||
|
||
private | ||
public :: MethodCellType | ||
|
||
type, abstract, extends(MethodType) :: MethodCellType | ||
contains | ||
procedure, public :: check | ||
end type MethodCellType | ||
|
||
contains | ||
|
||
!> @brief Check reporting/terminating conditions before tracking | ||
!! the particle across the cell. | ||
!! | ||
!! Check a number of conditions determining whether to continue | ||
!! tracking the particle or terminate it, as well as whether to | ||
!! record any output data as per selected reporting conditions. | ||
!< | ||
subroutine check(this, particle, cell_defn, tmax) | ||
! modules | ||
use TdisModule, only: endofsimulation, totimc, totim | ||
use ParticleModule, only: TERM_WEAKSINK, TERM_NO_EXITS, & | ||
TERM_STOPZONE, TERM_INACTIVE | ||
! dummy | ||
class(MethodCellType), intent(inout) :: this | ||
type(ParticleType), pointer, intent(inout) :: particle | ||
type(CellDefnType), pointer, intent(inout) :: cell_defn | ||
real(DP), intent(in) :: tmax | ||
! local | ||
logical(LGP) :: dry_cell, dry_particle, no_exit_face, stop_zone, weak_sink | ||
integer(I4B) :: i | ||
real(DP) :: t, ttrackmax | ||
|
||
dry_cell = this%fmi%ibdgwfsat0(cell_defn%icell) == 0 | ||
dry_particle = particle%z > cell_defn%top | ||
no_exit_face = cell_defn%inoexitface > 0 | ||
stop_zone = cell_defn%izone > 0 .and. particle%istopzone == cell_defn%izone | ||
weak_sink = cell_defn%iweaksink > 0 | ||
|
||
particle%izone = cell_defn%izone | ||
if (stop_zone) then | ||
particle%advancing = .false. | ||
particle%istatus = TERM_STOPZONE | ||
call this%save(particle, reason=3) | ||
return | ||
end if | ||
|
||
if (no_exit_face .and. .not. dry_cell) then | ||
particle%advancing = .false. | ||
particle%istatus = TERM_NO_EXITS | ||
call this%save(particle, reason=3) | ||
return | ||
end if | ||
|
||
if (weak_sink) then | ||
if (particle%istopweaksink > 0) then | ||
particle%advancing = .false. | ||
particle%istatus = TERM_WEAKSINK | ||
call this%save(particle, reason=3) | ||
return | ||
else | ||
call this%save(particle, reason=4) | ||
end if | ||
end if | ||
|
||
if (dry_cell) then | ||
if (particle%idrymeth == 0) then | ||
! drop to cell bottom. handled by pass | ||
! to bottom method, nothing to do here | ||
no_exit_face = .false. | ||
else if (particle%idrymeth == 1) then | ||
! stop | ||
particle%advancing = .false. | ||
particle%istatus = TERM_INACTIVE | ||
call this%save(particle, reason=3) | ||
return | ||
else if (particle%idrymeth == 2) then | ||
! stay | ||
particle%advancing = .false. | ||
no_exit_face = .false. | ||
|
||
! we might report tracking times | ||
! out of order here, but we want | ||
! the particle termination event | ||
! (if this is the last time step) | ||
! to have the maximum tracking t, | ||
! so we need to keep tabs on it. | ||
ttrackmax = totim | ||
|
||
! update tracking time to time | ||
! step end time and save record | ||
particle%ttrack = totim | ||
call this%save(particle, reason=2) | ||
|
||
! record user tracking times | ||
call this%tracktimes%advance() | ||
if (this%tracktimes%any()) then | ||
do i = this%tracktimes%selection(1), this%tracktimes%selection(2) | ||
t = this%tracktimes%times(i) | ||
if (t < totimc) cycle | ||
if (t >= tmax) exit | ||
particle%ttrack = t | ||
call this%save(particle, reason=5) | ||
if (t > ttrackmax) ttrackmax = t | ||
end do | ||
end if | ||
|
||
! terminate if last period/step | ||
if (endofsimulation) then | ||
particle%istatus = TERM_NO_EXITS | ||
particle%ttrack = ttrackmax | ||
call this%save(particle, reason=3) | ||
return | ||
end if | ||
end if | ||
else if (dry_particle .and. this%name /= "passtobottom") then | ||
if (particle%idrymeth == 0) then | ||
! drop to water table | ||
particle%z = cell_defn%top | ||
call this%save(particle, reason=1) | ||
else if (particle%idrymeth == 1) then | ||
! stop | ||
particle%advancing = .false. | ||
particle%istatus = TERM_INACTIVE | ||
call this%save(particle, reason=3) | ||
return | ||
else if (particle%idrymeth == 2) then | ||
! stay | ||
particle%advancing = .false. | ||
no_exit_face = .false. | ||
|
||
! we might report tracking times | ||
! out of order here, but we want | ||
! the particle termination event | ||
! (if this is the last time step) | ||
! to have the maximum tracking t, | ||
! so we need to keep tabs on it. | ||
ttrackmax = totim | ||
|
||
! update tracking time to time | ||
! step end time and save record | ||
particle%ttrack = totim | ||
call this%save(particle, reason=2) | ||
|
||
! record user tracking times | ||
call this%tracktimes%advance() | ||
if (this%tracktimes%any()) then | ||
do i = this%tracktimes%selection(1), this%tracktimes%selection(2) | ||
t = this%tracktimes%times(i) | ||
if (t < totimc) cycle | ||
if (t >= tmax) exit | ||
particle%ttrack = t | ||
call this%save(particle, reason=5) | ||
if (t > ttrackmax) ttrackmax = t | ||
end do | ||
end if | ||
end if | ||
end if | ||
|
||
if (no_exit_face) then | ||
particle%advancing = .false. | ||
particle%istatus = TERM_NO_EXITS | ||
call this%save(particle, reason=3) | ||
return | ||
end if | ||
|
||
end subroutine check | ||
|
||
end module MethodCellModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.