source: inundation/parallel/run_parallel_advection.py @ 2131

Last change on this file since 2131 was 2090, checked in by linda, 19 years ago

Removed pypar test files and commented pmesh_divide

File size: 1.9 KB
Line 
1#!/usr/bin/env python
2
3import sys
4from os import sep
5sys.path.append('..'+sep+'pyvolution')
6
7#========================================================================
8from config import g, epsilon
9from Numeric import allclose, array, zeros, ones, Float
10from parallel_meshes import parallel_rectangle
11
12from advection import Domain
13from parallel_advection import Parallel_Domain
14from parallel_advection import Transmissive_boundary, Dirichlet_boundary
15
16import pypar
17
18numprocs = pypar.size()
19myid = pypar.rank()
20processor_name = pypar.Get_processor_name()
21
22
23
24#N = 50
25N = 20
26M = 20
27
28points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
29    parallel_rectangle(N, M, len1_g=1.0)
30
31#Create advection domain with direction (1,-1)
32domain = Parallel_Domain(points, vertices, boundary,
33                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
34
35# Initial condition is zero by default
36
37#turn on the visualisation
38rect = [0.0, 0.0, 1.0, 1.0]
39domain.initialise_visualiser(rect=rect)
40
41#Boundaries
42T = Transmissive_boundary(domain)
43D = Dirichlet_boundary(array([1.0]))
44
45domain.default_order = 2
46
47
48domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} )
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.