Skip to content

Commit

Permalink
More comments about tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adcroft committed Oct 15, 2024
1 parent e6d706e commit 0b92daf
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 17 deletions.
23 changes: 17 additions & 6 deletions src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ subroutine test_recon_consistency(test, scheme, n0, niter, h_neglect)

end subroutine test_recon_consistency

!> Test class-based remapping that remapping a uniform field remains uniform
!> Test that remapping a uniform field remains uniform
subroutine test_preserve_uniform(test, scheme, n0, niter, h_neglect)
type(testing), intent(inout) :: test !< Unit testing convenience functions
character(len=*), intent(in) :: scheme !< Name of scheme to use
Expand All @@ -1888,8 +1888,12 @@ subroutine test_preserve_uniform(test, scheme, n0, niter, h_neglect)
integer :: iter ! Loop counter
character(len=8) :: label ! Generated label

call initialize_remapping(remapCS, scheme, force_bounds_in_subcell=.false. )
call remapCS%reconstruction%init(n0, h_neglect, check=.false.)
call initialize_remapping(remapCS, scheme, nk=n0, h_neglect=h_neglect, &
force_bounds_in_subcell=.true., &
force_bounds_in_target=.true., &
better_force_bounds_in_target=.true., &
offset_tgt_summation=.false., &
om4_remap_via_sub_cells=.false.)

error = .false.
do iter = 1, niter
Expand All @@ -1916,11 +1920,9 @@ subroutine test_preserve_uniform(test, scheme, n0, niter, h_neglect)
write(label(1:8),'(i8)') niter
call test%test( error, trim(adjustl(label))//' uniformity tests of '//scheme )

call remapCS%reconstruction%destroy()

end subroutine test_preserve_uniform

!> Test remapping to the same grid preserves answers
!> Test that remapping to the same grid preserves answers
!!
!! Notes:
!! 1) this test is currently imperfect since occasionally we see round-off
Expand Down Expand Up @@ -2735,7 +2737,16 @@ logical function remapping_unit_tests(verbose, num_comp_samp)
call test_recon_consistency(test, 'C_PPM_CWK', n0, ntests, h_neglect)
call test_recon_consistency(test, 'C_EPPM_CWK', n0, ntests, h_neglect)

call test_preserve_uniform(test, 'PCM', n0, ntests, h_neglect)
call test_preserve_uniform(test, 'C_PCM', n0, ntests, h_neglect)
! call test_preserve_uniform(test, 'PLM', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PLM_HYBGEN', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PPM_H4', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PPM_IH4', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PPM_HYBGEN', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PPM_CW', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'WENO_HYBGEN', n0, ntests, h_neglect) ! Fails
! call test_preserve_uniform(test, 'PQM_IH4IH3', n0, ntests, h_neglect) ! Fails
call test_preserve_uniform(test, 'C_PLM_CW', n0, ntests, h_neglect)
call test_preserve_uniform(test, 'C_PLM_HYBGEN', n0, ntests, h_neglect)
call test_preserve_uniform(test, 'C_MPLM_WA', n0, ntests, h_neglect)
Expand Down
2 changes: 0 additions & 2 deletions src/ALE/Recon1d_EMPLM_WA_poly.F90
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,11 @@ logical function check_reconstruction(this, h, u)
! ! Check bounding of right edges
! do K = 1, this%n-1
! if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
! if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) print *,'R',K
! enddo

! ! Check bounding of left edges
! do K = 2, this%n
! if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) check_reconstruction = .true.
! if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) print *,'L',K
! enddo

! Check order of u, ur, ul
Expand Down
9 changes: 7 additions & 2 deletions src/ALE/Recon1d_MPLM_WA.F90
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ logical function check_reconstruction(this, h, u)
! max(abs(2. * this%u_mean(k)), abs(this%ul(k)), abs(this%ur(k))) ) check_reconstruction = .true.
! enddo

! Check bounding of right edges
! Check bounding of right edges, w.r.t. the cell means
do K = 1, this%n-1
if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges
! Check bounding of left edges, w.r.t. the cell means
do K = 2, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) check_reconstruction = .true.
enddo
Expand All @@ -221,6 +221,11 @@ logical function check_reconstruction(this, h, u)
if ( ( this%ur(k) - this%u_mean(k) ) * ( this%ul(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges, w.r.t. this cell mean and the previous cell right edge
do K = 2, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%ur(k-1) ) < 0. ) check_reconstruction = .true.
enddo

end function check_reconstruction

!> Runs PLM reconstruction unit tests and returns True for any fails, False otherwise
Expand Down
5 changes: 3 additions & 2 deletions src/ALE/Recon1d_MPLM_WA_poly.F90
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,17 @@ logical function check_reconstruction(this, h, u)
max(abs(2. * this%u_mean(k)), abs(this%ul(k)), abs(this%ur(k))) ) check_reconstruction = .true.
enddo

! Check bounding of right edges
! Check bounding of right edges, w.r.t. the cell means
do K = 1, this%n-1
if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges
! Check bounding of left edges, w.r.t. the cell means
do K = 2, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges, w.r.t. this cell mean and the previous cell right edge
! Check order of u, ur, ul
! Note that in OM4 implementation, we were not consistent for top and bottom layers due
! extrapolation using cell means rather than edge values
Expand Down
16 changes: 14 additions & 2 deletions src/ALE/Recon1d_PLM_CW.F90
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,28 @@ logical function check_reconstruction(this, h, u)
max(abs(2. * this%u_mean(k)), abs(this%ul(k)), abs(this%ur(k))) ) check_reconstruction = .true.
enddo

! Check bounding of right edges
! Check bounding of right edges, w.r.t. the cell means
do K = 1, this%n-1
if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges
! Check bounding of left edges, w.r.t. the cell means
do K = 2, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) check_reconstruction = .true.
enddo

! PLM is not globally monotonic (expected)

! ! Check bounding of right edges, w.r.t. this cell mean and the next cell left edge
! do K = 1, this%n-1
! if ( ( this%ur(k) - this%u_mean(k) ) * ( this%ul(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
! enddo

! ! Check bounding of left edges, w.r.t. this cell mean and the previous cell right edge
! do K = 2, this%n
! if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%ur(k-1) ) < 0. ) check_reconstruction = .true.
! enddo

end function check_reconstruction

!> Runs PLM reconstruction unit tests and returns True for any fails, False otherwise
Expand Down
24 changes: 21 additions & 3 deletions src/ALE/Recon1d_PLM_hybgen.F90
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,39 @@ logical function check_reconstruction(this, h, u)
if ( abs( this%u_mean(k) - u(k) ) > 0. ) check_reconstruction = .true.
enddo

! Check implied curvature
! Check the cell reconstruction is monotonic within each cell (it should be as a straight line)
do k = 1, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ur(k) - this%u_mean(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of right edges
! Check the cell is a straight line (to within machine precision)
do k = 1, this%n
if ( abs(2. * this%u_mean(k) - ( this%ul(k) + this%ur(k) )) > epsilon(this%u_mean(1)) * &
max(abs(2. * this%u_mean(k)), abs(this%ul(k)), abs(this%ur(k))) ) check_reconstruction = .true.
enddo

! Check bounding of right edges, w.r.t. the cell means
do K = 1, this%n-1
if ( ( this%ur(k) - this%u_mean(k) ) * ( this%u_mean(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
enddo

! Check bounding of left edges
! Check bounding of left edges, w.r.t. the cell means
do K = 2, this%n
if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%u_mean(k-1) ) < 0. ) check_reconstruction = .true.
enddo

! PLM is not globally monotonic so the following are expected to fail

! ! Check bounding of right edges, w.r.t. this cell mean and the next cell left edge
! do K = 1, this%n-1
! if ( ( this%ur(k) - this%u_mean(k) ) * ( this%ul(k+1) - this%ur(k) ) < 0. ) check_reconstruction = .true.
! enddo

! ! Check bounding of left edges, w.r.t. this cell mean and the previous cell right edge
! do K = 2, this%n
! if ( ( this%u_mean(k) - this%ul(k) ) * ( this%ul(k) - this%ur(k-1) ) < 0. ) check_reconstruction = .true.
! enddo

end function check_reconstruction

!> Runs PLM reconstruction unit tests and returns True for any fails, False otherwise
Expand Down

0 comments on commit 0b92daf

Please sign in to comment.