Commit 533b7e0e authored by Luís de Sousa's avatar Luís de Sousa
Browse files

Corrected: forgotten breaks, extra #endif, passes by reference.

parent 73e3aabb
......@@ -33,7 +33,9 @@ THE SOFTWARE.
//! share the same value.
//! \author Michele Guidolin, University of Exeter,
//! contact: m.guidolin [at] exeter.ac.uk
//! \date 2011-07
//! \author Luís de Sousa, EAWAG,
//! contact: luis.desousa [at] eawag.ch
//! \date 2016-03
#include"Grid.hpp"
......@@ -598,8 +600,7 @@ namespace CA {
out<<x_sep;
}
out<<y_sep;
}
#endif
}
}
}
......
......@@ -32,7 +32,9 @@ THE SOFTWARE.
//! code for the Moore neighbourhood using the CA2D_MOORE macro.
//! \author Michele Guidolin, University of Exeter,
//! contact: m.guidolin [at] exeter.ac.uk
//! \date 2011-07
//! \author Luís de Sousa, EAWAG,
//! contact: luis.desousa [at] eawag.ch
//! \date 2016-03
#include"Common.hpp"
......@@ -452,7 +454,6 @@ inline _caReal caYCoo(CA_GRID grid, int cell_number)
case 5: y += 1; break;
case 6: y += 1/2; break;
}
#endif
// The yy distance between two adjacent cells is sqrt(3) * hexagon side.
return grid.y_coo_top - y * sqrt(3) * grid.length;
......@@ -1249,7 +1250,7 @@ inline void caWriteCellBuffState(CA_GRID grid, CA_CELLBUFF_STATE_IO dst, _caStat
//! Determines the coordinates of the neighbouring cell in the position given by cell_number.
//! Results are passed by reference.
inline void getXY(int cell_number, _caUnsigned main_x, _caUnsigned main_y,
_caUnsigned* x, _caUnsigned* y)
_caUnsigned& x, _caUnsigned& y)
{
x = main_x;
y = main_y;
......@@ -1285,7 +1286,7 @@ inline void getXY(int cell_number, _caUnsigned main_x, _caUnsigned main_y,
//! Computes indexes in the three edge buffers for a given (x,y) indexed cell.
//! Results are passed by reference.
inline void computeEdgeIndexes(CA_GRID grid, _caUnsigned x, _caUnsigned y,
_caUnsigned* i_ns, _caUnsigned* i_nwse, _caUnsigned* i_swne)
_caUnsigned& i_ns, _caUnsigned& i_nwse, _caUnsigned& i_swne)
{
i_ns = (y + grid.eb_ns_y_border) * grid.eb_ns_x_size
+ (x + grid.eb_we_x_border) + grid.eb_ns_start;
......@@ -1310,9 +1311,9 @@ inline _caReal caReadEdgeBuffReal(CA_GRID grid, CA_EDGEBUFF_REAL_I src,
_caUnsigned i_nwse;
_caUnsigned i_swne;
getXY(cell_number, grid.main_x, grid.main_y, &x, &y);
getXY(cell_number, grid.main_x, grid.main_y, x, y);
computeEdgeIndexes(grid, x, y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, x, y, i_ns, i_nwse, i_swne);
if(grid.main_x % 2) //odd
{
......@@ -1356,27 +1357,27 @@ inline void caReadEdgeBuffRealEdgeArray(CA_GRID grid, CA_EDGEBUFF_REAL_I src,
_caUnsigned i_nwse;
_caUnsigned i_swne;
getXY(cell_number, grid.main_x, grid.main_y, &x, &y);
getXY(cell_number, grid.main_x, grid.main_y, x, y);
computeEdgeIndexes(grid, x, y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, x, y, i_ns, i_nwse, i_swne);
values[0] = 0.0; break;
values[2] = src[i_ns]; break;
values[5] = src[i_ns + grid.eb_ns_x_size]; break;
values[0] = 0.0;
values[2] = src[i_ns];
values[5] = src[i_ns + grid.eb_ns_x_size];
if(grid.main_x % 2) //odd
{
values[1] = src[i_swne + 1]; break;
values[3] = src[i_nwse]; break;
values[4] = src[i_swne]; break;
values[6] = src[i_nwse + 1]; break;
values[1] = src[i_swne + 1];
values[3] = src[i_nwse];
values[4] = src[i_swne];
values[6] = src[i_nwse + 1];
}
else //even
{
values[1] = src[i_swne + grid.eb_swne_x_size]; break;
values[3] = src[i_nwse]; break;
values[4] = src[i_swne]; break;
values[6] = src[i_nwse + grid.eb_nwse_x_size]; break;
values[1] = src[i_swne + grid.eb_swne_x_size];
values[3] = src[i_nwse];
values[4] = src[i_swne];
values[6] = src[i_nwse + grid.eb_nwse_x_size];
}
}
......@@ -1389,7 +1390,7 @@ inline void caWriteEdgeBuffReal(CA_GRID grid, CA_EDGEBUFF_REAL_IO dst, int edge_
_caUnsigned i_nwse;
_caUnsigned i_swne;
computeEdgeIndexes(grid, grid.main_x, grid.main_y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, grid.main_x, grid.main_y, i_ns, i_nwse, i_swne);
if(grid.main_x % 2) //odd
{
......@@ -1433,9 +1434,9 @@ inline _caState caReadEdgeBuffState(CA_GRID grid, CA_EDGEBUFF_STATE_I src,
_caUnsigned i_nwse;
_caUnsigned i_swne;
getXY(cell_number, grid.main_x, grid.main_y, &x, &y);
getXY(cell_number, grid.main_x, grid.main_y, x, y);
computeEdgeIndexes(grid, x, y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, x, y, i_ns, i_nwse, i_swne);
if(grid.main_x % 2) //odd
{
......@@ -1479,29 +1480,29 @@ inline void caReadEdgeBuffStateEdgeArray(CA_GRID grid, CA_EDGEBUFF_STATE_I src,
_caUnsigned i_nwse;
_caUnsigned i_swne;
getXY(cell_number, grid.main_x, grid.main_y, &x, &y);
getXY(cell_number, grid.main_x, grid.main_y, x, y);
computeEdgeIndexes(grid, x, y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, x, y, i_ns, i_nwse, i_swne);
if(grid.main_x % 2) //odd
{
values[0] = 0.0; break;
values[1] = src[i_swne + 1]; break;
values[2] = src[i_ns]; break;
values[3] = src[i_nwse]; break;
values[4] = src[i_swne]; break;
values[5] = src[i_ns + grid.eb_ns_x_size]; break;
values[6] = src[i_nwse + 1]; break;
values[0] = 0.0;
values[1] = src[i_swne + 1];
values[2] = src[i_ns];
values[3] = src[i_nwse];
values[4] = src[i_swne];
values[5] = src[i_ns + grid.eb_ns_x_size];
values[6] = src[i_nwse + 1];
}
else //even
{
values[0] = 0.0; break;
values[1] = src[i_swne + grid.eb_swne_x_size]; break;
values[2] = src[i_ns]; break;
values[3] = src[i_nwse]; break;
values[4] = src[i_swne]; break;
values[5] = src[i_ns + grid.eb_ns_x_size]; break;
values[6] = src[i_nwse + grid.eb_nwse_x_size]; break;
values[0] = 0.0;
values[1] = src[i_swne + grid.eb_swne_x_size];
values[2] = src[i_ns];
values[3] = src[i_nwse];
values[4] = src[i_swne];
values[5] = src[i_ns + grid.eb_ns_x_size];
values[6] = src[i_nwse + grid.eb_nwse_x_size];
}
}
......@@ -1515,7 +1516,7 @@ inline void caWriteEdgeBuffState(CA_GRID grid, CA_EDGEBUFF_STATE_IO dst, int edg
_caUnsigned i_nwse;
_caUnsigned i_swne;
computeEdgeIndexes(grid, grid.main_x, grid.main_y, &i_ns, &i_nwse, &i_swne);
computeEdgeIndexes(grid, grid.main_x, grid.main_y, i_ns, i_nwse, i_swne);
if(grid.main_x % 2) //odd
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment