Skip to content

Commit

Permalink
Replaced lr_edge() and inv_f() with f() and dfdx()
Browse files Browse the repository at this point in the history
  • Loading branch information
adcroft committed Aug 8, 2024
1 parent 9984bf8 commit e5aa270
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 347 deletions.
1 change: 1 addition & 0 deletions src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ logical function remapping_unit_tests(verbose, num_comp_samp)
type(PPM_H4_2019) :: PPM_H4_2019

call test%set( verbose=verbose ) ! Sets the verbosity flag in test
! call test%set( stop_instantly=.true. ) ! While debugging

answer_date = 20190101 ! 20181231
h_neglect = hNeglect_dflt
Expand Down
36 changes: 15 additions & 21 deletions src/ALE/Recon1d_EMPLM_WA.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ module Recon1d_EMPLM_WA
!! The source for the methods ultimately used by this class are:
!! init() -> MPLM_WA%init() -> PLM_CW%init()
!! reconstruct() *locally defined
!! lr_edge() -> MPLM_WA%lr_edge() -> PLM_CW%lr_edge()
!! average() -> MPLM_WA%average() -> PLM_CW%average()
!! inv_f() -> MPLM_WA%inv_f() -> PLM_CW%inv_f()
!! f() -> MPLM_WA%f() -> PLM_CW%f()
!! dfdx() -> MPLM_WA%dfdx() -> PLM_CW%dfdx()
!! check_reconstruction() -> MPLM_WA%check_reconstruction()
!! unit_tests() *locally defined
!! destroy() -> MPLM_WA%destroy() -> PLM_CW%destroy()
!! cell_mean() -> MPLM_WA%cell_mean() -> PLM_CW%cell_mean() -> Recon1d%cell_mean()
!! remap_to_sub_grid() -> MPLM_WA%remap_to_sub_grid() -> PLM_CW%remap_to_sub_grd() -> Recon1d%remap_to_sub_grid()
!! init_parent() -> MPLM_WA%init_parent() -> PLM_CW%init()
!! reconstruct_parent() -> MPLM_WA%reconstruct()
Expand Down Expand Up @@ -140,35 +139,30 @@ logical function unit_tests(this, verbose, stdout, stderr)

call this%reconstruct( (/2.,2.,2./), (/1.,3.,5./) )
call test%real_arr(3, this%u_mean, (/1.,3.,5./), 'Setting cell values')

do k = 1, 3
um(k) = this%cell_mean(k)
ul(k) = this%f(k, 0.)
um(k) = this%f(k, 0.5)
ur(k) = this%f(k, 1.)
enddo
call test%real_arr(3, um, (/1.,3.,5./), 'Return cell mean')
call test%real_arr(3, ul, (/0.,2.,4./), 'Evaluation on left edge')
call test%real_arr(3, um, (/1.,3.,5./), 'Evaluation in center')
call test%real_arr(3, ur, (/2.,4.,6./), 'Evaluation on right edge')

do k = 1, 3
call this%lr_edge(k, ul(k), ur(k))
ul(k) = this%dfdx(k, 0.)
um(k) = this%dfdx(k, 0.5)
ur(k) = this%dfdx(k, 1.)
enddo
call test%real_arr(3, ul, (/0.,2.,4./), 'Return left edge')
call test%real_arr(3, ur, (/2.,4.,6./), 'Return right edge')
call test%real_arr(3, ul, (/2.,2.,2./), 'dfdx on left edge')
call test%real_arr(3, um, (/2.,2.,2./), 'dfdx in center')
call test%real_arr(3, ur, (/2.,2.,2./), 'dfdx on right edge')

do k = 1, 3
um(k) = this%average(k, 0.5, 0.75) ! Average from x=0.25 to 0.75 in each cell
enddo
call test%real_arr(3, um, (/1.25,3.25,5.25/), 'Return interval average')

do k = 1, 3
ull(k) = this%inv_f(k, real(2*k-2))
ul(k) = this%inv_f(k, real(2*k-1)-0.5)
um(k) = this%inv_f(k, real(2*k-1))
ur(k) = this%inv_f(k, real(2*k-1)+0.5)
urr(k) = this%inv_f(k, real(2*k-0))
enddo
call test%real_arr(3, ull, (/0.,0.,0./), 'Return position of f<<')
call test%real_arr(3, ul, (/0.25,0.25,0.25/), 'Return position of f<')
call test%real_arr(3, um, (/0.5,0.5,0.5/), 'Return position of f=')
call test%real_arr(3, ur, (/0.75,0.75,0.75/), 'Return position of f>')
call test%real_arr(3, urr, (/1.,1.,1./), 'Return position of f>>')

unit_tests = test%summarize('EMPLM_WA:unit_tests')

end function unit_tests
Expand Down
37 changes: 15 additions & 22 deletions src/ALE/Recon1d_EMPLM_WA_poly.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ module Recon1d_EMPLM_WA_poly
!! The source for the methods ultimately used by this class are:
!! init() -> MPLM_WA_poly%init()
!! reconstruct() -> MPLM_WA_poly%reconstruct()
!! lr_edge() -> MPLM_WA_poly%lr_edge() -> MPLM_WA_poly%lr_edge() -> PLM_CW%lr_edge()
!! average() -> MPLM_WA_poly%average()
!! inv_f() -> MPLM_WA_poly%inv_f() -> MPLM_WA_poly%inv_f() -> PLM_CW%inv_f()
!! f() -> MPLM_WA_poly%f() -> MPLM_WA_poly%f() -> PLM_CW%f()
!! dfdx() -> MPLM_WA_poly%dfdx() -> MPLM_WA_poly%dfdx() -> PLM_CW%dfdx()
!! check_reconstruction() -> MPLM_WA_poly%check_reconstruction()
!! unit_tests() *locally defined
!! destroy() -> MPLM_WA_poly%destroy() -> MPLM_WA%destroy() -> PLM_CW%destroy()
!! cell_mean() -> MPLM_WA_poly%cell_mean() -> MPLM_WA%cell_mean() -> PLM_CW%cell_mean()
!! -> Recon1d%cell_mean()
!! remap_to_sub_grid() *locally defined
!! init_parent() -> MPLM_WA_poly%init()
!! reconstruct_parent() -> MPLM_WA_poly%reconstruct()
Expand Down Expand Up @@ -120,35 +118,30 @@ logical function unit_tests(this, verbose, stdout, stderr)

call this%reconstruct( (/2.,2.,2./), (/1.,3.,5./) )
call test%real_arr(3, this%u_mean, (/1.,3.,5./), 'Setting cell values')

do k = 1, 3
um(k) = this%cell_mean(k)
ul(k) = this%f(k, 0.)
um(k) = this%f(k, 0.5)
ur(k) = this%f(k, 1.)
enddo
call test%real_arr(3, um, (/1.,3.,5./), 'Return cell mean')
call test%real_arr(3, ul, (/0.,2.,4./), 'Evaluation on left edge')
call test%real_arr(3, um, (/1.,3.,5./), 'Evaluation in center')
call test%real_arr(3, ur, (/2.,4.,6./), 'Evaluation on right edge')

do k = 1, 3
call this%lr_edge(k, ul(k), ur(k))
ul(k) = this%dfdx(k, 0.)
um(k) = this%dfdx(k, 0.5)
ur(k) = this%dfdx(k, 1.)
enddo
call test%real_arr(3, ul, (/0.,2.,4./), 'Return left edge')
call test%real_arr(3, ur, (/2.,4.,6./), 'Return right edge')
call test%real_arr(3, ul, (/2.,2.,2./), 'dfdx on left edge')
call test%real_arr(3, um, (/2.,2.,2./), 'dfdx in center')
call test%real_arr(3, ur, (/2.,2.,2./), 'dfdx on right edge')

do k = 1, 3
um(k) = this%average(k, 0.5, 0.75) ! Average from x=0.25 to 0.75 in each cell
enddo
call test%real_arr(3, um, (/1.25,3.25,5.25/), 'Return interval average')

do k = 1, 3
ull(k) = this%inv_f(k, real(2*k-2))
ul(k) = this%inv_f(k, real(2*k-1)-0.5)
um(k) = this%inv_f(k, real(2*k-1))
ur(k) = this%inv_f(k, real(2*k-1)+0.5)
urr(k) = this%inv_f(k, real(2*k-0))
enddo
call test%real_arr(3, ull, (/0.,0.,0./), 'Return position of f<<')
call test%real_arr(3, ul, (/0.25,0.25,0.25/), 'Return position of f<')
call test%real_arr(3, um, (/0.5,0.5,0.5/), 'Return position of f=')
call test%real_arr(3, ur, (/0.75,0.75,0.75/), 'Return position of f>')
call test%real_arr(3, urr, (/1.,1.,1./), 'Return position of f>>')

unit_tests = test%summarize('EMPLM_WA_poly:unit_tests')

end function unit_tests
Expand Down
36 changes: 15 additions & 21 deletions src/ALE/Recon1d_MPLM_WA.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ module Recon1d_MPLM_WA
!! The source for the methods ultimately used by this class are:
!! init() -> PLM_CW%init()
!! reconstruct() *locally defined
!! lr_edge() -> PLM_CW%lr_edge()
!! average() -> PLM_CW%average()
!! inv_f() -> PLM_CW%inv_f()
!! f() -> PLM_CW%f()
!! dfdx() -> PLM_CW%dfdx()
!! check_reconstruction() *locally defined
!! unit_tests() *locally defined
!! destroy() -> PLM_CW%destroy()
!! cell_mean() -> PLM_CW%cell_mean() -> Recon1d%cell_mean()
!! remap_to_sub_grid() -> PLM_CW%remap_to_sub_grd() -> Recon1d%remap_to_sub_grid()
!! init_parent() -> PLM_CW%init()
!! reconstruct_parent() -> reconstruct()
Expand Down Expand Up @@ -234,35 +233,30 @@ logical function unit_tests(this, verbose, stdout, stderr)

call this%reconstruct( (/2.,2.,2./), (/1.,3.,5./) )
call test%real_arr(3, this%u_mean, (/1.,3.,5./), 'Setting cell values')

do k = 1, 3
um(k) = this%cell_mean(k)
ul(k) = this%f(k, 0.)
um(k) = this%f(k, 0.5)
ur(k) = this%f(k, 1.)
enddo
call test%real_arr(3, um, (/1.,3.,5./), 'Return cell mean')
call test%real_arr(3, ul, (/1.,2.,5./), 'Evaluation on left edge')
call test%real_arr(3, um, (/1.,3.,5./), 'Evaluation in center')
call test%real_arr(3, ur, (/1.,4.,5./), 'Evaluation on right edge')

do k = 1, 3
call this%lr_edge(k, ul(k), ur(k))
ul(k) = this%dfdx(k, 0.)
um(k) = this%dfdx(k, 0.5)
ur(k) = this%dfdx(k, 1.)
enddo
call test%real_arr(3, ul, (/1.,2.,5./), 'Return left edge')
call test%real_arr(3, ur, (/1.,4.,5./), 'Return right edge')
call test%real_arr(3, ul, (/0.,2.,0./), 'dfdx on left edge')
call test%real_arr(3, um, (/0.,2.,0./), 'dfdx in center')
call test%real_arr(3, ur, (/0.,2.,0./), 'dfdx on right edge')

do k = 1, 3
um(k) = this%average(k, 0.5, 0.75) ! Average from x=0.25 to 0.75 in each cell
enddo
call test%real_arr(3, um, (/1.,3.25,5./), 'Return interval average')

do k = 1, 3
ull(k) = this%inv_f(k, real(2*k-2))
ul(k) = this%inv_f(k, real(2*k-1)-0.5)
um(k) = this%inv_f(k, real(2*k-1))
ur(k) = this%inv_f(k, real(2*k-1)+0.5)
urr(k) = this%inv_f(k, real(2*k-0))
enddo
call test%real_arr(3, ull, (/0.,0.,0./), 'Return position of f<<')
call test%real_arr(3, ul, (/0.,0.25,0./), 'Return position of f<')
call test%real_arr(3, um, (/0.5,0.5,0.5/), 'Return position of f=')
call test%real_arr(3, ur, (/1.,0.75,1./), 'Return position of f>')
call test%real_arr(3, urr, (/1.,1.,1./), 'Return position of f>>')

unit_tests = test%summarize('MPLM_WA:unit_tests')

end function unit_tests
Expand Down
41 changes: 18 additions & 23 deletions src/ALE/Recon1d_MPLM_WA_poly.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ module Recon1d_MPLM_WA_poly
!! The source for the methods ultimately used by this class are:
!! init() *locally defined
!! reconstruct() *locally defined
!! lr_edge() -> MPLM_WA%lr_edge() -> PLM_CW%lr_edge()
!! average() *locally defined
!! inv_f() -> MPLM_WA%inv_f() -> PLM_CW%inv_f()
!! f() -> MPLM_WA%f() -> PLM_CW%f()
!! dfdx() -> MPLM_WA%dfdx() -> PLM_CW%dfdx()
!! check_reconstruction() *locally defined
!! unit_tests() *locally defined
!! destroy() -> MPLM_WA%destroy() -> PLM_CW%destroy()
!! cell_mean() -> MPLM_WA%cell_mean() -> PLM_CW%cell_mean() -> Recon1d%cell_mean()
!! remap_to_sub_grid() *locally defined
!! init_parent() -> init()
!! reconstruct_parent() -> reconstruct()
Expand Down Expand Up @@ -89,7 +88,7 @@ subroutine init(this, n, h_neglect, check)

end subroutine init

!> Calculate a 1D PLM reconstructions based on h(:) and u(:)
!> Calculate a 1D MPLM_WA_poly reconstructions based on h(:) and u(:)
subroutine reconstruct(this, h, u)
class(MPLM_WA_poly), intent(inout) :: this !< This reconstruction
real, intent(in) :: h(*) !< Grid spacing (thickness) [typically H]
Expand Down Expand Up @@ -294,7 +293,8 @@ subroutine remap_to_sub_grid(this, h0, u0, n1, h_sub, &

i0_last_thick_cell = 0
do i0 = 1, n0
call this%lr_edge(i0, ul, ur)
ul = this%ul(i0)
ur = this%ur(i0)
u0_min(i0) = min(ul, ur)
u0_max(i0) = max(ul, ur)
if (h0(i0)>0.) i0_last_thick_cell = i0
Expand Down Expand Up @@ -451,35 +451,30 @@ logical function unit_tests(this, verbose, stdout, stderr)

call this%reconstruct( (/2.,2.,2./), (/1.,3.,5./) )
call test%real_arr(3, this%u_mean, (/1.,3.,5./), 'Setting cell values')

do k = 1, 3
um(k) = this%cell_mean(k)
ul(k) = this%f(k, 0.)
um(k) = this%f(k, 0.5)
ur(k) = this%f(k, 1.)
enddo
call test%real_arr(3, um, (/1.,3.,5./), 'Return cell mean')
call test%real_arr(3, ul, (/1.,2.,5./), 'Evaluation on left edge')
call test%real_arr(3, um, (/1.,3.,5./), 'Evaluation in center')
call test%real_arr(3, ur, (/1.,4.,5./), 'Evaluation on right edge')

do k = 1, 3
call this%lr_edge(k, ul(k), ur(k))
ul(k) = this%dfdx(k, 0.)
um(k) = this%dfdx(k, 0.5)
ur(k) = this%dfdx(k, 1.)
enddo
call test%real_arr(3, ul, (/1.,2.,5./), 'Return left edge')
call test%real_arr(3, ur, (/1.,4.,5./), 'Return right edge')
call test%real_arr(3, ul, (/0.,2.,0./), 'dfdx on left edge')
call test%real_arr(3, um, (/0.,2.,0./), 'dfdx in center')
call test%real_arr(3, ur, (/0.,2.,0./), 'dfdx on right edge')

do k = 1, 3
um(k) = this%average(k, 0.5, 0.75) ! Average from x=0.25 to 0.75 in each cell
enddo
call test%real_arr(3, um, (/1.,3.25,5./), 'Return interval average')

do k = 1, 3
ull(k) = this%inv_f(k, real(2*k-2))
ul(k) = this%inv_f(k, real(2*k-1)-0.5)
um(k) = this%inv_f(k, real(2*k-1))
ur(k) = this%inv_f(k, real(2*k-1)+0.5)
urr(k) = this%inv_f(k, real(2*k-0))
enddo
call test%real_arr(3, ull, (/0.,0.,0./), 'Return position of f<<')
call test%real_arr(3, ul, (/0.,0.25,0./), 'Return position of f<')
call test%real_arr(3, um, (/0.5,0.5,0.5/), 'Return position of f=')
call test%real_arr(3, ur, (/1.,0.75,1./), 'Return position of f>')
call test%real_arr(3, urr, (/1.,1.,1./), 'Return position of f>>')

unit_tests = test%summarize('MPLM_WA_poly:unit_tests')

end function unit_tests
Expand Down
Loading

0 comments on commit e5aa270

Please sign in to comment.