source: inundation/parallel/run_parallel_merimbula.py @ 2769

Last change on this file since 2769 was 2769, checked in by linda, 18 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

  • Property svn:executable set to *
File size: 4.5 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.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#########################################################
27import sys
28import pypar    # The Python-MPI interface
29import time
30
31
32from os import sep
33sys.path.append('..'+sep+'pyvolution')
34
35# Numeric arrays
36
37from Numeric import array, zeros, Float
38# pmesh
39
40#from shallow_water import Domain
41
42from print_stats import print_test_stats, build_full_flag
43
44from pmesh2domain import pmesh_to_domain_instance
45from advection import Domain as Advection_Domain
46from parallel_advection import Parallel_Domain
47
48from generic_boundary_conditions import Transmissive_boundary
49
50# mesh partition routines
51
52from pmesh_divide  import pmesh_divide
53from build_submesh import build_submesh, extract_hostmesh
54from build_local   import build_local_mesh
55from build_commun  import send_submesh, rec_submesh
56
57
58class Set_Stage:
59    """Set an initial condition with constant water height, for x<x0
60    """
61
62    def __init__(self, x0=0.25, x1=0.5, h=1.0):
63        self.x0 = x0
64        self.x1 = x1
65        self.= h
66
67    def __call__(self, x, y):
68        return self.h*((x>self.x0)&(x<self.x1))
69
70# read in the processor information
71
72numprocs = pypar.size()
73myid = pypar.rank()
74processor_name = pypar.Get_processor_name()
75
76
77#-------
78# Domain
79rect = zeros( 4, Float) # Buffer for results
80
81if myid == 0:
82
83    # read in the test files
84
85#    filename = 'test-100.tsh'
86    filename = 'merimbula_10785.tsh'
87    nx = numprocs
88    ny = 1
89    if nx*ny != numprocs:
90        print "WARNING: number of subboxes is not equal to the number of proc"
91
92    domain_full = pmesh_to_domain_instance(filename, Advection_Domain)
93#    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
94    domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))
95
96    nodes, triangles, boundary, triangles_per_proc, quantities  =\
97            pmesh_divide(domain_full, nx, ny)
98   
99    # subdivide the mesh
100    rect = array(domain_full.xy_extent, Float)
101#    rect = array(rect, Float)
102
103    submesh = build_submesh(nodes, triangles, boundary, quantities, \
104                            triangles_per_proc)
105
106    # send the mesh partition to the appropriate processor
107
108    for p in range(1, numprocs):
109      send_submesh(submesh, triangles_per_proc, p)
110
111    hostmesh = extract_hostmesh(submesh)
112    [points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict] = \
113             build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
114
115# read in the mesh partition that belongs to this
116# processor (note that the information is in the
117# correct form for the GA data structure
118
119else:
120    [points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict] = \
121             rec_submesh(0)
122
123pypar.broadcast(rect,0)
124
125domain = Parallel_Domain(points, vertices, boundary,
126                                   full_send_dict  = full_send_dict,
127                                   ghost_recv_dict = ghost_recv_dict,
128                                   velocity = [0.1,0.0])
129
130# Make a notes of which triangles are full and which are ghost
131
132tri_full_flag = build_full_flag(domain, ghost_recv_dict)
133
134#domain.initialise_visualiser(rect=rect)
135
136#Boundaries
137
138T = Transmissive_boundary(domain)
139#R = Reflective_boundary(domain)
140domain.set_boundary( {'outflow': T, 'inflow': T, 'inner':T, 'exterior': T, 'open':T, 'ghost':None} )
141
142
143
144domain.set_quantity('stage', quantities['stage'])
145
146#---------
147# Evolution
148t0 = time.time()
149
150
151try:
152    domain.initialise_visualiser(rect=rect)
153    #domain.visualiser.coloring['stage'] = True
154    #domain.visualiser.scale_z['stage'] = 0.2
155except:
156    print 'No visualiser'
157
158
159from norms import linf_norm
160
161#yieldstep = 1
162#finaltime = 4000
163
164yieldstep = 1000
165finaltime = 50000
166
167for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
168    if myid == 0:
169        domain.write_time()
170    print_test_stats(domain, tri_full_flag)
171
172if myid == 0:
173    print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.