Changeset 5727
 Timestamp:
 Sep 3, 2008, 10:28:15 PM (14 years ago)
 Location:
 anuga_work/development/anuga_1d
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

anuga_work/development/anuga_1d/comp_flux_ext.c
r5724 r5727 19 19 /* z=(a<b)?a:b; */ 20 20 /* return z;} */ 21 22 <<<<<<< .mine23 24 25 26 27 =======28 21 29 22 … … 54 47 55 48 56 >>>>>>> .r5723 49 57 50 //Innermost flux function (using w=z+h) 58 51 int _flux_function(double *q_left, double *q_right, 
anuga_work/development/anuga_1d/dam_h_elevation.py
r5725 r5727 1 1 import os 2 2 from math import sqrt, sin, cos, pi, exp 3 from shallow_water_domain _newimport *3 from shallow_water_domain import * 4 4 from Numeric import zeros, Float 5 5 #from analytic_dam_sudi import AnalyticDam 
anuga_work/development/anuga_1d/shallow_water_domain.py
r5587 r5727 43 43 """ 44 44 45 #from domain import * 46 #from domain_order2 import * 45 47 46 from domain import * 48 47 Generic_Domain = Domain #Rename 
anuga_work/development/anuga_1d/shallow_water_domain_new.py
r5725 r5727 154 154 #Call correct module function 155 155 #(either from this module or Cextension) 156 compute_fluxes_C_ long(self) #compute_fluxes_C_wellbalanced(self) #compute_fluxes_C_long(self) #compute_fluxes(self) #compute_fluxes_C_short(self)156 compute_fluxes_C_short(self) #compute_fluxes_C_wellbalanced(self) #compute_fluxes_C_short(self) #compute_fluxes_C_long(self) 157 157 158 158 def compute_timestep(self): 
anuga_work/development/anuga_1d/test_shallow_water.py
r5587 r5727 6 6 7 7 from shallow_water_domain import * 8 from shallow_water_domain import flux_function as domain_flux_function 9 8 10 from Numeric import allclose, array, ones, Float 9 11 … … 32 34 domain.set_boundary({'exterior' : Reflective_boundary(domain)}) 33 35 34 stage_ud, xmom_ud = compute_fluxes_python(domain)36 stage_ud, xmom_ud = local_compute_fluxes(domain) 35 37 36 38 domain.compute_fluxes() 37 39 38 #print doamin.quantities['xmomentum'].explicit_update 39 #print compute_fluxes_python(domain) 40 #print domain.quantities['stage'].explicit_update 41 #print domain.quantities['xmomentum'].explicit_update 42 print stage_ud 40 43 41 44 assert allclose( domain.quantities['stage'].explicit_update, stage_ud ) … … 51 54 52 55 #This assumes h0 = 1.0e3!! 53 edgeflux, maxspeed = flux_function(normal, ql,qr,zl,zr)56 edgeflux, maxspeed = local_flux_function(normal, ql,qr,zl,zr) 54 57 #print maxspeed 55 58 #print edgeflux 56 59 57 assert allclose(array([ 1.998002, 8.89201198],Float), edgeflux)58 assert allclose(5.1 284971665, maxspeed)60 assert allclose(array([2.0, 8.9],Float), edgeflux, rtol=1.0e005) 61 assert allclose(5.1305, maxspeed, rtol=1.0e005) 59 62 60 63 normal = 1.0 … … 64 67 zr = 0.0 65 68 66 edgeflux, maxspeed = flux_function(normal, ql,qr,zl,zr)69 edgeflux, maxspeed = local_flux_function(normal, ql,qr,zl,zr) 67 70 68 71 … … 70 73 #print edgeflux 71 74 72 assert allclose(array([ 1.998002, 8.89201198],Float), edgeflux)73 assert allclose(5.1 284971665, maxspeed)75 assert allclose(array([2.0, 8.9],Float), edgeflux, rtol=1.0e005) 76 assert allclose(5.1305, maxspeed, rtol=1.0e005) 74 77 75 78 def test_domain_flux_function(self): … … 80 83 zr = 0.0 81 84 82 edgeflux, maxspeed = flux_function(normal, ql,qr,zl,zr)85 edgeflux, maxspeed = local_flux_function(normal, ql,qr,zl,zr) 83 86 84 87 #print edgeflux 85 88 86 from shallow_water_domain import flux_function as domain_flux_function 89 87 90 88 91 domainedgeflux, domainmaxspeed = domain_flux_function(normal, ql,qr,zl,zr) … … 93 96 assert allclose(domainmaxspeed, maxspeed) 94 97 98 def test_gravity(self): 99 """ 100 Compare shallow_water_domain gravity calculation 101 """ 102 103 def slope_one(x): 104 return x 105 106 domain = Domain(self.points) 107 domain.set_quantity('stage',4.0) 108 domain.set_quantity('elevation',slope_one) 109 domain.set_boundary({'exterior' : Reflective_boundary(domain)}) 110 111 gravity(domain) 112 113 #print domain.quantities['stage'].vertex_values 114 #print domain.quantities['elevation'].vertex_values 115 #print domain.quantities['xmomentum'].explicit_update 116 117 assert allclose( array([34.3, 24.5, 14.7], Float), domain.quantities['xmomentum'].explicit_update ) 118 119 120 def test_evolve(self): 121 """ 122 Compare shallow_water_domain gravity calculation 123 """ 124 125 def slope_one(x): 126 return x 127 128 domain = Domain(self.points) 129 domain.set_quantity('stage',4.0) 130 domain.set_quantity('elevation',slope_one) 131 domain.set_boundary({'exterior' : Reflective_boundary(domain)}) 132 133 yieldstep=0.01 134 finaltime=0.01 135 136 for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime): 137 domain.write_time() 138 139 print domain.quantities['stage'].vertex_values 140 print domain.quantities['elevation'].vertex_values 141 print domain.quantities['xmomentum'].vertex_values 142 143 144 print domain.quantities['stage'].centroid_values 145 print domain.quantities['elevation'].centroid_values 146 print domain.quantities['xmomentum'].centroid_values 147 148 assert allclose( array([34.3, 24.5, 14.7], Float), domain.quantities['xmomentum'].explicit_update ) 95 149 96 150 97 151 #============================================================================== 98 152 99 def compute_fluxes_python(domain):153 def local_compute_fluxes(domain): 100 154 """Compute all fluxes and the timestep suitable for all volumes 101 155 in domain. … … 122 176 N = domain.number_of_elements 123 177 124 tmp0 = zeros( (N,),Float)125 tmp1 = zeros( (N,),Float)178 tmp0 = zeros(N,Float) 179 tmp1 = zeros(N,Float) 126 180 127 181 #Shortcuts … … 222 276 223 277 224 def flux_function(normal, ql, qr, zl, zr):278 def local_flux_function(normal, ql, qr, zl, zr): 225 279 """Compute fluxes between volumes for the shallow water wave equation 226 280 cast in terms of w = h+z using the 'central scheme' as described in
Note: See TracChangeset
for help on using the changeset viewer.