source: inundation/parallel/run_parallel_advection.py @ 2625

Last change on this file since 2625 was 2625, checked in by linda, 18 years ago

Added ghost boundary layers

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