source: anuga_work/development/river2d_integration/Create_Domain_From_Pts_Vert.py @ 7244

Last change on this file since 7244 was 6085, checked in by ole, 16 years ago

Got River2D runfile reader and associated ANUGA domain to work

File size: 3.5 KB
Line 
1""" This Script attempts to create an ANUGA Domain
2
3from two files containing Points & Vertices of a triangular mesh
4
5
6"""
7
8#------------------------------------------------------------------------------
9# Import necessary modules
10#------------------------------------------------------------------------------
11print ' ABOUT to Start Simulation:- Importing Modules'
12
13# Standard modules
14import os
15import time
16import sys
17
18# Related major packages
19from anuga.shallow_water import Domain
20from anuga.shallow_water import Reflective_boundary
21from anuga.shallow_water import Dirichlet_boundary
22from anuga.shallow_water import Time_boundary
23from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
24from anuga.abstract_2d_finite_volumes.util import file_function
25from anuga.pmesh.mesh_interface import create_mesh_from_regions
26from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
27from anuga.shallow_water.data_manager import dem2pts
28from anuga.geospatial_data.geospatial_data import Geospatial_data
29from anuga.shallow_water.shallow_water_domain import Inflow
30#import inflow_test
31from anuga.utilities.polygon import read_polygon
32from 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 ???
35import Numeric
36
37#------------------------------------------------------------------------------
38#    CREATE DOMAIN from Mesh created ELSEWHERE
39#------------------------------------------------------------------------------
40
41
42
43
44points=[]
45fid = open('ANUGA_MeshPts.csv')
46for 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])
52fid.close()
53
54vertices = []
55fid = open('ANUGA_MeshVertices.csv')   
56for 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])
63fid.close()
64
65boundary=None  # Deal with this later
66
67#print points
68#print vertices
69domain = Domain(points, vertices, boundary) # Create domain
70domain.check_integrity()
71
72#------------------------------------------------------------------------------
73#         ASSIGN Elevations to the MESH
74#------------------------------------------------------------------------------
75
76domain.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
92Br = Reflective_boundary(domain)
93domain.set_boundary({'exterior': Br})  # Default tag
94
95#------------------------------------------------------------------------------
96# Evolve system through time
97#------------------------------------------------------------------------------
98
99import time
100t0 = time.time()
101
102for t in domain.evolve(yieldstep = 10, finaltime = 100): 
103    domain.write_time()
104    domain.write_boundary_statistics(quantities='stage')     
105
106print 'That took', time.time() - t0, 'seconds'                 
107   
Note: See TracBrowser for help on using the repository browser.