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 | import sys |
---|
26 | from os import sep; sys.path.append('..'+sep+'pyvolution') |
---|
27 | from mesh_factory import rectangular |
---|
28 | from shallow_water import Domain, Reflective_boundary |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | #Create shallow water domain |
---|
33 | points, vertices, boundary = rectangular(50, 50, len1=500, len2=500) |
---|
34 | domain = Domain(points, vertices, boundary) |
---|
35 | domain.smooth = False |
---|
36 | domain.visualise = True |
---|
37 | domain.default_order = 1 |
---|
38 | domain.minimum_allowed_height = min_depth |
---|
39 | print 'Extent', domain.get_extent() |
---|
40 | |
---|
41 | # Set initial condition |
---|
42 | class Set_IC: |
---|
43 | """Set an initial condition with a constant value, for x0<x<x1 |
---|
44 | """ |
---|
45 | |
---|
46 | def __init__(self, x0=0.25, x1=0.5, h=1.0): |
---|
47 | self.x0 = x0 |
---|
48 | self.x1 = x1 |
---|
49 | self.h = h |
---|
50 | |
---|
51 | def __call__(self, x, y): |
---|
52 | return self.h*((x>self.x0)&(x<self.x1)) |
---|
53 | |
---|
54 | |
---|
55 | domain.set_quantity('stage', Set_IC(200.0,300.0,5.0)) |
---|
56 | |
---|
57 | try: |
---|
58 | domain.initialise_visualiser() |
---|
59 | except: |
---|
60 | print 'No visualiser' |
---|
61 | else: |
---|
62 | domain.visualiser.scale_z['stage'] = 0.2 |
---|
63 | domain.visualiser.scale_z['elevation'] = 0.05 |
---|
64 | |
---|
65 | |
---|
66 | #Boundaries |
---|
67 | R = Reflective_boundary(domain) |
---|
68 | domain.set_boundary( {'left': R, 'right': R, 'top':R, 'bottom': R} ) |
---|
69 | |
---|
70 | |
---|
71 | # Evolution |
---|
72 | print 'Minimal allowed water height = ', domain.minimum_allowed_height |
---|
73 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
74 | print 'Integral stage = ', domain.quantities['stage'].get_integral(),' Time = ',domain.time |
---|
75 | |
---|
76 | |
---|