Changeset 8567


Ignore:
Timestamp:
Sep 9, 2012, 9:05:44 AM (13 years ago)
Author:
steve
Message:

C version of calc_sides

Location:
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/pmesh2domain.py

    r8565 r8567  
    219219    return sides
    220220
    221 def calc_sides(triangles):
     221def calc_sides_zip(triangles):
    222222    '''Build dictionary mapping from sides (2-tuple of points)
    223223    to left hand side neighbouring triangle
     
    242242    return sides
    243243
    244 def calc_sides_c(triangles):
     244def calc_sides(triangles):
    245245    '''Build dictionary mapping from sides (2-tuple of points)
    246246    to left hand side neighbouring triangle
     
    256256#    print type(triangles)
    257257
    258     print ntriangles
     258    #print ntriangles
    259259
    260260    from pmesh2domain_ext import sides_dictionary_construct
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/pmesh2domain_ext.c

    r8566 r8567  
    66#define DDATA(p) ((double*)(((PyArrayObject *)p)->data))
    77#define IDATA(p) ((long*)(((PyArrayObject *)p)->data))
    8 #define LENDATA(p) ((long*)(((PyArrayObject *)p)->dimensions[0]))
     8#define LENDATA(p) ((long)(((PyArrayObject *)p)->dimensions[0]))
    99
    1010
     
    1616        long *triangles;
    1717        PyObject *pyobj_key;
    18         PyObject *pyobj_value;
    1918        PyObject *pyobj_sides;
    2019        PyArrayObject *pyobj_triangles;
     
    3736           c = int(triangle[2])
    3837
    39            sides[a,b] = (id, 2) #(id, face)
    40            sides[b,c] = (id, 0) #(id, face)
    41            sides[c,a] = (id, 1) #(id, face)
     38           sides[a,b] = 3*id+2 #(id, face)
     39           sides[b,c] = 3*id+0 #(id, face)
     40           sides[c,a] = 3*id+1 #(id, face)
    4241         */
    4342
    44         printf("numTriangle %d\n",numTriangle);
     43        //printf("numTriangle %d\n",numTriangle);
    4544
    4645        for(i=0; i<numTriangle; i++){
     
    5453            PyTuple_SetItem( pyobj_key, 1, PyInt_FromLong( b ) );
    5554           
    56             pyobj_value = PyTuple_New( 2 );
    57             PyTuple_SetItem( pyobj_value, 0, PyInt_FromLong( i ) );
    58             PyTuple_SetItem( pyobj_value, 1, PyInt_FromLong( 2 ) );
    59 
    60             PyDict_SetItem( pyobj_sides, pyobj_key, pyobj_value );
     55            PyDict_SetItem( pyobj_sides, pyobj_key, PyInt_FromLong( 3*i+2 ) );
    6156
    6257            Py_DECREF(pyobj_key);
    63             Py_DECREF(pyobj_value);
    6458           
    6559            // sides[b,c] = (id, 0) #(id, face)
     
    6862            PyTuple_SetItem( pyobj_key, 1, PyInt_FromLong( c ) );
    6963           
    70             pyobj_value = PyTuple_New( 2 );
    71             PyTuple_SetItem( pyobj_value, 0, PyInt_FromLong( i ) );
    72             PyTuple_SetItem( pyobj_value, 1, PyInt_FromLong( 0 ) );
    73            
    74             PyDict_SetItem( pyobj_sides, pyobj_key, pyobj_value );
     64            PyDict_SetItem( pyobj_sides, pyobj_key, PyInt_FromLong( 3*i+0 ) );
    7565
    7666            Py_DECREF(pyobj_key);
    77             Py_DECREF(pyobj_value);
     67
    7868           
    7969            // sides[c,a] = (id, 1) #(id, face)
    8070            pyobj_key = PyTuple_New( 2 );
    8171            PyTuple_SetItem( pyobj_key, 0, PyInt_FromLong( c ) );
    82             PyTuple_SetItem( pyobj_key, 1, PyInt_FromLong( a) );
    83            
    84             pyobj_value = PyTuple_New( 2 );
    85             PyTuple_SetItem( pyobj_value, 0, PyInt_FromLong( i ) );
    86             PyTuple_SetItem( pyobj_value, 1, PyInt_FromLong( 1 ) );
    87            
    88             PyDict_SetItem( pyobj_sides, pyobj_key, pyobj_value );
     72            PyTuple_SetItem( pyobj_key, 1, PyInt_FromLong( a ) );
     73                     
     74            PyDict_SetItem( pyobj_sides, pyobj_key, PyInt_FromLong( 3*i+1 ) );
    8975
    9076            Py_DECREF(pyobj_key);
    91             Py_DECREF(pyobj_value);
     77
    9278
    9379        }
Note: See TracChangeset for help on using the changeset viewer.