source: trunk/anuga_work/shallow_water_balanced_steve/run_sw_merimbula.py @ 8288

Last change on this file since 8288 was 8288, checked in by steve, 12 years ago

Added in new test function for balanced code

File size: 3.4 KB
Line 
1
2"""Run parallel shallow water domain.
3
4   run using command like:
5
6   python run_sw_merimbula.py
7
8   where m is the number of processors to be used.
9   
10   Will produce sww files with names domain_Pn_m.sww where m is number of processors and
11   n in [0, m-1] refers to specific processor that owned this part of the partitioned mesh.
12"""
13
14#------------------------------------------------------------------------------
15# Import necessary modules
16#------------------------------------------------------------------------------
17
18import os
19import sys
20import time
21import numpy as num
22
23#------------------------
24# ANUGA Modules
25#------------------------
26       
27from swb_domain import Domain
28from anuga import Reflective_boundary
29from anuga import Dirichlet_boundary
30from anuga import Time_boundary
31#from swb_domain import Transmissive_boundary
32
33from anuga import rectangular_cross
34from anuga import create_domain_from_file
35
36
37
38#--------------------------------------------------------------------------
39# Setup parameters
40#--------------------------------------------------------------------------
41
42mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0
43#mesh_filename = "merimbula_43200.tsh"   ; x0 = 756000.0 ; x1 = 756500.0
44#mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5
45#mesh_filename = "test-20.tsh" ; x0 = 250.0 ; x1 = 350.0
46yieldstep = 20
47finaltime = 200
48verbose = True
49
50#--------------------------------------------------------------------------
51# Setup procedures
52#--------------------------------------------------------------------------
53class Set_Stage:
54    """Set an initial condition with constant water height, for x0<x<x1
55    """
56
57    def __init__(self, x0=0.25, x1=0.5, h=1.0):
58        self.x0 = x0
59        self.x1 = x1
60        self.= h
61
62    def __call__(self, x, y):
63        return self.h*((x>self.x0)&(x<self.x1))
64
65
66class Set_Elevation:
67    """Set an elevation
68    """
69
70    def __init__(self, h=1.0):
71        self.x0 = x0
72        self.x1 = x1
73        self.= h
74
75    def __call__(self, x, y):
76        return x/self.h
77   
78
79#--------------------------------------------------------------------------
80# Setup Domain
81#--------------------------------------------------------------------------
82domain = create_domain_from_file(mesh_filename, DomainClass=Domain)
83
84domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))
85
86
87#--------------------------------------------------------------------------
88# Setup Domain
89#--------------------------------------------------------------------------
90domain.set_default_order(2)
91domain.set_timestepping_method('rk2')
92#domain.set_CFL(0.7)
93#domain.set_beta(1.5)
94domain.set_name('merimbula')
95
96
97
98#------------------------------------------------------------------------------
99# Setup boundary conditions
100# This must currently happen *after* domain has been distributed
101#------------------------------------------------------------------------------
102Br = Reflective_boundary(domain)      # Solid reflective wall
103
104domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br})
105
106#------------------------------------------------------------------------------
107# Evolution
108#------------------------------------------------------------------------------
109if verbose: print 'EVOLVE'
110
111t0 = time.time()
112
113for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
114    domain.write_time()
115
116print 'That took %.2f seconds' %(time.time()-t0)
117
118
119
Note: See TracBrowser for help on using the repository browser.