Changeset 8052


Ignore:
Timestamp:
Oct 27, 2010, 5:22:43 PM (13 years ago)
Author:
steve
Message:

Modified C code to take long arrays instead of int (caused error on 64 bit machine)

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.domain import Domain
     1from anuga import Domain
    22#from anuga.utilities.sparse import Sparse, Sparse_CSR
    33from sparse import Sparse, Sparse_CSR #the new import
  • trunk/anuga_work/development/2010-projects/kv/kinematic_viscosity_ext.c

    r8051 r8052  
    4040}
    4141
    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) {
     42int 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) {
    4350    int i, edge, edge_counted, j;
    4451        double dist, this_x, this_y, other_x, other_y, edge_length;
     
    7582}
    7683
    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) {
     84int 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) {
    7892        int i, k, edge, j[4], *sorted_j, this_index;
    7993        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
     
    151165    Py_DECREF(mesh);
    152166   
    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);
    154174    if (err != 0) {
    155175        PyErr_SetString(PyExc_RuntimeError, "Could not build geo structure");
     
    190210        colind = get_consecutive_array(kv_operator,"operator_colind");
    191211       
    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);
    193219    if (err != 0) {
    194220        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 import Domain
    2 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions import Dirichlet_boundary
     1from anuga.abstract_2d_finite_volumes.generic_domain import Generic_Domain
     2from anuga import Dirichlet_boundary
    33from kinematic_viscosity import Kinematic_Viscosity_Operator
    44import numpy as num
     
    2121                boundary_map[(0,1)] = Dirichlet_boundary([1,1,2])
    2222                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)
    2424                return Kinematic_Viscosity_Operator(domain)
    2525
     
    3333                boundary_map[(1,0)] = Dirichlet_boundary([1,1,0])
    3434                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)
    3636                return Kinematic_Viscosity_Operator(domain)
    3737
     
    146146                U_mod[0,:] = U_new
    147147                assert num.allclose(U_new - operator1.dt * 2 * num.mat(A)*num.mat(U_mod), U[0,:])
     148
    148149################################################################################
    149150
    150151if __name__ == "__main__":
    151     suite = unittest.makeSuite(Test_Kinematic_Viscosity, 'test')
     152    suite = unittest.makeSuite(Test_Kinematic_Viscosity, 'test', verbose=True)
    152153    runner = unittest.TextTestRunner()
    153154    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.