1 | ANUGA Kinematic Viscosity Module |
---|
2 | Lindon Roberts, 2010 |
---|
3 | |
---|
4 | Summary |
---|
5 | ============================================================================ |
---|
6 | This module applies kinematic viscosity smoothing to the velocities in a |
---|
7 | domain, given by the parabolic equations |
---|
8 | du/dt = (h*u_x)_x + (h*u_y)_y |
---|
9 | dv/dt = (h*v_x)_x + (h*v_y)_y |
---|
10 | for u(x,y) and v(x,y) being water velocities, and h(x,y) is the stage height. |
---|
11 | For more details on the implementation, see the report. In particular, the |
---|
12 | code implements a pure elliptic solver. Both solvers are implicit. |
---|
13 | |
---|
14 | Files Included |
---|
15 | ============================================================================ |
---|
16 | - kinematic_viscosity.py: The main python module. |
---|
17 | - kinematic_viscosity_ext.c: The C extension to the python module. |
---|
18 | - test_kinematic_viscosity.py: A unit test for the python module. |
---|
19 | - util_ext.*: Copies of the files in anuga.utilities (for kinematic_viscosity_ext.c). |
---|
20 | - sparse.py: A modified version of anuga.utilities.sparse (which will supersede it). |
---|
21 | - test_sparse.py: A unit test for the sparse module. |
---|
22 | - make.bat: A makefile script for MinGW on Windows (this may have to be modified). |
---|
23 | |
---|
24 | Usage |
---|
25 | ============================================================================ |
---|
26 | Some sample code can be found in the unit tests. In particular, one |
---|
27 | requires an anuga.abstract_2d_finite_volumes.domain domain, a numpy |
---|
28 | vector h with h.shape == (n,) of stage heights and momentum numpy matrix |
---|
29 | p with p == [(hu) | (hv)] where u and v are x- and y-velocity and |
---|
30 | p.shape == (n,2). |
---|
31 | |
---|
32 | The stage height vector is the stage heights for the current time step. |
---|
33 | |
---|
34 | To initialise the kinematic viscosity operator, one uses |
---|
35 | kv_operator = kinematic_viscosity.Kinematic_Viscosity_Operator(domain) |
---|
36 | with optional parameters |
---|
37 | |
---|
38 | 1. apply_triangle_areas (default True) |
---|
39 | Whether or not to include the factor of 1/|Triangle area| in the numerical |
---|
40 | approximation (see the report for more details). |
---|
41 | |
---|
42 | 2. verbose (default False) |
---|
43 | Whether to include detailed logs for anuga.log. |
---|
44 | |
---|
45 | Parabolic Solver: |
---|
46 | We use the commands |
---|
47 | > kv_operator.apply_stage_heights(h) |
---|
48 | > p_new = kv_operator.parabolic_solver(p) |
---|
49 | |
---|
50 | Elliptic Solver: |
---|
51 | This solves |
---|
52 | (h*u_x)_x + (h*u_y)_y = f_1 |
---|
53 | (h*v_y)_y + (h*v_y)_y = f_2 |
---|
54 | We also need a right-hand side numpy matrix f with f.shape == (n,2) |
---|
55 | and f == [f_1 | f_2]. Then |
---|
56 | > kv_operator.apply_stage_heights(h) |
---|
57 | > p = kv_operator.cg_solve(f) |
---|
58 | You can also solve for in only one dimension with |
---|
59 | > kv_operator.apply_stage_heights(h) |
---|
60 | > kv_operator.set_qty_considered('u') |
---|
61 | > p_x = kv_operator.cg_solve(f1) |
---|
62 | (and similarly for v) |
---|
63 | |
---|
64 | ============================================================================ |
---|
65 | |
---|
66 | Last Modified: 25 October 2010 |
---|