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

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

Got first version of parallel api going

Still todo: Communicate all attributes of domain such as name and also boundary conditions across to other processes automatically.

File size: 2.8 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)
52
53
54
55# TODO: Communicate all attributes of domain including boundary conditions
56
57# Name and dir, etc currently has to be set here as they are not
58# transferred from the original domain
59domain.set_name('runup')                    # Set sww filename
60
61
62
63
64#------------------------------------------------------------------------------
65# Setup parallel boundary conditions
66#------------------------------------------------------------------------------
67
68Br = Reflective_boundary(domain)      # Solid reflective wall
69Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
70
71# Associate boundary tags with boundary objects
72domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
73                     'ghost': None})
74
75
76#------------------------------------------------------------------------------
77# Evolve system through time
78#------------------------------------------------------------------------------
79
80for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
81    domain.write_time()
82   
83
Note: See TracBrowser for help on using the repository browser.