1 | #!/usr/bin/env python |
---|
2 | ######################################################### |
---|
3 | # |
---|
4 | # Shows problem of conservation of mass. Due to material being |
---|
5 | # removed if too shallow. Can lead to problems if timestep |
---|
6 | # set very small. |
---|
7 | # |
---|
8 | # |
---|
9 | # |
---|
10 | # Authors: Linda Stals, Steve Roberts, Matthew Hardy, Ole Nielsen |
---|
11 | # July 2005 |
---|
12 | # |
---|
13 | # |
---|
14 | ######################################################### |
---|
15 | |
---|
16 | |
---|
17 | ############################################## |
---|
18 | # Change min_depth and see how larger values aggravate the problem |
---|
19 | yieldstep = 0.1 |
---|
20 | finaltime = 10.0 |
---|
21 | #min_depth = 1.0e-4 |
---|
22 | min_depth = 1.0e-2 |
---|
23 | |
---|
24 | |
---|
25 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular |
---|
26 | from anuga.shallow_water import Domain, Reflective_boundary |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | #Create shallow water domain |
---|
31 | points, vertices, boundary = rectangular(50, 50, len1=500, len2=500) |
---|
32 | domain = Domain(points, vertices, boundary) |
---|
33 | domain.smooth = False |
---|
34 | domain.visualise = True |
---|
35 | domain.default_order = 1 |
---|
36 | domain.minimum_allowed_height = min_depth |
---|
37 | print 'Extent', domain.get_extent() |
---|
38 | |
---|
39 | # Set initial condition |
---|
40 | class Set_IC: |
---|
41 | """Set an initial condition with a constant value, for x0<x<x1 |
---|
42 | """ |
---|
43 | |
---|
44 | def __init__(self, x0=0.25, x1=0.5, h=1.0): |
---|
45 | self.x0 = x0 |
---|
46 | self.x1 = x1 |
---|
47 | self.h = h |
---|
48 | |
---|
49 | def __call__(self, x, y): |
---|
50 | return self.h*((x>self.x0)&(x<self.x1)) |
---|
51 | |
---|
52 | |
---|
53 | domain.set_quantity('stage', Set_IC(200.0,300.0,5.0)) |
---|
54 | |
---|
55 | try: |
---|
56 | domain.initialise_visualiser() |
---|
57 | except: |
---|
58 | print 'No visualiser' |
---|
59 | else: |
---|
60 | domain.visualiser.scale_z['stage'] = 0.2 |
---|
61 | domain.visualiser.scale_z['elevation'] = 0.05 |
---|
62 | |
---|
63 | |
---|
64 | #Boundaries |
---|
65 | R = Reflective_boundary(domain) |
---|
66 | domain.set_boundary( {'left': R, 'right': R, 'top':R, 'bottom': R} ) |
---|
67 | |
---|
68 | |
---|
69 | # Evolution |
---|
70 | print 'Minimal allowed water height = ', domain.minimum_allowed_height |
---|
71 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
72 | print 'Integral stage = ', domain.quantities['stage'].get_integral(),' Time = ',domain.time |
---|
73 | |
---|
74 | |
---|