Changeset 2601
- Timestamp:
- Mar 27, 2006, 1:54:32 PM (17 years ago)
- Location:
- inundation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/examples/beach.py
r2582 r2601 28 28 name = 'beach' 29 29 print 'Creating domain from %s.tsh' %name 30 domain = pmesh_to_domain_instance(name + '.tsh', Domain) 30 #domain = pmesh_to_domain_instance(name + '.tsh', Domain) 31 domain = Domain(mesh_file= name + '.tsh') 31 32 32 33 domain.store = True -
inundation/pyvolution/domain.py
r2569 r2601 14 14 from generic_boundary_conditions import Time_boundary 15 15 from generic_boundary_conditions import Transmissive_boundary 16 from pmesh2domain import _pmesh_to_domain 16 17 17 18 import types … … 19 20 class Domain(Mesh): 20 21 21 def __init__(self, coordinates, vertices, boundary = None, 22 conserved_quantities = None, other_quantities = None, 23 tagged_elements = None, geo_reference = None, 24 use_inscribed_circle=False): 22 def __init__(self, coordinates=None, vertices=None, 23 boundary=None, 24 conserved_quantities=None, other_quantities=None, 25 tagged_elements=None, geo_reference=None, 26 use_inscribed_circle=False, 27 mesh_file=None): 28 29 if mesh_file is not None: 30 coordinates, vertices, boundary, vertex_quantity_dict \ 31 ,tagged_elements, geo_reference = \ 32 _pmesh_to_domain(file_name=mesh_file) 33 # FIXME(DSG-DSG) have to do something with vertex_quantity_dict 25 34 26 35 Mesh.__init__(self, coordinates, vertices, boundary, … … 100 109 self.already_computed_flux = zeros((N, 3), Int) 101 110 111 if mesh_file is not None: 112 # If the mesh file passed any quantity values 113 # , initialise with these values. 114 self.set_quantity_vertices_dict(vertex_quantity_dict) 115 116 102 117 103 118 def set_default_order(self, n): -
inundation/pyvolution/shallow_water.py
r2598 r2601 69 69 class Domain(Generic_Domain): 70 70 71 def __init__(self, coordinates , vertices, boundary = None,71 def __init__(self, coordinates=None, vertices=None, boundary = None, 72 72 tagged_elements = None, geo_reference = None, 73 use_inscribed_circle=False): 73 use_inscribed_circle=False, 74 mesh_file=None): 74 75 75 76 conserved_quantities = ['stage', 'xmomentum', 'ymomentum'] … … 77 78 Generic_Domain.__init__(self, coordinates, vertices, boundary, 78 79 conserved_quantities, other_quantities, 79 tagged_elements, geo_reference, use_inscribed_circle )80 tagged_elements, geo_reference, use_inscribed_circle, mesh_file) 80 81 81 82 from config import minimum_allowed_height, maximum_allowed_speed, g … … 106 107 self.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] 107 108 108 109 109 110 def set_quantities_to_be_stored(self, q): 110 111 """Specify which quantities will be stored in the sww file. -
inundation/pyvolution/test_shallow_water.py
r2566 r2601 3278 3278 3279 3279 3280 def test_pmesh2Domain(self): 3281 import os 3282 import tempfile 3283 3284 fileName = tempfile.mktemp(".tsh") 3285 file = open(fileName,"w") 3286 file.write("4 3 # <vertex #> <x> <y> [attributes]\n \ 3287 0 0.0 0.0 0.0 0.0 0.01 \n \ 3288 1 1.0 0.0 10.0 10.0 0.02 \n \ 3289 2 0.0 1.0 0.0 10.0 0.03 \n \ 3290 3 0.5 0.25 8.0 12.0 0.04 \n \ 3291 # Vert att title \n \ 3292 elevation \n \ 3293 stage \n \ 3294 friction \n \ 3295 2 # <triangle #> [<vertex #>] [<neigbouring triangle #>] \n\ 3296 0 0 3 2 -1 -1 1 dsg\n\ 3297 1 0 1 3 -1 0 -1 ole nielsen\n\ 3298 4 # <segment #> <vertex #> <vertex #> [boundary tag] \n\ 3299 0 1 0 2 \n\ 3300 1 0 2 3 \n\ 3301 2 2 3 \n\ 3302 3 3 1 1 \n\ 3303 3 0 # <x> <y> [attributes] ...Mesh Vertices... \n \ 3304 0 216.0 -86.0 \n \ 3305 1 160.0 -167.0 \n \ 3306 2 114.0 -91.0 \n \ 3307 3 # <vertex #> <vertex #> [boundary tag] ...Mesh Segments... \n \ 3308 0 0 1 0 \n \ 3309 1 1 2 0 \n \ 3310 2 2 0 0 \n \ 3311 0 # <x> <y> ...Mesh Holes... \n \ 3312 0 # <x> <y> <attribute>...Mesh Regions... \n \ 3313 0 # <x> <y> <attribute>...Mesh Regions, area... \n\ 3314 #Geo reference \n \ 3315 56 \n \ 3316 140 \n \ 3317 120 \n") 3318 file.close() 3319 3320 tags = {} 3321 b1 = Dirichlet_boundary(conserved_quantities = array([0.0])) 3322 b2 = Dirichlet_boundary(conserved_quantities = array([1.0])) 3323 b3 = Dirichlet_boundary(conserved_quantities = array([2.0])) 3324 tags["1"] = b1 3325 tags["2"] = b2 3326 tags["3"] = b3 3327 3328 #from pmesh2domain import pmesh_to_domain_instance 3329 #domain = pmesh_to_domain_instance(fileName, Domain) 3330 3331 domain = Domain(mesh_file=fileName) 3332 3333 os.remove(fileName) 3334 #print "domain.tagged_elements", domain.tagged_elements 3335 ## check the quantities 3336 #print domain.quantities['elevation'].vertex_values 3337 answer = [[0., 8., 0.], 3338 [0., 10., 8.]] 3339 assert allclose(domain.quantities['elevation'].vertex_values, 3340 answer) 3341 3342 #print domain.quantities['stage'].vertex_values 3343 answer = [[0., 12., 10.], 3344 [0., 10., 12.]] 3345 assert allclose(domain.quantities['stage'].vertex_values, 3346 answer) 3347 3348 #print domain.quantities['friction'].vertex_values 3349 answer = [[0.01, 0.04, 0.03], 3350 [0.01, 0.02, 0.04]] 3351 assert allclose(domain.quantities['friction'].vertex_values, 3352 answer) 3353 3354 #print domain.quantities['friction'].vertex_values 3355 assert allclose(domain.tagged_elements['dsg'][0],0) 3356 assert allclose(domain.tagged_elements['ole nielsen'][0],1) 3357 3358 self.failUnless( domain.boundary[(1, 0)] == '1', 3359 "test_tags_to_boundaries failed. Single boundary wasn't added.") 3360 self.failUnless( domain.boundary[(1, 2)] == '2', 3361 "test_tags_to_boundaries failed. Single boundary wasn't added.") 3362 self.failUnless( domain.boundary[(0, 1)] == '3', 3363 "test_tags_to_boundaries failed. Single boundary wasn't added.") 3364 self.failUnless( domain.boundary[(0, 0)] == 'exterior', 3365 "test_tags_to_boundaries failed. Single boundary wasn't added.") 3366 #print "domain.boundary",domain.boundary 3367 self.failUnless( len(domain.boundary) == 4, 3368 "test_pmesh2Domain Too many boundaries") 3369 #FIXME change to use get_xllcorner 3370 #print "d.geo_reference.xllcorner",domain.geo_reference.xllcorner 3371 self.failUnless(domain.geo_reference.xllcorner == 140.0, 3372 "bad geo_referece") 3373 #************ 3374 3280 3375 #------------------------------------------------------------- 3281 3376 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.