source: inundation/ga/storm_surge/parallel/run_parallel_advection.py @ 1520

Last change on this file since 1520 was 1520, checked in by steve, 19 years ago
File size: 1.9 KB
Line 
1import sys
2from os import sep
3sys.path.append('..'+sep+'pyvolution')
4
5#========================================================================
6from config import g, epsilon
7from Numeric import allclose, array, zeros, ones, Float
8from parallel_advection import *
9from Numeric import array
10from parallel_meshes import *
11
12import pypar
13
14numprocs = pypar.size()
15myid = pypar.rank()
16processor_name = pypar.Get_processor_name()
17
18
19
20#N = 50
21N = 50
22M = 50
23
24points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
25    parallel_rectangular(N, M, len1_g=1.0)
26
27#Create advection domain with direction (1,-1)
28domain = Parallel_Domain(points, vertices, boundary,
29                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
30
31# Initial condition is zero by default
32
33#turn on the visualisation
34rect = [0.0, 0.0, 1.0, 1.0]
35domain.initialise_visualiser(rect=rect)
36
37#Boundaries
38T = Transmissive_boundary(domain)
39D = Dirichlet_boundary(array([1.0]))
40
41domain.default_order = 2
42
43
44domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} )
45domain.check_integrity()
46
47class Set_Stage:
48    """Set an initial condition with constant water height, for x<x0
49    """
50
51    def __init__(self, x0=0.25, x1=0.5, h=1.0):
52        self.x0 = x0
53        self.x1 = x1
54        self.= h
55
56    def __call__(self, x, y):
57        return self.h*((x>self.x0)&(x<self.x1))
58
59domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
60
61if myid == 0:
62    import time
63    t0 = time.time()
64
65#Check that the boundary value gets propagated to all elements
66for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
67    if myid == 0:
68        domain.write_time()
69
70if myid == 0:
71    print 'That took %.2f seconds' %(time.time()-t0)
72    print 'Communication time %.2f seconds'%domain.communication_time
73    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.