source: anuga_core/source/anuga_parallel/run_parallel_merimbula_test.py @ 3579

Last change on this file since 3579 was 3579, checked in by ole, 18 years ago

Removed all references to pyvolution in parallel code

File size: 4.4 KB
Line 
1#!/usr/bin/env python
2#########################################################
3#
4#  Main file for parallel mesh testing. Runs an advection
5# flow simulation using a rectangular mesh
6#
7#  This is a modification of the run_parallel_advection.py
8# file
9#
10#
11# *) The (new) files that have been added to manage the
12# grid partitioning are
13#    +) pmesh_divide_metis.py: subdivide a pmesh
14#    +) build_submesh.py: build the submeshes on the host
15# processor.
16#    +) build_local.py: build the GA mesh datastructure
17# on each processor.
18#    +) build_commun.py: handle the communication between
19# the host and processors
20#
21#  Authors: Linda Stals, Steve Roberts and Matthew Hardy,
22# June 2005
23#
24#
25#
26#########################################################
27
28import pypar    # The Python-MPI interface
29import time
30
31# Numeric arrays
32from Numeric import array, zeros, Float
33
34from print_stats import print_test_stats, build_full_flag
35
36from anuga.abstract_2d_finite_volumes.pmesh2domain\
37     import pmesh_to_domain_instance
38from anuga.advection.advection import Domain as Advection_Domain
39from parallel_advection import Parallel_Domain
40
41from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
42     import Transmissive_boundary
43
44# mesh partition routines
45
46from pmesh_divide  import pmesh_divide_metis
47from build_submesh import build_submesh
48from build_local   import build_local_mesh
49from build_commun  import send_submesh, rec_submesh, extract_hostmesh
50
51
52class Set_Stage:
53    """Set an initial condition with constant water height, for x<x0
54    """
55
56    def __init__(self, x0=0.25, x1=0.5, h=1.0):
57        self.x0 = x0
58        self.x1 = x1
59        self.= h
60
61    def __call__(self, x, y):
62        return self.h*((x>self.x0)&(x<self.x1))
63
64# read in the processor information
65
66numprocs = pypar.size()
67myid = pypar.rank()
68processor_name = pypar.Get_processor_name()
69
70
71#-------
72# Domain
73rect = zeros( 4, Float) # Buffer for results
74
75if myid == 0:
76
77    # read in the test files
78
79    filename = 'test-100.tsh'
80#    filename = 'merimbula_10785.tsh'
81    nx = numprocs
82    ny = 1
83    if nx*ny != numprocs:
84        print "WARNING: number of subboxes is not equal to the number of proc"
85
86    domain_full = pmesh_to_domain_instance(filename, Advection_Domain)
87    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
88#    domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))
89
90    nodes, triangles, boundary, triangles_per_proc, quantities  =\
91            pmesh_divide_metis(domain_full, numprocs)
92   
93    # subdivide the mesh
94    rect = array(domain_full.xy_extent, Float)
95#    rect = array(rect, Float)
96
97    submesh = build_submesh(nodes, triangles, boundary, quantities, \
98                            triangles_per_proc)
99
100    # send the mesh partition to the appropriate processor
101
102    for p in range(1, numprocs):
103      send_submesh(submesh, triangles_per_proc, p)
104
105    # Build the local mesh for processor 0
106   
107    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
108              extract_hostmesh(submesh, triangles_per_proc)
109
110# read in the mesh partition that belongs to this
111# processor (note that the information is in the
112# correct form for the GA data structure
113
114else:
115    [points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict] = \
116             rec_submesh(0)
117
118pypar.broadcast(rect,0)
119
120domain = Parallel_Domain(points, vertices, boundary,
121                                   full_send_dict  = full_send_dict,
122                                   ghost_recv_dict = ghost_recv_dict,
123                                   velocity = [0.1,0.0])
124
125# Make a notes of which triangles are full and which are ghost
126
127tri_full_flag = build_full_flag(domain, ghost_recv_dict)
128
129#domain.initialise_visualiser(rect=rect)
130
131#Boundaries
132
133T = Transmissive_boundary(domain)
134#R = Reflective_boundary(domain)
135domain.set_boundary( {'outflow': T, 'inflow': T, 'inner':T, 'exterior': T, 'open':T, 'ghost':None} )
136
137
138
139domain.set_quantity('stage', quantities['stage'])
140
141#---------
142# Evolution
143t0 = time.time()
144
145
146try:
147    domain.initialise_visualiser(rect=rect)
148    #domain.visualiser.coloring['stage'] = True
149    #domain.visualiser.scale_z['stage'] = 0.2
150except:
151    print 'No visualiser'
152
153
154from norms import linf_norm
155
156yieldstep = 1
157finaltime = 200
158
159#yieldstep = 1000
160#finaltime = 50000
161
162for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
163    if myid == 0:
164        domain.write_time()
165    print_test_stats(domain, tri_full_flag)
166
167if myid == 0:
168    print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.