Skip to content

Commit

Permalink
fix(prt): don't reset transform in subcell rect method (#2131)
Browse files Browse the repository at this point in the history
#2066 introduced a bug where particle coordinates were prematurely transformed back from cell-local coords to model coords. This produced incorrect particle positions in/near quad-refined cells.
  • Loading branch information
wpbonelli authored Jan 8, 2025
1 parent f2fe1d8 commit 2445835
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/Solution/ParticleTracker/CellDefn.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module CellDefnModule
use KindModule, only: DP, I4B, LGP
use ConstantsModule, only: DZERO
use MathUtilModule, only: is_close
implicit none

private
Expand Down
3 changes: 1 addition & 2 deletions src/Solution/ParticleTracker/Method.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ subroutine try_pass(this, particle, nextlevel, advancing)
! otherwise pass the particle to the next subdomain.
! if that leaves it on a boundary, stop advancing.
call this%pass(particle)
if (particle%iboundary(nextlevel - 1) .ne. 0) then
if (particle%iboundary(nextlevel - 1) .ne. 0) &
advancing = .false.
end if
end if
end subroutine try_pass

Expand Down
11 changes: 10 additions & 1 deletion src/Solution/ParticleTracker/MethodDisv.f90
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,25 @@ subroutine load_disv(this, particle, next_level, submethod)
ic = particle%idomain(next_level)
call this%load_cell_defn(ic, cell%defn)
if (this%fmi%ibdgwfsat0(ic) == 0) then
! Cell is active but dry, so select and initialize pass-to-bottom
! cell method and set cell method pointer
call method_cell_ptb%init( &
fmi=this%fmi, &
cell=this%cell, &
trackctl=this%trackctl, &
tracktimes=this%tracktimes)
submethod => method_cell_ptb
else if (particle%ifrctrn > 0) then
! Force the ternary method
call method_cell_tern%init( &
fmi=this%fmi, &
cell=this%cell, &
trackctl=this%trackctl, &
tracktimes=this%tracktimes)
submethod => method_cell_tern
else if (cell%defn%can_be_rect) then
! Cell is a rectangle, convert it to a rectangular cell type and
! initialize Pollock's method
call cell_poly_to_rect(cell, rect)
base => rect
call method_cell_plck%init( &
Expand All @@ -111,6 +116,8 @@ subroutine load_disv(this, particle, next_level, submethod)
tracktimes=this%tracktimes)
submethod => method_cell_plck
else if (cell%defn%can_be_quad) then
! Cell is quad-refined, convert to a quad rect cell type and
! initialize the corresponding method
call cell_poly_to_quad(cell, quad)
base => quad
call method_cell_quad%init( &
Expand All @@ -120,6 +127,7 @@ subroutine load_disv(this, particle, next_level, submethod)
tracktimes=this%tracktimes)
submethod => method_cell_quad
else
! Default to the ternary method
call method_cell_tern%init( &
fmi=this%fmi, &
cell=this%cell, &
Expand Down Expand Up @@ -232,7 +240,8 @@ subroutine pass_disv(this, particle)
particle%advancing = .false.
call this%save(particle, reason=3)
else
! Update old to new cell properties
! Otherwise, load cell properties into the
! particle. It may be marked to terminate.
call this%load_particle(cell, particle)
if (.not. particle%advancing) return

Expand Down
1 change: 0 additions & 1 deletion src/Solution/ParticleTracker/MethodSubcellPollock.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ subroutine apply_msp(this, particle, tmax)
call particle%transform(xOrigin, yOrigin)
call this%track_subcell(subcell, particle, tmax)
call particle%transform(xOrigin, yOrigin, invert=.true.)
call particle%reset_transform()
end select
end subroutine apply_msp

Expand Down

0 comments on commit 2445835

Please sign in to comment.