Changeset 6703
- Timestamp:
- Apr 2, 2009, 4:09:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r5967 r6703 18 18 #include "math.h" 19 19 #include <stdio.h> 20 #include <string.h> 20 21 21 22 // Shared code snippets … … 26 27 27 28 // Computational function for rotation 29 // FIXME: Perhaps inline this and profile 28 30 int _rotate(double *q, double n1, double n2) { 29 31 /*Rotate the momentum component q (q[1], q[2]) … … 164 166 // This is used by flux functions 165 167 // Input parameters uh and h may be modified by this function. 168 169 // FIXME: Perhaps inline this and profile 166 170 double _compute_speed(double *uh, 167 171 double *h, … … 210 214 double v_left, v_right; 211 215 double s_min, s_max, soundspeed_left, soundspeed_right; 212 double denom, z;216 double denom, inverse_denominator, z; 213 217 214 218 // Workspace (allocate once, use many) … … 229 233 _rotate(q_right_rotated, n1, n2); 230 234 231 z = (z_left+z_right)/2; // Average elevation values.232 // Even though this will nominally allow for discontinuities233 // in the elevation data, there is currently no numerical234 // support for this so results may be strange near jumps in the bed.235 z = 0.5*(z_left+z_right); // Average elevation values. 236 // Even though this will nominally allow for discontinuities 237 // in the elevation data, there is currently no numerical 238 // support for this so results may be strange near jumps in the bed. 235 239 236 240 // Compute speeds in x-direction … … 280 284 *max_speed = 0.0; 281 285 } else { 286 inverse_denominator = 1.0/denom; 282 287 for (i=0; i<3; i++) { 283 288 edgeflux[i] = s_max*flux_left[i] - s_min*flux_right[i]; 284 289 edgeflux[i] += s_max*s_min*(q_right_rotated[i]-q_left_rotated[i]); 285 edgeflux[i] /= denom;290 edgeflux[i] *= inverse_denominator; 286 291 } 287 292 … … 1652 1657 // Start computation 1653 1658 call++; // Flag 'id' of flux calculation for this timestep 1654 1659 1660 1655 1661 // Set explicit_update to zero for all conserved_quantities. 1656 1662 // This assumes compute_fluxes called before forcing terms 1657 for (k=0; k<number_of_elements; k++) { 1658 stage_explicit_update[k]=0.0; 1659 xmom_explicit_update[k]=0.0; 1660 ymom_explicit_update[k]=0.0; 1661 } 1663 memset((char*) stage_explicit_update, 0, number_of_elements*sizeof(double)); 1664 memset((char*) xmom_explicit_update, 0, number_of_elements*sizeof(double)); 1665 memset((char*) ymom_explicit_update, 0, number_of_elements*sizeof(double)); 1666 1662 1667 1663 1668 // For all triangles … … 1666 1671 // Loop through neighbours and compute edge flux for each 1667 1672 for (i=0; i<3; i++) { 1668 ki = k*3+i; // Linear index (triangle k, edge i)1673 ki = k*3+i; // Linear index to edge i of triangle k 1669 1674 1670 1675 if (already_computed_flux[ki] == call) … … 1672 1677 continue; 1673 1678 1674 1679 // Get left hand side values from triangle k, edge i 1675 1680 ql[0] = stage_edge_values[ki]; 1676 1681 ql[1] = xmom_edge_values[ki]; … … 1678 1683 zl = bed_edge_values[ki]; 1679 1684 1680 // Quantities at neighbour on nearest face 1685 // Get right hand side values either from neighbouring triangle 1686 // or from boundary array (Quantities at neighbour on nearest face). 1681 1687 n = neighbours[ki]; 1682 1688 if (n < 0) { … … 1689 1695 zr = zl; // Extend bed elevation to boundary 1690 1696 } else { 1691 // Neighbour is a real element1697 // Neighbour is a real triangle 1692 1698 m = neighbour_edges[ki]; 1693 1699 nm = n*3+m; // Linear index (triangle n, edge m) … … 1699 1705 } 1700 1706 1707 // Now we have values for this edge - both from left and right side. 1701 1708 1702 1709 if (optimise_dry_cells) {
Note: See TracChangeset
for help on using the changeset viewer.