Changeset 5672
- Timestamp:
- Aug 21, 2008, 4:32:14 PM (16 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/anuga_user_manual.tex
r5657 r5672 2254 2254 appropriate segments for each conserved quantity. 2255 2255 2256 Optional argument \code{default_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2257 The default_boundary could be a simple Dirichlet condition or even another File\_boundary 2256 Optional argument \code{default\_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2257 The \code{default\_boundary} could be a simple Dirichlet condition or 2258 even another \code{File\_boundary} 2258 2259 typically using data pertaining to another time interval. 2259 2260 \end{classdesc} 2260 2261 2261 2262 \begin{classdesc}{Field\_boundary}{Boundary} 2263 Module: \module{shallow\_water.shallow\_water\_domain} 2264 2265 This method works in the same way as \code{File\_boundary} except that it 2266 allows for the value of stage to be offset by a constant specified in the 2267 keyword argument \code{mean\_stage}. 2268 2269 This functionality allows for models to be run for a range of tides using 2270 the same boundary information (from .sts, .sww or .tms files). The tidal value 2271 for each run would then be specified in the keyword argument 2272 \code{mean\_stage}. 2273 If \code{mean\_stage} = 0.0, \code{Field\_boundary} and \code{File\_boundary} 2274 behave identically. 2275 2276 2277 Note that if the optional argument \code{default\_boundary} is specified 2278 it's stage value will be adjusted by \code{mean\_stage} just like the values 2279 obtained from the file. 2280 2281 See \code{File\_boundary} for further details. 2282 \end{classdesc} 2262 2283 2263 2284 %%% -
anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r5666 r5672 332 332 # Pass control to default boundary 333 333 res = self.default_boundary.evaluate(vol_id, edge_id) 334 334 335 # Ensure that result cannot be manipulated 336 # This is a real danger in case the 337 # default_boundary is a Dirichlet type 338 # for instance. 339 res = res.copy() 340 335 341 if self.default_boundary_invoked is False: 336 342 # Issue warning the first time … … 347 353 348 354 349 350 351 355 if res == NAN: 352 356 x,y=self.midpoint_coordinates[i,:] -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r5657 r5672 1145 1145 vol_id and edge_id are ignored 1146 1146 """ 1147 1147 1148 1148 # Evaluate file boundary 1149 1149 q = self.file_boundary.evaluate(vol_id, edge_id) -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5657 r5672 7801 7801 from anuga.pmesh.mesh_interface import create_mesh_from_regions 7802 7802 7803 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]] 7803 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0], 7804 [6.02,97.02],[6.00,97.02]] 7804 7805 tide = 0.37 7805 7806 time_step_count = 5 7806 7807 time_step = 2 7807 lat_long_points = bounding_polygon[0:3]7808 lat_long_points = bounding_polygon[0:3] 7808 7809 n=len(lat_long_points) 7809 7810 first_tstep=ones(n,Int) … … 7936 7937 os.remove(meshname) 7937 7938 7938 7939 7940 7941 7942 7943 def test_field_boundary_stsI_beyond_model_time(self): 7944 """test_field_boundary(self): 7945 7946 Test that field_boundary can work when model time 7947 exceeds available data whilst adjusting mean_stage. 7948 7949 """ 7950 7951 # Don't do warnings in unit test 7952 import warnings 7953 warnings.simplefilter('ignore') 7954 7955 from anuga.shallow_water import Domain 7956 from anuga.shallow_water import Reflective_boundary 7957 from anuga.shallow_water import Dirichlet_boundary 7958 from anuga.shallow_water import File_boundary 7959 from anuga.pmesh.mesh_interface import create_mesh_from_regions 7960 7961 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0], 7962 [6.02,97.02],[6.00,97.02]] 7963 tide = 0.37 7964 time_step_count = 5 7965 time_step = 2 7966 lat_long_points = bounding_polygon[0:3] 7967 n=len(lat_long_points) 7968 first_tstep=ones(n,Int) 7969 last_tstep=(time_step_count)*ones(n,Int) 7970 7971 h = 20 7972 w = 2 7973 u = 10 7974 v = -10 7975 gauge_depth=h*ones(n,Float) 7976 ha=w*ones((n,time_step_count),Float) 7977 ua=u*ones((n,time_step_count),Float) 7978 va=v*ones((n,time_step_count),Float) 7979 base_name, files = self.write_mux2(lat_long_points, 7980 time_step_count, time_step, 7981 first_tstep, last_tstep, 7982 depth=gauge_depth, 7983 ha=ha, 7984 ua=ua, 7985 va=va) 7986 7987 sts_file=base_name 7988 urs2sts(base_name, 7989 sts_file, 7990 mean_stage=0.0, # Deliberately let Field_boundary do the adjustment 7991 verbose=False) 7992 self.delete_mux(files) 7993 7994 #print 'start create mesh from regions' 7995 for i in range(len(bounding_polygon)): 7996 zone,\ 7997 bounding_polygon[i][0],\ 7998 bounding_polygon[i][1]=redfearn(bounding_polygon[i][0], 7999 bounding_polygon[i][1]) 8000 8001 extent_res=1000000 8002 meshname = 'urs_test_mesh' + '.tsh' 8003 interior_regions=None 8004 boundary_tags={'ocean': [0,1], 'otherocean': [2,3,4]} 8005 create_mesh_from_regions(bounding_polygon, 8006 boundary_tags=boundary_tags, 8007 maximum_triangle_area=extent_res, 8008 filename=meshname, 8009 interior_regions=interior_regions, 8010 verbose=False) 8011 8012 domain_fbound = Domain(meshname) 8013 domain_fbound.set_quantity('stage', tide) 8014 8015 Br = Reflective_boundary(domain_fbound) 8016 Bd = Dirichlet_boundary([w+tide, u*(w+h), v*(w+h)]) 8017 Bdefault = Dirichlet_boundary([w, u*(w+h), v*(w+h)]) 8018 8019 Bf = Field_boundary(sts_file+'.sts', 8020 domain_fbound, 8021 mean_stage=tide, # Field boundary to adjust for tide 8022 boundary_polygon=bounding_polygon, 8023 default_boundary=Bdefault) # Condition to be used 8024 # if model time exceeds 8025 # available data 8026 8027 domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br}) 8028 8029 # Check boundary object evaluates as it should 8030 for i, ((vol_id, edge_id), B) in enumerate(domain_fbound.boundary_objects): 8031 if B is Bf: 8032 8033 qf = B.evaluate(vol_id, edge_id) # Field boundary 8034 qd = Bd.evaluate(vol_id, edge_id) # Dirichlet boundary 8035 8036 msg = 'Got %s, should have been %s' %(qf, qd) 8037 assert allclose(qf, qd), msg 8038 8039 # Evolve 8040 data_finaltime = time_step*(time_step_count-1) 8041 finaltime = data_finaltime + 10 # Let model time exceed available data 8042 yieldstep = time_step 8043 temp_fbound=zeros(int(finaltime/yieldstep)+1, Float) 8044 8045 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, 8046 finaltime=finaltime, 8047 skip_initial_step=False)): 8048 8049 D = domain_fbound 8050 temp_fbound[i]=D.quantities['stage'].centroid_values[2] 8051 8052 # Check that file boundary object has populated 8053 # boundary array correctly 8054 # FIXME (Ole): Do this for the other tests too! 8055 for j, val in enumerate(D.get_quantity('stage').boundary_values): 8056 8057 (vol_id, edge_id), B = D.boundary_objects[j] 8058 if isinstance(B, Field_boundary): 8059 msg = 'Got %f should have been %f' %(val, w+tide) 8060 assert allclose(val, w + tide), msg 8061 7939 8062 7940 8063 def test_file_boundary_stsII(self): -
anuga_work/development/boxingday08/project.py
r5573 r5672 99 99 patong_bay_polygon = read_polygon(dir+sep+'patong_bay_polygon.csv') 100 100 101 tide=0. 45101 tide=0.15 102 102 103 103 ###################################### -
anuga_work/development/boxingday08/run_boxingday_polyline.py
r5601 r5672 54 54 timestamp = strftime('%Y%m%d_%H%M%S',localtime()) 55 55 basename = scenario[:4] + '_polyline' 56 tide = project.tide 56 57 57 58 … … 130 131 print domain.statistics() 131 132 132 domain.set_name(basename+timestamp )133 domain.set_name(basename+timestamp+'_'+str(tide)) 133 134 #domain.set_name(basename) 134 135 domain.set_datadir(scenario) … … 146 147 #------------------------------------------------------------------------------ 147 148 148 tide = project.tide149 149 domain.set_quantity('stage', tide) 150 150 domain.set_quantity('friction', 0.01)
Note: See TracChangeset
for help on using the changeset viewer.