Runs unit tests on remapping functions. Should only be called from a single/root thread Returns True if a test fails, otherwise False.
1606 logical,
intent(in) :: verbose
1608 integer,
parameter :: n0 = 4, n1 = 3, n2 = 6
1609 real :: h0(n0), x0(n0+1), u0(n0)
1610 real :: h1(n1), x1(n1+1), u1(n1), hn1(n1), dx1(n1+1)
1611 real :: h2(n2), x2(n2+1), u2(n2), hn2(n2), dx2(n2+1)
1612 data u0 /9., 3., -3., -9./
1616 type(remapping_CS) :: CS
1617 real,
allocatable,
dimension(:,:) :: ppoly0_E, ppoly0_S, ppoly0_coefs
1619 real :: err, h_neglect, h_neglect_edge
1620 logical :: thisTest, v
1623 h_neglect = hneglect_dflt
1624 h_neglect_edge = 1.0e-10
1626 write(*,*)
'==== MOM_remapping: remapping_unit_tests ================='
1627 remapping_unit_tests = .false.
1630 call buildgridfromh(n0, h0, x0)
1632 err=x0(i)-0.75*real(i-1)
1633 if (abs(err)>real(i-1)*epsilon(err)) thistest = .true.
1635 if (thistest)
write(*,*)
'remapping_unit_tests: Failed buildGridFromH() 1'
1636 remapping_unit_tests = remapping_unit_tests .or. thistest
1637 call buildgridfromh(n1, h1, x1)
1640 if (abs(err)>real(i-1)*epsilon(err)) thistest = .true.
1642 if (thistest)
write(*,*)
'remapping_unit_tests: Failed buildGridFromH() 2'
1643 remapping_unit_tests = remapping_unit_tests .or. thistest
1646 call initialize_remapping(cs,
'PPM_H4')
1647 if (verbose)
write(*,*)
'h0 (test data)'
1648 if (verbose)
call dumpgrid(n0,h0,x0,u0)
1650 call dzfromh1h2( n0, h0, n1, h1, dx1 )
1651 call remapping_core_w( cs, n0, h0, u0, n1, dx1, u1, h_neglect, h_neglect_edge)
1653 err=u1(i)-8.*(0.5*real(1+n1)-real(i))
1654 if (abs(err)>real(n1-1)*epsilon(err)) thistest = .true.
1656 if (verbose)
write(*,*)
'h1 (by projection)'
1657 if (verbose)
call dumpgrid(n1,h1,x1,u1)
1658 if (thistest)
write(*,*)
'remapping_unit_tests: Failed remapping_core_w()'
1659 remapping_unit_tests = remapping_unit_tests .or. thistest
1662 allocate(ppoly0_e(n0,2))
1663 allocate(ppoly0_s(n0,2))
1664 allocate(ppoly0_coefs(n0,cs%degree+1))
1668 ppoly0_coefs(:,:) = 0.0
1670 call edge_values_explicit_h4( n0, h0, u0, ppoly0_e, h_neglect=1e-10 )
1671 call ppm_reconstruction( n0, h0, u0, ppoly0_e, ppoly0_coefs, h_neglect )
1672 call ppm_boundary_extrapolation( n0, h0, u0, ppoly0_e, ppoly0_coefs, h_neglect )
1674 call remapbyprojection( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1675 n1, h1, integration_ppm, u1, h_neglect )
1677 err=u1(i)-8.*(0.5*real(1+n1)-real(i))
1678 if (abs(err)>2.*epsilon(err)) thistest = .true.
1680 if (thistest)
write(*,*)
'remapping_unit_tests: Failed remapByProjection()'
1681 remapping_unit_tests = remapping_unit_tests .or. thistest
1685 call remapbydeltaz( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1686 n1, x1-x0(1:n1+1), &
1687 integration_ppm, u1, hn1, h_neglect )
1688 if (verbose)
write(*,*)
'h1 (by delta)'
1689 if (verbose)
call dumpgrid(n1,h1,x1,u1)
1692 err=u1(i)-8.*(0.5*real(1+n1)-real(i))
1693 if (abs(err)>2.*epsilon(err)) thistest = .true.
1695 if (thistest)
write(*,*)
'remapping_unit_tests: Failed remapByDeltaZ() 1'
1696 remapping_unit_tests = remapping_unit_tests .or. thistest
1699 call buildgridfromh(n2, h2, x2)
1700 dx2(1:n0+1) = x2(1:n0+1) - x0
1701 dx2(n0+2:n2+1) = x2(n0+2:n2+1) - x0(n0+1)
1702 call remapbydeltaz( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1704 integration_ppm, u2, hn2, h_neglect )
1705 if (verbose)
write(*,*)
'h2'
1706 if (verbose)
call dumpgrid(n2,h2,x2,u2)
1707 if (verbose)
write(*,*)
'hn2'
1708 if (verbose)
call dumpgrid(n2,hn2,x2,u2)
1711 err=u2(i)-8./2.*(0.5*real(1+n2)-real(i))
1712 if (abs(err)>2.*epsilon(err)) thistest = .true.
1714 if (thistest)
write(*,*)
'remapping_unit_tests: Failed remapByDeltaZ() 2'
1715 remapping_unit_tests = remapping_unit_tests .or. thistest
1717 if (verbose)
write(*,*)
'Via sub-cells'
1719 call remap_via_sub_cells( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1720 n2, h2, integration_ppm, .false., u2, err )
1721 if (verbose)
call dumpgrid(n2,h2,x2,u2)
1724 err=u2(i)-8./2.*(0.5*real(1+n2)-real(i))
1725 if (abs(err)>2.*epsilon(err)) thistest = .true.
1727 if (thistest)
write(*,*)
'remapping_unit_tests: Failed remap_via_sub_cells() 2'
1728 remapping_unit_tests = remapping_unit_tests .or. thistest
1730 call remap_via_sub_cells( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1731 6, (/.125,.125,.125,.125,.125,.125/), integration_ppm, .false., u2, err )
1732 if (verbose)
call dumpgrid(6,h2,x2,u2)
1734 call remap_via_sub_cells( n0, h0, u0, ppoly0_e, ppoly0_coefs, &
1735 3, (/2.25,1.5,1./), integration_ppm, .false., u2, err )
1736 if (verbose)
call dumpgrid(3,h2,x2,u2)
1738 if (.not. remapping_unit_tests)
write(*,*)
'Pass'
1740 write(*,*)
'===== MOM_remapping: new remapping_unit_tests =================='
1742 deallocate(ppoly0_e, ppoly0_s, ppoly0_coefs)
1743 allocate(ppoly0_coefs(5,6))
1744 allocate(ppoly0_e(5,2))
1745 allocate(ppoly0_s(5,2))
1747 call pcm_reconstruction(3, (/1.,2.,4./), ppoly0_e(1:3,:), &
1748 ppoly0_coefs(1:3,:) )
1749 remapping_unit_tests = remapping_unit_tests .or. &
1750 test_answer(v, 3, ppoly0_e(:,1), (/1.,2.,4./),
'PCM: left edges')
1751 remapping_unit_tests = remapping_unit_tests .or. &
1752 test_answer(v, 3, ppoly0_e(:,2), (/1.,2.,4./),
'PCM: right edges')
1753 remapping_unit_tests = remapping_unit_tests .or. &
1754 test_answer(v, 3, ppoly0_coefs(:,1), (/1.,2.,4./),
'PCM: P0')
1756 call plm_reconstruction(3, (/1.,1.,1./), (/1.,3.,5./), ppoly0_e(1:3,:), &
1757 ppoly0_coefs(1:3,:), h_neglect )
1758 remapping_unit_tests = remapping_unit_tests .or. &
1759 test_answer(v, 3, ppoly0_e(:,1), (/1.,2.,5./),
'Unlim PLM: left edges')
1760 remapping_unit_tests = remapping_unit_tests .or. &
1761 test_answer(v, 3, ppoly0_e(:,2), (/1.,4.,5./),
'Unlim PLM: right edges')
1762 remapping_unit_tests = remapping_unit_tests .or. &
1763 test_answer(v, 3, ppoly0_coefs(:,1), (/1.,2.,5./),
'Unlim PLM: P0')
1764 remapping_unit_tests = remapping_unit_tests .or. &
1765 test_answer(v, 3, ppoly0_coefs(:,2), (/0.,2.,0./),
'Unlim PLM: P1')
1767 call plm_reconstruction(3, (/1.,1.,1./), (/1.,2.,7./), ppoly0_e(1:3,:), &
1768 ppoly0_coefs(1:3,:), h_neglect )
1769 remapping_unit_tests = remapping_unit_tests .or. &
1770 test_answer(v, 3, ppoly0_e(:,1), (/1.,1.,7./),
'Left lim PLM: left edges')
1771 remapping_unit_tests = remapping_unit_tests .or. &
1772 test_answer(v, 3, ppoly0_e(:,2), (/1.,3.,7./),
'Left lim PLM: right edges')
1773 remapping_unit_tests = remapping_unit_tests .or. &
1774 test_answer(v, 3, ppoly0_coefs(:,1), (/1.,1.,7./),
'Left lim PLM: P0')
1775 remapping_unit_tests = remapping_unit_tests .or. &
1776 test_answer(v, 3, ppoly0_coefs(:,2), (/0.,2.,0./),
'Left lim PLM: P1')
1778 call plm_reconstruction(3, (/1.,1.,1./), (/1.,6.,7./), ppoly0_e(1:3,:), &
1779 ppoly0_coefs(1:3,:), h_neglect )
1780 remapping_unit_tests = remapping_unit_tests .or. &
1781 test_answer(v, 3, ppoly0_e(:,1), (/1.,5.,7./),
'Right lim PLM: left edges')
1782 remapping_unit_tests = remapping_unit_tests .or. &
1783 test_answer(v, 3, ppoly0_e(:,2), (/1.,7.,7./),
'Right lim PLM: right edges')
1784 remapping_unit_tests = remapping_unit_tests .or. &
1785 test_answer(v, 3, ppoly0_coefs(:,1), (/1.,5.,7./),
'Right lim PLM: P0')
1786 remapping_unit_tests = remapping_unit_tests .or. &
1787 test_answer(v, 3, ppoly0_coefs(:,2), (/0.,2.,0./),
'Right lim PLM: P1')
1789 call plm_reconstruction(3, (/1.,2.,3./), (/1.,4.,9./), ppoly0_e(1:3,:), &
1790 ppoly0_coefs(1:3,:), h_neglect )
1791 remapping_unit_tests = remapping_unit_tests .or. &
1792 test_answer(v, 3, ppoly0_e(:,1), (/1.,2.,9./),
'Non-uniform line PLM: left edges')
1793 remapping_unit_tests = remapping_unit_tests .or. &
1794 test_answer(v, 3, ppoly0_e(:,2), (/1.,6.,9./),
'Non-uniform line PLM: right edges')
1795 remapping_unit_tests = remapping_unit_tests .or. &
1796 test_answer(v, 3, ppoly0_coefs(:,1), (/1.,2.,9./),
'Non-uniform line PLM: P0')
1797 remapping_unit_tests = remapping_unit_tests .or. &
1798 test_answer(v, 3, ppoly0_coefs(:,2), (/0.,4.,0./),
'Non-uniform line PLM: P1')
1800 call edge_values_explicit_h4( 5, (/1.,1.,1.,1.,1./), (/1.,3.,5.,7.,9./), ppoly0_e, &
1803 thistest = test_answer(v, 5, ppoly0_e(:,1), (/0.,2.,4.,6.,8./),
'Line H4: left edges')
1804 thistest = test_answer(v, 5, ppoly0_e(:,2), (/2.,4.,6.,8.,10./),
'Line H4: right edges')
1805 ppoly0_e(:,1) = (/0.,2.,4.,6.,8./)
1806 ppoly0_e(:,2) = (/2.,4.,6.,8.,10./)
1807 call ppm_reconstruction(5, (/1.,1.,1.,1.,1./), (/1.,3.,5.,7.,9./), ppoly0_e(1:5,:), &
1808 ppoly0_coefs(1:5,:), h_neglect )
1809 remapping_unit_tests = remapping_unit_tests .or. &
1810 test_answer(v, 5, ppoly0_coefs(:,1), (/1.,2.,4.,6.,9./),
'Line PPM: P0')
1811 remapping_unit_tests = remapping_unit_tests .or. &
1812 test_answer(v, 5, ppoly0_coefs(:,2), (/0.,2.,2.,2.,0./),
'Line PPM: P1')
1813 remapping_unit_tests = remapping_unit_tests .or. &
1814 test_answer(v, 5, ppoly0_coefs(:,3), (/0.,0.,0.,0.,0./),
'Line PPM: P2')
1816 call edge_values_explicit_h4( 5, (/1.,1.,1.,1.,1./), (/1.,1.,7.,19.,37./), ppoly0_e, &
1819 thistest = test_answer(v, 5, ppoly0_e(:,1), (/3.,0.,3.,12.,27./),
'Parabola H4: left edges')
1820 thistest = test_answer(v, 5, ppoly0_e(:,2), (/0.,3.,12.,27.,48./),
'Parabola H4: right edges')
1821 ppoly0_e(:,1) = (/0.,0.,3.,12.,27./)
1822 ppoly0_e(:,2) = (/0.,3.,12.,27.,48./)
1823 call ppm_reconstruction(5, (/1.,1.,1.,1.,1./), (/0.,1.,7.,19.,37./), ppoly0_e(1:5,:), &
1824 ppoly0_coefs(1:5,:), h_neglect )
1825 remapping_unit_tests = remapping_unit_tests .or. &
1826 test_answer(v, 5, ppoly0_e(:,1), (/0.,0.,3.,12.,37./),
'Parabola PPM: left edges')
1827 remapping_unit_tests = remapping_unit_tests .or. &
1828 test_answer(v, 5, ppoly0_e(:,2), (/0.,3.,12.,27.,37./),
'Parabola PPM: right edges')
1829 remapping_unit_tests = remapping_unit_tests .or. &
1830 test_answer(v, 5, ppoly0_coefs(:,1), (/0.,0.,3.,12.,37./),
'Parabola PPM: P0')
1831 remapping_unit_tests = remapping_unit_tests .or. &
1832 test_answer(v, 5, ppoly0_coefs(:,2), (/0.,0.,6.,12.,0./),
'Parabola PPM: P1')
1833 remapping_unit_tests = remapping_unit_tests .or. &
1834 test_answer(v, 5, ppoly0_coefs(:,3), (/0.,3.,3.,3.,0./),
'Parabola PPM: P2')
1836 ppoly0_e(:,1) = (/0.,0.,6.,10.,15./)
1837 ppoly0_e(:,2) = (/0.,6.,12.,17.,15./)
1838 call ppm_reconstruction(5, (/1.,1.,1.,1.,1./), (/0.,5.,7.,16.,15./), ppoly0_e(1:5,:), &
1839 ppoly0_coefs(1:5,:), h_neglect )
1840 remapping_unit_tests = remapping_unit_tests .or. &
1841 test_answer(v, 5, ppoly0_e(:,1), (/0.,3.,6.,16.,15./),
'Limits PPM: left edges')
1842 remapping_unit_tests = remapping_unit_tests .or. &
1843 test_answer(v, 5, ppoly0_e(:,2), (/0.,6.,9.,16.,15./),
'Limits PPM: right edges')
1844 remapping_unit_tests = remapping_unit_tests .or. &
1845 test_answer(v, 5, ppoly0_coefs(:,1), (/0.,3.,6.,16.,15./),
'Limits PPM: P0')
1846 remapping_unit_tests = remapping_unit_tests .or. &
1847 test_answer(v, 5, ppoly0_coefs(:,2), (/0.,6.,0.,0.,0./),
'Limits PPM: P1')
1848 remapping_unit_tests = remapping_unit_tests .or. &
1849 test_answer(v, 5, ppoly0_coefs(:,3), (/0.,-3.,3.,0.,0./),
'Limits PPM: P2')
1851 call plm_reconstruction(4, (/0.,1.,1.,0./), (/5.,4.,2.,1./), ppoly0_e(1:4,:), &
1852 ppoly0_coefs(1:4,:), h_neglect )
1853 remapping_unit_tests = remapping_unit_tests .or. &
1854 test_answer(v, 4, ppoly0_e(1:4,1), (/5.,5.,3.,1./),
'PPM: left edges h=0110')
1855 remapping_unit_tests = remapping_unit_tests .or. &
1856 test_answer(v, 4, ppoly0_e(1:4,2), (/5.,3.,1.,1./),
'PPM: right edges h=0110')
1857 call remap_via_sub_cells( 4, (/0.,1.,1.,0./), (/5.,4.,2.,1./), ppoly0_e(1:4,:), &
1858 ppoly0_coefs(1:4,:), &
1859 2, (/1.,1./), integration_plm, .false., u2, err )
1860 remapping_unit_tests = remapping_unit_tests .or. &
1861 test_answer(v, 2, u2, (/4.,2./),
'PLM: remapped h=0110->h=11')
1863 deallocate(ppoly0_e, ppoly0_s, ppoly0_coefs)
1865 if (.not. remapping_unit_tests)
write(*,*)
'Pass'