Changeset 8052
- Timestamp:
- Oct 27, 2010, 5:22:43 PM (14 years ago)
- Location:
- trunk/anuga_work/development/2010-projects/kv
- Files:
-
- 2 added
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/kv/kinematic_viscosity.py
r8051 r8052 1 from anuga .abstract_2d_finite_volumes.domainimport Domain1 from anuga import Domain 2 2 #from anuga.utilities.sparse import Sparse, Sparse_CSR 3 3 from sparse import Sparse, Sparse_CSR #the new import -
trunk/anuga_work/development/2010-projects/kv/kinematic_viscosity_ext.c
r8051 r8052 40 40 } 41 41 42 int build_geo_structure(int n, int tot_len, double *centroids, int *neighbours, double *edgelengths, double *edge_midpoints, int *geo_indices, double *geo_values) { 42 int build_geo_structure(int n, 43 int tot_len, 44 double *centroids, 45 long *neighbours, 46 double *edgelengths, 47 double *edge_midpoints, 48 long *geo_indices, 49 double *geo_values) { 43 50 int i, edge, edge_counted, j; 44 51 double dist, this_x, this_y, other_x, other_y, edge_length; … … 75 82 } 76 83 77 int build_operator_matrix(int n, int tot_len, int *geo_indices, double *geo_values, double *h, double *boundary_heights, double *data, int *colind) { 84 int build_operator_matrix(int n, 85 int tot_len, 86 long *geo_indices, 87 double *geo_values, 88 double *h, 89 double *boundary_heights, 90 double *data, 91 long *colind) { 78 92 int i, k, edge, j[4], *sorted_j, this_index; 79 93 double h_j, v[3], v_i; //v[k] = value of the interaction of edge k in a given triangle, v_i = (i,i) entry … … 151 165 Py_DECREF(mesh); 152 166 153 err = build_geo_structure(n,tot_len, (double *)centroid_coordinates -> data, (int *)neighbours -> data, (double *)edgelengths->data, (double *)edge_midpoint_coordinates -> data, (int *)geo_indices -> data, (double *)geo_values -> data); 167 err = build_geo_structure(n,tot_len, 168 (double *)centroid_coordinates -> data, 169 (long *)neighbours -> data, 170 (double *)edgelengths->data, 171 (double *)edge_midpoint_coordinates -> data, 172 (long *)geo_indices -> data, 173 (double *)geo_values -> data); 154 174 if (err != 0) { 155 175 PyErr_SetString(PyExc_RuntimeError, "Could not build geo structure"); … … 190 210 colind = get_consecutive_array(kv_operator,"operator_colind"); 191 211 192 err = build_operator_matrix(n,tot_len, (int *)geo_indices -> data, (double *)geo_values -> data, (double *)h -> data, (double *)boundary_heights -> data, (double *)_data -> data, (int *)colind -> data); 212 err = build_operator_matrix(n,tot_len, 213 (long *)geo_indices -> data, 214 (double *)geo_values -> data, 215 (double *)h -> data, 216 (double *)boundary_heights -> data, 217 (double *)_data -> data, 218 (long *)colind -> data); 193 219 if (err != 0) { 194 220 PyErr_SetString(PyExc_RuntimeError, "Could not get stage height interactions"); -
trunk/anuga_work/development/2010-projects/kv/test_kinematic_viscosity.py
r8051 r8052 1 from anuga.abstract_2d_finite_volumes. domain importDomain2 from anuga .abstract_2d_finite_volumes.generic_boundary_conditionsimport Dirichlet_boundary1 from anuga.abstract_2d_finite_volumes.generic_domain import Generic_Domain 2 from anuga import Dirichlet_boundary 3 3 from kinematic_viscosity import Kinematic_Viscosity_Operator 4 4 import numpy as num … … 21 21 boundary_map[(0,1)] = Dirichlet_boundary([1,1,2]) 22 22 boundary_map[(0,2)] = Dirichlet_boundary([1,1,0]) 23 domain = Domain(source=points,triangles=elements,boundary=boundary_map)23 domain = Generic_Domain(source=points,triangles=elements,boundary=boundary_map) 24 24 return Kinematic_Viscosity_Operator(domain) 25 25 … … 33 33 boundary_map[(1,0)] = Dirichlet_boundary([1,1,0]) 34 34 boundary_map[(1,2)] = Dirichlet_boundary([1,2,1]) 35 domain = Domain(source=points,triangles=elements,boundary=boundary_map)35 domain = Generic_Domain(source=points,triangles=elements,boundary=boundary_map) 36 36 return Kinematic_Viscosity_Operator(domain) 37 37 … … 146 146 U_mod[0,:] = U_new 147 147 assert num.allclose(U_new - operator1.dt * 2 * num.mat(A)*num.mat(U_mod), U[0,:]) 148 148 149 ################################################################################ 149 150 150 151 if __name__ == "__main__": 151 suite = unittest.makeSuite(Test_Kinematic_Viscosity, 'test' )152 suite = unittest.makeSuite(Test_Kinematic_Viscosity, 'test', verbose=True) 152 153 runner = unittest.TextTestRunner() 153 154 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.