[6157] | 1 | |
---|
| 2 | from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary |
---|
| 3 | from eqf_v2 import earthquake_tsunami |
---|
| 4 | |
---|
| 5 | res = 10000000. |
---|
| 6 | intres = 1000000. |
---|
| 7 | boundingpoly=[[-100000,-80000],[-100000,80000],[100000,80000],[100000,-80000]] |
---|
| 8 | poly = [[-40000,-20000],[40000,-20000],[40000,30000],[-40000,30000]] |
---|
| 9 | interior_regions = [[poly,intres]] |
---|
| 10 | |
---|
| 11 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
| 12 | from caching import cache |
---|
| 13 | meshname = 'another_test'+'.msh' |
---|
| 14 | |
---|
| 15 | _ = cache(create_mesh_from_regions, |
---|
| 16 | boundingpoly, |
---|
| 17 | {'boundary_tags': {'e0': [0], 'e1': [1], 'e2': [2], 'e3': [3]}, |
---|
| 18 | 'maximum_triangle_area': res, |
---|
| 19 | 'filename': meshname, |
---|
| 20 | 'interior_regions': interior_regions}, |
---|
| 21 | verbose = True) |
---|
| 22 | |
---|
| 23 | domain = Domain(meshname, use_cache = True, verbose = True) |
---|
| 24 | |
---|
| 25 | basename = 'test' |
---|
| 26 | domain.set_name(basename) |
---|
| 27 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
| 28 | domain.set_minimum_storable_height(0.01) |
---|
| 29 | |
---|
| 30 | tsunami_source = earthquake_tsunami(length=25.0, |
---|
| 31 | width=5.0, |
---|
| 32 | strike=0., |
---|
| 33 | depth=3.50, |
---|
| 34 | # depth=3500.0, |
---|
| 35 | dip=15.0, |
---|
| 36 | slip=1., |
---|
| 37 | x0=0.0, |
---|
| 38 | y0=0.0, |
---|
| 39 | domain=domain, |
---|
| 40 | verbose=True) |
---|
| 41 | |
---|
| 42 | stage0 = 1.0 |
---|
| 43 | |
---|
| 44 | #sets tsunami_source to the domain |
---|
| 45 | domain.set_quantity('stage', tsunami_source) |
---|
| 46 | z2 = domain.get_quantity('stage') |
---|
| 47 | int2 = z2.get_integral()/400000.0 |
---|
| 48 | #print 'integral before and after', int1, int2 |
---|
| 49 | |
---|
| 50 | print 'len(z2)',len(z2) |
---|
| 51 | print 'dir(z2)',dir(z2) |
---|
| 52 | |
---|
| 53 | domain.set_quantity('elevation', -10.0, alpha = 0.1) |
---|
| 54 | |
---|
| 55 | Br = Reflective_boundary(domain) |
---|
| 56 | Bd = Dirichlet_boundary([0,0,0]) |
---|
| 57 | domain.set_boundary( {'e0': Br, 'e1': Br, 'e2': Br, 'e3': Br} ) |
---|
| 58 | |
---|
| 59 | import time |
---|
| 60 | |
---|
| 61 | t0 = time.time() |
---|
| 62 | |
---|
| 63 | for t in domain.evolve(yieldstep = 1, finaltime = 1): |
---|
| 64 | domain.write_time() |
---|
| 65 | domain.write_boundary_statistics(tags = 'e2') |
---|
| 66 | |
---|
| 67 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
[6304] | 68 | import numpy as num |
---|
[6157] | 69 | from pylab import plot, ion, hold,savefig |
---|
| 70 | |
---|
| 71 | ''' |
---|
| 72 | #points=array([[0,0],[0,10]]) |
---|
| 73 | max = 100 |
---|
| 74 | skip = 1000 |
---|
| 75 | |
---|
| 76 | y = 10000 |
---|
[6304] | 77 | points=num.array([[0]*2]*max) |
---|
[6157] | 78 | print points |
---|
| 79 | half_max_skip=(max*skip)/2 |
---|
| 80 | for i in range(max): |
---|
| 81 | print i*skip-half_max_skip |
---|
| 82 | points[i]=[i*skip-half_max_skip, y] |
---|
| 83 | # print i |
---|
| 84 | ''' |
---|
| 85 | interval=500 |
---|
| 86 | profile_lenght= 20000 |
---|
| 87 | number_points = profile_lenght/interval |
---|
| 88 | y = 10000 |
---|
[6304] | 89 | points=num.array([[0]*2]*number_points) |
---|
[6157] | 90 | print points |
---|
| 91 | half_profile=profile_lenght/2 |
---|
| 92 | for i in range(number_points): |
---|
| 93 | print i*interval-half_profile |
---|
| 94 | points[i]=[i*interval-half_profile, y] |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | print "points[0,:]",points |
---|
| 98 | ion() |
---|
| 99 | print 'hello' |
---|
| 100 | |
---|
| 101 | F = file_function('test.sww', quantities = 'stage', interpolation_points=points,verbose = True,use_cache=True) |
---|
| 102 | |
---|
| 103 | print F.statistics() |
---|
| 104 | t=1 |
---|
| 105 | x = 0.0 |
---|
| 106 | y = 0.0 |
---|
| 107 | #print F(t=1, x=5000, y=5000) |
---|
| 108 | profile=[] |
---|
| 109 | |
---|
| 110 | for i in range(number_points): |
---|
| 111 | profile.append(F(0,point_id=i)) |
---|
| 112 | print i, F(0,point_id=i) |
---|
| 113 | print'profile', profile#,points[:,1] |
---|
| 114 | |
---|
| 115 | plot(points[:,0],profile) |
---|
| 116 | savefig("profile",dpi=300) |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|