Changeset 4438
- Timestamp:
- May 15, 2007, 4:34:49 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r4312 r4438 228 228 is also set by this function 229 229 """ 230 230 231 #FIXME (Ole): rename H0 to minimum_allowed_height_in_flux_computation 232 #rename limit2007 to tight_slope_limiters. 233 #Maybe use histogram to identify isolated extreme speeds and deal with them adaptively 234 #similarly to how we used to use 1 order steps to recover. 231 235 self.minimum_allowed_height = minimum_allowed_height 232 236 self.H0 = minimum_allowed_height … … 861 865 from shallow_water_ext import\ 862 866 compute_fluxes_ext_central as compute_fluxes_ext 863 864 867 865 868 domain.timestep = compute_fluxes_ext(timestep, domain.epsilon, 866 domain.H0, 869 domain.H0, 867 870 domain.g, 868 871 domain.neighbours, … … 1505 1508 1506 1509 1510 1507 1511 def manning_friction(domain): 1508 1512 """Apply (Manning) friction to water momentum … … 1806 1810 ymom_update[k] += S*v 1807 1811 1812 1813 1814 1815 class Inflow: 1816 """Class Inflow - general 'rain and drain' forcing term. 1817 1818 Useful for implementing flows in and out of the domain. 1819 1820 Inflow(center, radius, flow) 1821 1822 center [m]: Coordinates at center of flow point 1823 radius [m]: Size of circular area 1824 flow [m^3/s]: Total flow rate over the specified area. 1825 This parameter can be either a constant or a 1826 function of time. Positive values indicate inflow, 1827 negative values indicate outflow. 1828 The specified flow will be divided by the area of 1829 the inflow region and then applied to update the 1830 quantity in question. 1831 1832 Examples 1833 1834 # Constant drain at 0.003 m^3/s. 1835 # The outflow area is 0.07**2*pi=0.0154 m^2 1836 # This corresponds to a rate of change of 0.003/0.0154 = 0.2 m/s 1837 # 1838 Inflow((0.7, 0.4), 0.07, -0.003) 1839 1840 1841 # Tap turning up to a maximum inflow of 0.0142 m^3/s. 1842 # The inflow area is 0.03**2*pi = 0.00283 m^2 1843 # This corresponds to a rate of change of 0.0142/0.00283 = 5 m/s 1844 # over the specified area 1845 Inflow((0.5, 0.5), 0.03, lambda t: min(0.01*t, 0.0142)) 1846 """ 1847 1848 # FIXME (OLE): Add a polygon as an alternative. 1849 # FIXME (OLE): Generalise to all quantities 1850 1851 def __init__(self, 1852 center=None, radius=None, 1853 flow=0.0, 1854 quantity_name = 'stage'): 1855 1856 from math import pi 1857 1858 1859 1860 if center is not None and radius is not None: 1861 assert len(center) == 2 1862 else: 1863 msg = 'Both center and radius must be specified' 1864 raise Exception, msg 1865 1866 self.center = center 1867 self.radius = radius 1868 self.area = radius**2*pi 1869 self.flow = flow 1870 self.quantity_name = quantity_name 1871 1872 def __call__(self, domain): 1873 1874 # Determine indices in flow area 1875 if not hasattr(self, 'indices'): 1876 center = self.center 1877 radius = self.radius 1878 1879 N = len(domain) 1880 self.indices = [] 1881 coordinates = domain.get_centroid_coordinates() 1882 for k in range(N): 1883 x, y = coordinates[k,:] # Centroid 1884 if ((x-center[0])**2+(y-center[1])**2) < radius**2: 1885 self.indices.append(k) 1886 1887 # Update inflow 1888 if callable(self.flow): 1889 flow = self.flow(domain.get_time()) 1890 else: 1891 flow = self.flow 1892 1893 # Now flow is a number 1894 1895 quantity = domain.quantities[self.quantity_name].explicit_update 1896 for k in self.indices: 1897 quantity[k] += flow/self.area 1808 1898 1809 1899
Note: See TracChangeset
for help on using the changeset viewer.