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

Last change on this file since 1454 was 1436, checked in by steve, 20 years ago
File size: 1.7 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 = 25
22M = 25
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#domain.initialise_visualiser()
33
34#Boundaries
35T = Transmissive_boundary(domain)
36D = Dirichlet_boundary(array([1.0]))
37
38domain.default_order = 2
39
40
41domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} )
42domain.check_integrity()
43
44class Set_Stage:
45    """Set an initial condition with constant water height, for x<x0
46    """
47
48    def __init__(self, x0=0.25, x1=0.5, h=1.0):
49        self.x0 = x0
50        self.x1 = x1
51        self.= h
52
53    def __call__(self, x, y):
54        return self.h*((x>self.x0)&(x<self.x1))
55
56if myid == 0:
57    domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
58    import time
59    t0 = time.time()
60
61#Check that the boundary value gets propagated to all elements
62for t in domain.evolve(yieldstep = 0.1, finaltime = 2.0):
63    if myid == 0:
64        domain.write_time()
65
66if myid == 0:
67    print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.