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

Last change on this file since 1472 was 1471, checked in by steve, 19 years ago

Can now change base colour for different quantities, but need a better method!

File size: 1.8 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 = parallel_rectangular(N, M, len1=1.0)
25
26#Create advection domain with direction (1,-1)
27domain = Parallel_Domain(points, vertices, boundary,
28                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
29
30# Initial condition is zero by default
31
32#turn on the visualisation
33domain.initialise_visualiser()
34
35#Boundaries
36T = Transmissive_boundary(domain)
37D = Dirichlet_boundary(array([1.0]))
38
39domain.default_order = 2
40
41
42domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} )
43domain.check_integrity()
44
45class Set_Stage:
46    """Set an initial condition with constant water height, for x<x0
47    """
48
49    def __init__(self, x0=0.25, x1=0.5, h=1.0):
50        self.x0 = x0
51        self.x1 = x1
52        self.= h
53
54    def __call__(self, x, y):
55        return self.h*((x>self.x0)&(x<self.x1))
56
57if myid == 0:
58    domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
59    import time
60    t0 = time.time()
61
62#Check that the boundary value gets propagated to all elements
63for t in domain.evolve(yieldstep = 0.5, finaltime = 3.0):
64    if myid == 0:
65        domain.write_time()
66
67if myid == 0:
68    print 'That took %.2f seconds' %(time.time()-t0)
69    print 'Communication time %.2f seconds'%domain.communication_time
70    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.