Changeset 4728


Ignore:
Timestamp:
Sep 11, 2007, 5:27:16 PM (17 years ago)
Author:
ole
Message:

Cosmetics

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

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r4723 r4728  
    150150        Pre-condition: vertex_values have been set
    151151        """
    152 
     152        # FIXME (Ole): This function is not called
     153        # in real model runs. Consider removing it.
     154       
    153155        N = self.vertex_values.shape[0]
    154156        for i in range(N):
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity_ext.c

    r4712 r4728  
    3636
    3737                if (number_of_boundaries[k] < 2) {
    38                         //Two or three true neighbours
    39 
    40                         //Get indices of neighbours (or self when used as surrogate)
    41                         //k0, k1, k2 = surrogate_neighbours[k,:]
     38                        // Two or three true neighbours
     39
     40                        // Get indices of neighbours (or self when used as surrogate)
     41                        // k0, k1, k2 = surrogate_neighbours[k,:]
    4242
    4343                        k0 = surrogate_neighbours[index3 + 0];
     
    4848                        if (k0 == k1 || k1 == k2) return -1;
    4949
    50                         //Get data
     50                        // Get data
    5151                        q0 = centroid_values[k0];
    5252                        q1 = centroid_values[k1];
     
    5757                        x2 = centroids[k2*2]; y2 = centroids[k2*2+1];
    5858
    59                         //Gradient
     59                        // Gradient
    6060                        _gradient(x0, y0, x1, y1, x2, y2, q0, q1, q2, &a[k], &b[k]);
    6161
    6262                } else if (number_of_boundaries[k] == 2) {
    63                         //One true neighbour
    64 
    65                         //Get index of the one neighbour
     63                        // One true neighbour
     64
     65                        // Get index of the one neighbour
    6666                        i=0; k0 = k;
    6767                        while (i<3 && k0==k) {
     
    7373                        k1 = k; //self
    7474
    75                         //Get data
     75                        // Get data
    7676                        q0 = centroid_values[k0];
    7777                        q1 = centroid_values[k1];
     
    8080                        x1 = centroids[k1*2]; y1 = centroids[k1*2+1];
    8181
    82                         //Two point gradient
     82                        // Two point gradient
    8383                        _gradient2(x0, y0, x1, y1, q0, q1, &a[k], &b[k]);
    8484
    85 
    86                         //Old (wrong code)
    87                         //det = x0*y1 - x1*y0;
    88                         //if (det != 0.0) {
    89                         //      a[k] = (y1*q0 - y0*q1)/det;
    90                         //      b[k] = (x0*q1 - x1*q0)/det;
    91                         //}
    9285                }
    9386                //    else:
    9487                //        #No true neighbours -
    9588                //        #Fall back to first order scheme
    96                 //        pass
    9789        }
    9890        return 0;
     
    117109                k2 = 2*k;
    118110
    119                 //Centroid coordinates
     111                // Centroid coordinates
    120112                x = centroids[k2]; y = centroids[k2+1];
    121113
    122                 //vertex coordinates
    123                 //x0, y0, x1, y1, x2, y2 = X[k,:]
     114                // vertex coordinates
     115                // x0, y0, x1, y1, x2, y2 = X[k,:]
    124116                x0 = vertex_coordinates[k6 + 0];
    125117                y0 = vertex_coordinates[k6 + 1];
     
    129121                y2 = vertex_coordinates[k6 + 5];
    130122
    131                 //Extrapolate
     123                // Extrapolate
    132124                vertex_values[k3+0] = centroid_values[k] + a[k]*(x0-x) + b[k]*(y0-y);
    133125                vertex_values[k3+1] = centroid_values[k] + a[k]*(x1-x) + b[k]*(y1-y);
     
    156148                q2 = vertex_values[k3 + 2];
    157149
    158                 //printf("%f, %f, %f\n", q0, q1, q2);
    159150                edge_values[k3 + 0] = 0.5*(q1+q2);
    160151                edge_values[k3 + 1] = 0.5*(q0+q2);
     
    167158                            double* centroid_values,
    168159                            double* centroid_backup_values) {
    169     //Backup centroid values
     160    // Backup centroid values
    170161
    171162
     
    186177                           double* centroid_values,
    187178                           double* centroid_backup_values) {
    188     //saxby centroid values
     179    // Saxby centroid values
    189180
    190181
     
    206197            double* explicit_update,
    207198            double* semi_implicit_update) {
    208         //Update centroid values based on values stored in
    209         //explicit_update and semi_implicit_update as well as given timestep
     199        // Update centroid values based on values stored in
     200        // explicit_update and semi_implicit_update as well as given timestep
    210201
    211202
     
    214205
    215206
    216         //Divide semi_implicit update by conserved quantity
     207        // Divide semi_implicit update by conserved quantity
    217208        for (k=0; k<N; k++) {
    218209                x = centroid_values[k];
     
    225216
    226217
    227         //Semi implicit updates
     218        // Semi implicit updates
    228219        for (k=0; k<N; k++) {
    229220                denominator = 1.0 - timestep*semi_implicit_update[k];
     
    236227        }
    237228
    238         /*  for (k=0; k<N; k++) {*/
    239         /*    centroid_values[k] = exp(timestep*semi_implicit_update[k])*centroid_values[k];*/
    240         /*  }*/
    241 
    242 
    243         //Explicit updates
     229
     230        // Explicit updates
    244231        for (k=0; k<N; k++) {
    245232                centroid_values[k] += timestep*explicit_update[k];
     
    247234
    248235
    249         //MH080605 set semi_implicit_update[k] to 0.0 here, rather than in update_conserved_quantities.py
     236        // MH080605 set semi_implicit_update[k] to 0.0 here, rather than in update_conserved_quantities.py
    250237        for (k=0;k<N;k++){
    251238                semi_implicit_update[k]=0.0;
     
    261248                           double* vertex_values,
    262249                           double* A) {
    263   //Average vertex values to obtain one value per node
     250  // Average vertex values to obtain one value per node
    264251
    265252  int i, index;
     
    270257  for (i=0; i<N; i++) {
    271258 
    272     //if (current_node == N) {
    273     //  printf("Current node exceeding number of nodes (%d)", N);   
    274     //  return 1;
     259    // if (current_node == N) {
     260    //   printf("Current node exceeding number of nodes (%d)", N);   
     261    //   return 1;
    275262    // }
    276263   
     
    278265    k += 1;
    279266           
    280     //volume_id = index / 3
    281     //vertex_id = index % 3
    282     //total += self.vertex_values[volume_id, vertex_id]
     267    // volume_id = index / 3
     268    // vertex_id = index % 3
     269    // total += self.vertex_values[volume_id, vertex_id]
    283270    total += vertex_values[index];
    284271     
    285     //printf("current_node=%d, index=%d, k=%d, total=%f\n", current_node, index, k, total);
     272    // printf("current_node=%d, index=%d, k=%d, total=%f\n", current_node, index, k, total);
    286273    if (number_of_triangles_per_node[current_node] == k) {
    287274      A[current_node] = total/k;
     
    334321        }
    335322
    336         //Release and return
     323        // Release and return
    337324        Py_DECREF(centroid_values);
    338325        Py_DECREF(explicit_update);
     
    368355
    369356
    370         //Release and return
     357        // Release and return
    371358        Py_DECREF(centroid_values);
    372359        Py_DECREF(centroid_backup_values);
     
    401388
    402389
    403         //Release and return
     390        // Release and return
    404391        Py_DECREF(centroid_values);
    405392        Py_DECREF(centroid_backup_values);
     
    438425        }
    439426
    440         //Release and return
     427        // Release and return
    441428        Py_DECREF(vertex_values);
    442429        Py_DECREF(edge_values);
     
    514501        }
    515502
    516         //Get pertinent variables
     503        // Get pertinent variables
    517504
    518505        centroids = get_consecutive_array(domain, "centroid_coordinates");
     
    523510        N = centroid_values -> dimensions[0];
    524511
    525         //Release
     512        // Release
    526513        Py_DECREF(domain);
    527514
    528         //Allocate space for return vectors a and b (don't DECREF)
     515        // Allocate space for return vectors a and b (don't DECREF)
    529516        dimensions[0] = N;
    530517        a = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE);
     
    546533        }
    547534
    548         //Release
     535        // Release
    549536        Py_DECREF(centroids);
    550537        Py_DECREF(centroid_values);
     
    552539        Py_DECREF(surrogate_neighbours);
    553540
    554         //Build result, release and return
     541        // Build result, release and return
    555542        R = Py_BuildValue("OO", PyArray_Return(a), PyArray_Return(b));
    556543        Py_DECREF(a);
     
    591578        }
    592579
    593         //Get pertinent variables
     580        // Get pertinent variables
    594581        centroids = get_consecutive_array(domain, "centroid_coordinates");
    595582        centroid_values = get_consecutive_array(quantity, "centroid_values");
     
    601588        N = centroid_values -> dimensions[0];
    602589
    603         //Release
     590        // Release
    604591        Py_DECREF(domain);
    605592
     
    647634
    648635
    649         //Release
     636        // Release
    650637        Py_DECREF(centroids);
    651638        Py_DECREF(centroid_values);
     
    692679        neighbours = get_consecutive_array(domain, "neighbours");
    693680
    694         //Get safety factor beta_w
     681        // Get safety factor beta_w
    695682        Tmp = PyObject_GetAttrString(domain, "beta_w");
    696683        if (!Tmp) {
     
    713700        N = qc -> dimensions[0];
    714701
    715         //Find min and max of this and neighbour's centroid values
     702        // Find min and max of this and neighbour's centroid values
    716703        qmin = malloc(N * sizeof(double));
    717704        qmax = malloc(N * sizeof(double));
     
    765752  Py_InitModule("quantity_ext", MethodTable);
    766753
    767   import_array();     //Necessary for handling of NumPY structures
    768 }
     754  import_array(); // Necessary for handling of NumPY structures
     755}
Note: See TracChangeset for help on using the changeset viewer.