Ignore:
Timestamp:
Sep 1, 2009, 10:29:19 AM (15 years ago)
Author:
steve
Message:

Committing latest parallel code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r7398 r7452  
    16441644                                                             verbose=False)
    16451645                assert num.allclose(Et, w + 0.5*u*u/g)
     1646
     1647
     1648    def test_cross_section_class(self):
     1649        """test_cross_section_class(self):
     1650
     1651        Test that the total and specific energy through a cross section can be
     1652        correctly obtained at run-time from the ANUGA cross section class.
     1653
     1654        This test creates a flat bed with a known flow through it, creates a cross
     1655        section and tests that the correct flow and energies are calculated
     1656
     1657        The specifics are
     1658        e = -1 m
     1659        u = 2 m/s
     1660        h = 2 m
     1661        w = 3 m (width of channel)
     1662
     1663        q = u*h*w = 12 m^3/s
     1664
     1665        This run tries it with georeferencing and with elevation = -1
     1666        """
     1667
     1668        import time, os
     1669        from Scientific.IO.NetCDF import NetCDFFile
     1670        from mesh_factory import rectangular
     1671
     1672        # Create basic mesh (20m x 3m)
     1673        width = 3
     1674        length = 20
     1675        t_end = 1
     1676        points, vertices, boundary = rectangular(length, width, length, width)
     1677
     1678        # Create shallow water domain
     1679        domain = Domain(points, vertices, boundary,
     1680                        geo_reference=Geo_reference(56, 308500, 6189000))
     1681
     1682        domain.default_order = 2
     1683        domain.set_quantities_to_be_stored(None)
     1684
     1685        e = -1.0
     1686        w = 1.0
     1687        h = w-e
     1688        u = 2.0
     1689        uh = u*h
     1690
     1691        Br = Reflective_boundary(domain)       # Side walls
     1692        Bd = Dirichlet_boundary([w, uh, 0])    # 2 m/s across the 3 m inlet:
     1693
     1694        # Initial conditions
     1695        domain.set_quantity('elevation', e)
     1696        domain.set_quantity('stage', w)
     1697        domain.set_quantity('xmomentum', uh)
     1698        domain.set_boundary({'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br})
     1699
     1700        # Interpolation points down the middle
     1701        I = [[0, width/2.],
     1702             [length/2., width/2.],
     1703             [length, width/2.]]
     1704        interpolation_points = domain.geo_reference.get_absolute(I)
     1705
     1706        # Shortcuts to quantites
     1707        stage = domain.get_quantity('stage')
     1708        xmomentum = domain.get_quantity('xmomentum')
     1709        ymomentum = domain.get_quantity('ymomentum')
     1710
     1711
     1712        # Create some cross sections
     1713        cross_sections = []
     1714        for i in range(5):
     1715            x = length/2. + i*0.23674563    # Arbitrary
     1716            polyline = [[x, 0], [x, width]]
     1717
     1718            polyline = domain.geo_reference.get_absolute(polyline)
     1719       
     1720            cross_sections.append(Cross_section(domain,polyline))
     1721
     1722
     1723 
     1724        for t in domain.evolve(yieldstep=0.1, finaltime=t_end):
     1725            # Check that quantities are they should be in the interior
     1726            w_t = stage.get_values(interpolation_points)
     1727            uh_t = xmomentum.get_values(interpolation_points)
     1728            vh_t = ymomentum.get_values(interpolation_points)
     1729
     1730            assert num.allclose(w_t, w)
     1731            assert num.allclose(uh_t, uh)
     1732            assert num.allclose(vh_t, 0.0, atol=1.0e-6)
     1733
     1734
     1735            # Check flows and energies through the middle
     1736            for cross_section in cross_sections:
     1737               
     1738                Q = cross_section.get_flow_through_cross_section()
     1739
     1740                assert num.allclose(Q, uh*width)
     1741
     1742                Es = cross_section.get_energy_through_cross_section(kind='specific')
     1743
     1744                assert num.allclose(Es, h + 0.5*u*u/g)
     1745
     1746                Et = cross_section.get_energy_through_cross_section(kind='total')
     1747               
     1748                assert num.allclose(Et, w + 0.5*u*u/g)
     1749
     1750
     1751
     1752
     1753
    16461754
    16471755    def test_another_runup_example(self):
Note: See TracChangeset for help on using the changeset viewer.