source: inundation/parallel/run_parallel_advection.py @ 2897

Last change on this file since 2897 was 2769, checked in by linda, 19 years ago

Removed the old pmesh_divide routines, the mesh is now divided using metis. Commented run_parallel_advection, run_parallel_merimbula_metis and run_parallel_sw_merimbula_metis. Add run_parallel_merimbula_tes and run_parallel_sw_merimbula_test as files that can be used to test new changes etc

File size: 2.7 KB
Line 
1#!/usr/bin/env python
2###
3#########################################################
4#
5#  Main file for parallel mesh testing. Runs an advection
6# flow simulation using a rectangular mesh
7#
8#
9#  Authors: Steve Roberts June 2005
10#  Modified by Linda Stals April 2006
11#
12#
13#########################################################
14
15
16import sys
17from os import sep
18sys.path.append('..'+sep+'pyvolution')
19
20# Parallel communication routines
21
22import pypar
23
24#  Mesh partition routines
25
26from parallel_meshes import parallel_rectangle
27
28# Parallel Domain
29 
30from parallel_advection import Parallel_Domain
31from parallel_advection import Transmissive_boundary
32
33############################
34# Set the initial conditions
35############################
36class Set_Stage:
37    """Set an initial condition with constant water height, for x<x0
38    """
39
40    def __init__(self, x0=0.25, x1=0.5, h=1.0):
41        self.x0 = x0
42        self.x1 = x1
43        self.= h
44
45    def __call__(self, x, y):
46        return self.h*((x>self.x0)&(x<self.x1))
47
48###############################
49# Read in processor information
50###############################
51
52numprocs = pypar.size()
53myid = pypar.rank()
54processor_name = pypar.Get_processor_name()
55
56N = 20
57M = 20
58
59#######################
60# Partition the domain
61#######################
62
63# Build a unit mesh, subdivide it over numproces processors with each
64# submesh containing M*N nodes
65
66points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
67    parallel_rectangle(N, M, len1_g=1.0)
68
69###########################################
70# Start the computations on each subpartion
71###########################################
72
73# Create advection domain with direction (1,-1)
74# Initial condition is zero by default
75
76domain = Parallel_Domain(points, vertices, boundary,
77                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
78
79# Turn on the visualisation
80
81rect = [0.0, 0.0, 1.0, 1.0]
82domain.initialise_visualiser(rect=rect)
83
84# Boundaries
85
86T = Transmissive_boundary(domain)
87domain.default_order = 2
88domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, 'ghost': None} )
89
90# Ensure that the domain definitions make sense
91
92domain.check_integrity()
93
94# Set the inititial conditions
95
96domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
97
98# Let processor 0 output some timing information
99
100if myid == 0:
101    import time
102    t0 = time.time()
103
104# Start the evolve computions
105
106for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
107    if myid == 0:
108        domain.write_time()
109
110# Output some computation statistics
111
112if myid == 0:
113    print 'That took %.2f seconds' %(time.time()-t0)
114    print 'Communication time %.2f seconds'%domain.communication_time
115    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.