source: inundation/parallel/run_parallel_advection.py @ 1855

Last change on this file since 1855 was 1575, checked in by steve, 19 years ago

In the process of copying stage from full domain to sub domains

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