1 | """ This Script attempts to create an ANUGA Domain |
---|
2 | |
---|
3 | from two files containing Points & Vertices of a triangular mesh |
---|
4 | |
---|
5 | |
---|
6 | """ |
---|
7 | |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | # Import necessary modules |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | print ' ABOUT to Start Simulation:- Importing Modules' |
---|
12 | |
---|
13 | # Standard modules |
---|
14 | import os |
---|
15 | import time |
---|
16 | import sys |
---|
17 | |
---|
18 | # Related major packages |
---|
19 | from anuga.shallow_water import Domain |
---|
20 | from anuga.shallow_water import Reflective_boundary |
---|
21 | from anuga.shallow_water import Dirichlet_boundary |
---|
22 | from anuga.shallow_water import Time_boundary |
---|
23 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
24 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
25 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
26 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf |
---|
27 | from anuga.shallow_water.data_manager import dem2pts |
---|
28 | from anuga.geospatial_data.geospatial_data import Geospatial_data |
---|
29 | from anuga.shallow_water.shallow_water_domain import Inflow |
---|
30 | #import inflow_test |
---|
31 | from anuga.utilities.polygon import read_polygon |
---|
32 | from anuga.shallow_water.shallow_water_domain import Rainfall |
---|
33 | |
---|
34 | # OLE How do I get the Domain Points to create a LIST of Points from the File ??? |
---|
35 | import Numeric |
---|
36 | |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | # CREATE DOMAIN from Mesh created ELSEWHERE |
---|
39 | #------------------------------------------------------------------------------ |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | points=[] |
---|
45 | fid = open('ANUGA_MeshPts.csv') |
---|
46 | for lines in fid.readlines(): |
---|
47 | if lines.strip() == '': continue |
---|
48 | fields = lines.split(',') |
---|
49 | x = float(fields[0]) |
---|
50 | y = float(fields[1]) |
---|
51 | points.append([x,y]) |
---|
52 | fid.close() |
---|
53 | |
---|
54 | vertices = [] |
---|
55 | fid = open('ANUGA_MeshVertices.csv') |
---|
56 | for lines in fid.readlines(): |
---|
57 | if lines.strip() == '': continue |
---|
58 | fields = lines.split(',') |
---|
59 | i = int(fields[0]) |
---|
60 | j = int(fields[1]) |
---|
61 | k = int(fields[2]) |
---|
62 | vertices.append([i,j,k]) |
---|
63 | fid.close() |
---|
64 | |
---|
65 | boundary=None # Deal with this later |
---|
66 | |
---|
67 | #print points |
---|
68 | #print vertices |
---|
69 | domain = Domain(points, vertices, boundary) # Create domain |
---|
70 | domain.check_integrity() |
---|
71 | |
---|
72 | #------------------------------------------------------------------------------ |
---|
73 | # ASSIGN Elevations to the MESH |
---|
74 | #------------------------------------------------------------------------------ |
---|
75 | |
---|
76 | domain.set_quantity('stage', 1.0) |
---|
77 | |
---|
78 | |
---|
79 | #------------------------------------------------------------------------------ |
---|
80 | # ASSIGN MANNING Roughness to the MESH |
---|
81 | #------------------------------------------------------------------------------ |
---|
82 | |
---|
83 | #------------------------------------------------------------------------------ |
---|
84 | # ASSIGN FORCING FUNCTIONS As required |
---|
85 | #------------------------------------------------------------------------------ |
---|
86 | |
---|
87 | |
---|
88 | #------------------------------------------------------------------------------ |
---|
89 | # BOUNDARY CONDITIONS |
---|
90 | #------------------------------------------------------------------------------ |
---|
91 | |
---|
92 | Br = Reflective_boundary(domain) |
---|
93 | domain.set_boundary({'exterior': Br}) # Default tag |
---|
94 | |
---|
95 | #------------------------------------------------------------------------------ |
---|
96 | # Evolve system through time |
---|
97 | #------------------------------------------------------------------------------ |
---|
98 | |
---|
99 | import time |
---|
100 | t0 = time.time() |
---|
101 | |
---|
102 | for t in domain.evolve(yieldstep = 10, finaltime = 100): |
---|
103 | domain.write_time() |
---|
104 | domain.write_boundary_statistics(quantities='stage') |
---|
105 | |
---|
106 | print 'That took', time.time() - t0, 'seconds' |
---|
107 | |
---|