source: anuga_core/source/anuga_parallel/test_parallel_sw_runup.py @ 3595

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

Arranged for domain name to be communicated automatically in the parallel API

File size: 2.9 KB
Line 
1#!/usr/bin/env python
2
3
4"""Simple water flow example using ANUGA
5
6Water driven up a linear slope and time varying boundary,
7similar to a beach environment
8
9This is a very simple test of the parallel algorithm
10"""
11
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17from anuga.pmesh.mesh_interface import create_mesh_from_regions
18from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
19from anuga.shallow_water import Domain
20from anuga.shallow_water import Reflective_boundary
21from anuga.shallow_water import Dirichlet_boundary
22from anuga.shallow_water import Time_boundary
23from anuga.shallow_water import Transmissive_boundary
24
25from parallel_api import *
26
27
28#--------------------------------------------------------------------------
29# Setup computational domain
30#--------------------------------------------------------------------------
31points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
32domain = Domain(points, vertices, boundary) # Create domain
33domain.set_name('runup')                    # Set sww filename
34
35
36#--------------------------------------------------------------------------
37# Setup initial conditions
38#--------------------------------------------------------------------------
39
40def topography(x,y): 
41    return -x/2                              # linear bed slope
42
43domain.set_quantity('elevation', topography) # Use function for elevation
44domain.set_quantity('friction', 0.1)         # Constant friction
45domain.set_quantity('stage', -.4)            # Constant initial stage
46
47
48#--------------------------------------------------------------------------
49# Create the parallel domain
50#--------------------------------------------------------------------------
51domain = distribute(domain, verbose=True)
52
53print 'P%d: name = %s' %(myid, domain.get_name())
54
55
56# TODO: Communicate all attributes of domain including boundary conditions
57
58# Name and dir, etc currently has to be set here as they are not
59# transferred from the original domain
60#domain.set_name('runup')                    # Set sww filename
61
62
63
64
65#------------------------------------------------------------------------------
66# Setup parallel boundary conditions
67#------------------------------------------------------------------------------
68
69Br = Reflective_boundary(domain)      # Solid reflective wall
70Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
71
72# Associate boundary tags with boundary objects
73domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
74                     'ghost': None})
75
76
77#------------------------------------------------------------------------------
78# Evolve system through time
79#------------------------------------------------------------------------------
80
81for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
82    pass
83    #domain.write_time()
84   
85
Note: See TracBrowser for help on using the repository browser.